1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 2 /* */ 3 /* This file is part of the program and library */ 4 /* SCIP --- Solving Constraint Integer Programs */ 5 /* */ 6 /* Copyright (c) 2002-2023 Zuse Institute Berlin (ZIB) */ 7 /* */ 8 /* Licensed under the Apache License, Version 2.0 (the "License"); */ 9 /* you may not use this file except in compliance with the License. */ 10 /* You may obtain a copy of the License at */ 11 /* */ 12 /* http://www.apache.org/licenses/LICENSE-2.0 */ 13 /* */ 14 /* Unless required by applicable law or agreed to in writing, software */ 15 /* distributed under the License is distributed on an "AS IS" BASIS, */ 16 /* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ 17 /* See the License for the specific language governing permissions and */ 18 /* limitations under the License. */ 19 /* */ 20 /* You should have received a copy of the Apache-2.0 license */ 21 /* along with SCIP; see the file LICENSE. If not visit scipopt.org. */ 22 /* */ 23 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 24 25 /**@file scip_datastructures.c 26 * @ingroup OTHER_CFILES 27 * @brief public methods for data structures 28 * @author Tobias Achterberg 29 * @author Timo Berthold 30 * @author Gerald Gamrath 31 * @author Leona Gottwald 32 * @author Stefan Heinz 33 * @author Gregor Hendel 34 * @author Thorsten Koch 35 * @author Alexander Martin 36 * @author Marc Pfetsch 37 * @author Michael Winkler 38 * @author Kati Wolter 39 * 40 * @todo check all SCIP_STAGE_* switches, and include the new stages TRANSFORMED and INITSOLVE 41 */ 42 43 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ 44 45 #include "scip/misc.h" 46 #include "scip/pub_message.h" 47 #include "scip/scip_datastructures.h" 48 #include "scip/scip_mem.h" 49 #include "scip/struct_mem.h" 50 #include "scip/struct_scip.h" 51 #include "scip/struct_set.h" 52 53 /** creates a dynamic array of real values 54 * 55 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 56 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 57 */ 58 SCIP_RETCODE SCIPcreateRealarray( 59 SCIP* scip, /**< SCIP data structure */ 60 SCIP_REALARRAY** realarray /**< pointer to store the real array */ 61 ) 62 { 63 assert(scip != NULL); 64 65 SCIP_CALL( SCIPrealarrayCreate(realarray, SCIPblkmem(scip)) ); 66 67 return SCIP_OKAY; 68 } 69 70 /** frees a dynamic array of real values 71 * 72 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 73 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 74 */ 75 SCIP_RETCODE SCIPfreeRealarray( 76 SCIP* scip, /**< SCIP data structure */ 77 SCIP_REALARRAY** realarray /**< pointer to the real array */ 78 ) 79 { 80 assert(scip != NULL); 81 82 SCIP_CALL( SCIPrealarrayFree(realarray) ); 83 84 return SCIP_OKAY; 85 } 86 87 /** extends dynamic array to be able to store indices from minidx to maxidx 88 * 89 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 90 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 91 */ 92 SCIP_RETCODE SCIPextendRealarray( 93 SCIP* scip, /**< SCIP data structure */ 94 SCIP_REALARRAY* realarray, /**< dynamic real array */ 95 int minidx, /**< smallest index to allocate storage for */ 96 int maxidx /**< largest index to allocate storage for */ 97 ) 98 { 99 assert(scip != NULL); 100 101 SCIP_CALL( SCIPrealarrayExtend(realarray, scip->set->mem_arraygrowinit, scip->set->mem_arraygrowfac, minidx, maxidx) ); 102 103 return SCIP_OKAY; 104 } 105 106 /** clears a dynamic real array 107 * 108 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 109 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 110 */ 111 SCIP_RETCODE SCIPclearRealarray( 112 SCIP* scip, /**< SCIP data structure */ 113 SCIP_REALARRAY* realarray /**< dynamic real array */ 114 ) 115 { 116 assert(scip != NULL); 117 118 SCIP_CALL( SCIPrealarrayClear(realarray) ); 119 120 return SCIP_OKAY; 121 } 122 123 /** gets value of entry in dynamic array 124 * 125 * @return value of entry in dynamic array 126 */ 127 SCIP_Real SCIPgetRealarrayVal( 128 SCIP* scip, /**< SCIP data structure */ 129 SCIP_REALARRAY* realarray, /**< dynamic real array */ 130 int idx /**< array index to get value for */ 131 ) 132 { 133 assert(scip != NULL); 134 135 return SCIPrealarrayGetVal(realarray, idx); 136 } 137 138 /** sets value of entry in dynamic array 139 * 140 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 141 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 142 */ 143 SCIP_RETCODE SCIPsetRealarrayVal( 144 SCIP* scip, /**< SCIP data structure */ 145 SCIP_REALARRAY* realarray, /**< dynamic real array */ 146 int idx, /**< array index to set value for */ 147 SCIP_Real val /**< value to set array index to */ 148 ) 149 { 150 assert(scip != NULL); 151 152 SCIP_CALL( SCIPrealarraySetVal(realarray, scip->set->mem_arraygrowinit, scip->set->mem_arraygrowfac, idx, val) ); 153 154 return SCIP_OKAY; 155 } 156 157 /** increases value of entry in dynamic array 158 * 159 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 160 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 161 */ 162 SCIP_RETCODE SCIPincRealarrayVal( 163 SCIP* scip, /**< SCIP data structure */ 164 SCIP_REALARRAY* realarray, /**< dynamic real array */ 165 int idx, /**< array index to increase value for */ 166 SCIP_Real incval /**< value to increase array index */ 167 ) 168 { 169 assert(scip != NULL); 170 171 SCIP_CALL( SCIPrealarrayIncVal(realarray, scip->set->mem_arraygrowinit, scip->set->mem_arraygrowfac, idx, incval) ); 172 173 return SCIP_OKAY; 174 } 175 176 /** returns the minimal index of all stored non-zero elements 177 * 178 * @return the minimal index of all stored non-zero elements 179 */ 180 int SCIPgetRealarrayMinIdx( 181 SCIP* scip, /**< SCIP data structure */ 182 SCIP_REALARRAY* realarray /**< dynamic real array */ 183 ) 184 { 185 assert(scip != NULL); 186 187 return SCIPrealarrayGetMinIdx(realarray); 188 } 189 190 /** returns the maximal index of all stored non-zero elements 191 * 192 * @return the maximal index of all stored non-zero elements 193 */ 194 int SCIPgetRealarrayMaxIdx( 195 SCIP* scip, /**< SCIP data structure */ 196 SCIP_REALARRAY* realarray /**< dynamic real array */ 197 ) 198 { 199 assert(scip != NULL); 200 201 return SCIPrealarrayGetMaxIdx(realarray); 202 } 203 204 /** creates a dynamic array of int values 205 * 206 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 207 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 208 */ 209 SCIP_RETCODE SCIPcreateIntarray( 210 SCIP* scip, /**< SCIP data structure */ 211 SCIP_INTARRAY** intarray /**< pointer to store the int array */ 212 ) 213 { 214 assert(scip != NULL); 215 216 SCIP_CALL( SCIPintarrayCreate(intarray, SCIPblkmem(scip)) ); 217 218 return SCIP_OKAY; 219 } 220 221 /** frees a dynamic array of int values 222 * 223 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 224 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 225 */ 226 SCIP_RETCODE SCIPfreeIntarray( 227 SCIP* scip, /**< SCIP data structure */ 228 SCIP_INTARRAY** intarray /**< pointer to the int array */ 229 ) 230 { 231 assert(scip != NULL); 232 233 SCIP_CALL( SCIPintarrayFree(intarray) ); 234 235 return SCIP_OKAY; 236 } 237 238 /** extends dynamic array to be able to store indices from minidx to maxidx 239 * 240 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 241 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 242 */ 243 SCIP_RETCODE SCIPextendIntarray( 244 SCIP* scip, /**< SCIP data structure */ 245 SCIP_INTARRAY* intarray, /**< dynamic int array */ 246 int minidx, /**< smallest index to allocate storage for */ 247 int maxidx /**< largest index to allocate storage for */ 248 ) 249 { 250 assert(scip != NULL); 251 252 SCIP_CALL( SCIPintarrayExtend(intarray, scip->set->mem_arraygrowinit, scip->set->mem_arraygrowfac, minidx, maxidx) ); 253 254 return SCIP_OKAY; 255 } 256 257 /** clears a dynamic int array 258 * 259 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 260 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 261 */ 262 SCIP_RETCODE SCIPclearIntarray( 263 SCIP* scip, /**< SCIP data structure */ 264 SCIP_INTARRAY* intarray /**< dynamic int array */ 265 ) 266 { 267 assert(scip != NULL); 268 269 SCIP_CALL( SCIPintarrayClear(intarray) ); 270 271 return SCIP_OKAY; 272 } 273 274 /** gets value of entry in dynamic array 275 * 276 * @return value of entry in dynamic array 277 */ 278 int SCIPgetIntarrayVal( 279 SCIP* scip, /**< SCIP data structure */ 280 SCIP_INTARRAY* intarray, /**< dynamic int array */ 281 int idx /**< array index to get value for */ 282 ) 283 { 284 assert(scip != NULL); 285 286 return SCIPintarrayGetVal(intarray, idx); 287 } 288 289 /** sets value of entry in dynamic array 290 * 291 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 292 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 293 */ 294 SCIP_RETCODE SCIPsetIntarrayVal( 295 SCIP* scip, /**< SCIP data structure */ 296 SCIP_INTARRAY* intarray, /**< dynamic int array */ 297 int idx, /**< array index to set value for */ 298 int val /**< value to set array index to */ 299 ) 300 { 301 assert(scip != NULL); 302 303 SCIP_CALL( SCIPintarraySetVal(intarray, scip->set->mem_arraygrowinit, scip->set->mem_arraygrowfac, idx, val) ); 304 305 return SCIP_OKAY; 306 } 307 308 /** increases value of entry in dynamic array 309 * 310 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 311 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 312 */ 313 SCIP_RETCODE SCIPincIntarrayVal( 314 SCIP* scip, /**< SCIP data structure */ 315 SCIP_INTARRAY* intarray, /**< dynamic int array */ 316 int idx, /**< array index to increase value for */ 317 int incval /**< value to increase array index */ 318 ) 319 { 320 assert(scip != NULL); 321 322 SCIP_CALL( SCIPintarrayIncVal(intarray, scip->set->mem_arraygrowinit, scip->set->mem_arraygrowfac, idx, incval) ); 323 324 return SCIP_OKAY; 325 } 326 327 /** returns the minimal index of all stored non-zero elements 328 * 329 * @return the minimal index of all stored non-zero elements 330 */ 331 int SCIPgetIntarrayMinIdx( 332 SCIP* scip, /**< SCIP data structure */ 333 SCIP_INTARRAY* intarray /**< dynamic int array */ 334 ) 335 { 336 assert(scip != NULL); 337 338 return SCIPintarrayGetMinIdx(intarray); 339 } 340 341 /** returns the maximal index of all stored non-zero elements 342 * 343 * @return the maximal index of all stored non-zero elements 344 */ 345 int SCIPgetIntarrayMaxIdx( 346 SCIP* scip, /**< SCIP data structure */ 347 SCIP_INTARRAY* intarray /**< dynamic int array */ 348 ) 349 { 350 assert(scip != NULL); 351 352 return SCIPintarrayGetMaxIdx(intarray); 353 } 354 355 /** creates a dynamic array of bool values 356 * 357 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 358 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 359 */ 360 SCIP_RETCODE SCIPcreateBoolarray( 361 SCIP* scip, /**< SCIP data structure */ 362 SCIP_BOOLARRAY** boolarray /**< pointer to store the bool array */ 363 ) 364 { 365 assert(scip != NULL); 366 367 SCIP_CALL( SCIPboolarrayCreate(boolarray, SCIPblkmem(scip)) ); 368 369 return SCIP_OKAY; 370 } 371 372 /** frees a dynamic array of bool values 373 * 374 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 375 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 376 */ 377 SCIP_RETCODE SCIPfreeBoolarray( 378 SCIP* scip, /**< SCIP data structure */ 379 SCIP_BOOLARRAY** boolarray /**< pointer to the bool array */ 380 ) 381 { 382 assert(scip != NULL); 383 384 SCIP_CALL( SCIPboolarrayFree(boolarray) ); 385 386 return SCIP_OKAY; 387 } 388 389 /** extends dynamic array to be able to store indices from minidx to maxidx 390 * 391 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 392 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 393 */ 394 SCIP_RETCODE SCIPextendBoolarray( 395 SCIP* scip, /**< SCIP data structure */ 396 SCIP_BOOLARRAY* boolarray, /**< dynamic bool array */ 397 int minidx, /**< smallest index to allocate storage for */ 398 int maxidx /**< largest index to allocate storage for */ 399 ) 400 { 401 assert(scip != NULL); 402 403 SCIP_CALL( SCIPboolarrayExtend(boolarray, scip->set->mem_arraygrowinit, scip->set->mem_arraygrowfac, minidx, maxidx) ); 404 405 return SCIP_OKAY; 406 } 407 408 /** clears a dynamic bool array 409 * 410 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 411 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 412 */ 413 SCIP_RETCODE SCIPclearBoolarray( 414 SCIP* scip, /**< SCIP data structure */ 415 SCIP_BOOLARRAY* boolarray /**< dynamic bool array */ 416 ) 417 { 418 assert(scip != NULL); 419 420 SCIP_CALL( SCIPboolarrayClear(boolarray) ); 421 422 return SCIP_OKAY; 423 } 424 425 /** gets value of entry in dynamic array 426 * 427 * @return value of entry in dynamic array at position idx 428 */ 429 SCIP_Bool SCIPgetBoolarrayVal( 430 SCIP* scip, /**< SCIP data structure */ 431 SCIP_BOOLARRAY* boolarray, /**< dynamic bool array */ 432 int idx /**< array index to get value for */ 433 ) 434 { 435 assert(scip != NULL); 436 437 return SCIPboolarrayGetVal(boolarray, idx); 438 } 439 440 /** sets value of entry in dynamic array 441 * 442 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 443 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 444 */ 445 SCIP_RETCODE SCIPsetBoolarrayVal( 446 SCIP* scip, /**< SCIP data structure */ 447 SCIP_BOOLARRAY* boolarray, /**< dynamic bool array */ 448 int idx, /**< array index to set value for */ 449 SCIP_Bool val /**< value to set array index to */ 450 ) 451 { 452 assert(scip != NULL); 453 454 SCIP_CALL( SCIPboolarraySetVal(boolarray, scip->set->mem_arraygrowinit, scip->set->mem_arraygrowfac, idx, val) ); 455 456 return SCIP_OKAY; 457 } 458 459 /** returns the minimal index of all stored non-zero elements 460 * 461 * @return the minimal index of all stored non-zero elements 462 */ 463 int SCIPgetBoolarrayMinIdx( 464 SCIP* scip, /**< SCIP data structure */ 465 SCIP_BOOLARRAY* boolarray /**< dynamic bool array */ 466 ) 467 { 468 assert(scip != NULL); 469 470 return SCIPboolarrayGetMinIdx(boolarray); 471 } 472 473 /** returns the maximal index of all stored non-zero elements 474 * 475 * @return the maximal index of all stored non-zero elements 476 */ 477 int SCIPgetBoolarrayMaxIdx( 478 SCIP* scip, /**< SCIP data structure */ 479 SCIP_BOOLARRAY* boolarray /**< dynamic bool array */ 480 ) 481 { 482 assert(scip != NULL); 483 484 return SCIPboolarrayGetMaxIdx(boolarray); 485 } 486 487 /** creates a dynamic array of pointers 488 * 489 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 490 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 491 */ 492 SCIP_RETCODE SCIPcreatePtrarray( 493 SCIP* scip, /**< SCIP data structure */ 494 SCIP_PTRARRAY** ptrarray /**< pointer to store the int array */ 495 ) 496 { 497 assert(scip != NULL); 498 499 SCIP_CALL( SCIPptrarrayCreate(ptrarray, SCIPblkmem(scip)) ); 500 501 return SCIP_OKAY; 502 } 503 504 /** frees a dynamic array of pointers 505 * 506 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 507 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 508 */ 509 SCIP_RETCODE SCIPfreePtrarray( 510 SCIP* scip, /**< SCIP data structure */ 511 SCIP_PTRARRAY** ptrarray /**< pointer to the int array */ 512 ) 513 { 514 assert(scip != NULL); 515 516 SCIP_CALL( SCIPptrarrayFree(ptrarray) ); 517 518 return SCIP_OKAY; 519 } 520 521 /** extends dynamic array to be able to store indices from minidx to maxidx 522 * 523 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 524 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 525 */ 526 SCIP_RETCODE SCIPextendPtrarray( 527 SCIP* scip, /**< SCIP data structure */ 528 SCIP_PTRARRAY* ptrarray, /**< dynamic int array */ 529 int minidx, /**< smallest index to allocate storage for */ 530 int maxidx /**< largest index to allocate storage for */ 531 ) 532 { 533 assert(scip != NULL); 534 535 SCIP_CALL( SCIPptrarrayExtend(ptrarray, scip->set->mem_arraygrowinit, scip->set->mem_arraygrowfac, minidx, maxidx) ); 536 537 return SCIP_OKAY; 538 } 539 540 /** clears a dynamic pointer array 541 * 542 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 543 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 544 */ 545 SCIP_RETCODE SCIPclearPtrarray( 546 SCIP* scip, /**< SCIP data structure */ 547 SCIP_PTRARRAY* ptrarray /**< dynamic int array */ 548 ) 549 { 550 assert(scip != NULL); 551 552 SCIP_CALL( SCIPptrarrayClear(ptrarray) ); 553 554 return SCIP_OKAY; 555 } 556 557 /** gets value of entry in dynamic array */ 558 void* SCIPgetPtrarrayVal( 559 SCIP* scip, /**< SCIP data structure */ 560 SCIP_PTRARRAY* ptrarray, /**< dynamic int array */ 561 int idx /**< array index to get value for */ 562 ) 563 { 564 assert(scip != NULL); 565 566 return SCIPptrarrayGetVal(ptrarray, idx); 567 } 568 569 /** sets value of entry in dynamic array 570 * 571 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 572 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 573 */ 574 SCIP_RETCODE SCIPsetPtrarrayVal( 575 SCIP* scip, /**< SCIP data structure */ 576 SCIP_PTRARRAY* ptrarray, /**< dynamic int array */ 577 int idx, /**< array index to set value for */ 578 void* val /**< value to set array index to */ 579 ) 580 { 581 assert(scip != NULL); 582 583 SCIP_CALL( SCIPptrarraySetVal(ptrarray, scip->set->mem_arraygrowinit, scip->set->mem_arraygrowfac, idx, val) ); 584 585 return SCIP_OKAY; 586 } 587 588 /** returns the minimal index of all stored non-zero elements 589 * 590 * @return the minimal index of all stored non-zero elements 591 */ 592 int SCIPgetPtrarrayMinIdx( 593 SCIP* scip, /**< SCIP data structure */ 594 SCIP_PTRARRAY* ptrarray /**< dynamic ptr array */ 595 ) 596 { 597 assert(scip != NULL); 598 599 return SCIPptrarrayGetMinIdx(ptrarray); 600 } 601 602 /** returns the maximal index of all stored non-zero elements 603 * 604 * @return the maximal index of all stored non-zero elements 605 */ 606 int SCIPgetPtrarrayMaxIdx( 607 SCIP* scip, /**< SCIP data structure */ 608 SCIP_PTRARRAY* ptrarray /**< dynamic ptr array */ 609 ) 610 { 611 assert(scip != NULL); 612 613 return SCIPptrarrayGetMaxIdx(ptrarray); 614 } 615 616 /** creates directed graph structure */ 617 SCIP_RETCODE SCIPcreateDigraph( 618 SCIP* scip, /**< SCIP data structure */ 619 SCIP_DIGRAPH** digraph, /**< pointer to store the created directed graph */ 620 int nnodes /**< number of nodes */ 621 ) 622 { 623 assert(scip != NULL); 624 assert(digraph != NULL); 625 626 SCIP_CALL( SCIPdigraphCreate(digraph, scip->mem->probmem, nnodes) ); 627 628 return SCIP_OKAY; 629 } 630 631 /** copies directed graph structure 632 * 633 * The copying procedure uses the memory of the passed SCIP instance. The user must ensure that the digraph lives 634 * as most as long as the SCIP instance. 635 * 636 * @note The data in nodedata is copied verbatim. This possibly has to be adapted by the user. 637 */ 638 SCIP_RETCODE SCIPcopyDigraph( 639 SCIP* scip, /**< SCIP data structure */ 640 SCIP_DIGRAPH** targetdigraph, /**< pointer to store the copied directed graph */ 641 SCIP_DIGRAPH* sourcedigraph /**< source directed graph */ 642 ) 643 { 644 assert(scip != NULL); 645 assert(sourcedigraph != NULL); 646 assert(targetdigraph != NULL); 647 648 SCIP_CALL( SCIPdigraphCopy(targetdigraph, sourcedigraph, scip->mem->probmem) ); 649 650 return SCIP_OKAY; 651 } 652 653 /** creates a disjoint set (union find) structure \p uf for \p ncomponents many components (of size one) */ 654 SCIP_RETCODE SCIPcreateDisjointset( 655 SCIP* scip, /**< SCIP data structure */ 656 SCIP_DISJOINTSET** djset, /**< disjoint set (union find) data structure */ 657 int ncomponents /**< number of components */ 658 ) 659 { 660 assert(scip != NULL); 661 assert(djset != NULL); 662 663 SCIP_CALL( SCIPdisjointsetCreate(djset, scip->mem->probmem, ncomponents) ); 664 665 return SCIP_OKAY; 666 } 667 668 /** frees the disjoint set (union find) data structure */ 669 void SCIPfreeDisjointset( 670 SCIP* scip, /**< SCIP data structure */ 671 SCIP_DISJOINTSET** djset /**< disjoint set (union find) data structure */ 672 ) 673 { 674 assert(scip != NULL); 675 676 SCIPdisjointsetFree(djset, scip->mem->probmem); 677 } 678