MCPcopy Create free account
hub / github.com/OpenSees/OpenSees / PQueueGetMax

Function PQueueGetMax

OTHER/METIS/pqueue.c:441–506  ·  view source on GitHub ↗

* This function returns the vertex with the largest gain from a partition * and removes the node from the bucket list **************************************************************************/

Source from the content-addressed store, hash-verified

439* and removes the node from the bucket list
440**************************************************************************/
441int PQueueGetMax(PQueueType *queue)
442{
443 int vtx, i, j, gain, node;
444 idxtype *locator;
445 ListNodeType *tptr;
446 KeyValueType *heap;
447
448 if (queue->nnodes == 0)
449 return -1;
450
451 queue->nnodes--;
452
453 if (queue->type == 1) {
454 tptr = queue->buckets[queue->maxgain];
455 queue->buckets[queue->maxgain] = tptr->next;
456 if (tptr->next != NULL) {
457 tptr->next->prev = NULL;
458 }
459 else {
460 if (queue->nnodes == 0) {
461 queue->maxgain = -queue->ngainspan;
462 }
463 else
464 for (; queue->buckets[queue->maxgain]==NULL; queue->maxgain--);
465 }
466
467 return tptr->id;
468 }
469 else {
470 heap = queue->heap;
471 locator = queue->locator;
472
473 vtx = heap[0].val;
474 locator[vtx] = -1;
475
476 if ((i = queue->nnodes) > 0) {
477 gain = heap[i].key;
478 node = heap[i].val;
479 i = 0;
480 while ((j=2*i+1) < queue->nnodes) {
481 if (heap[j].key > gain) {
482 if (j+1 < queue->nnodes && heap[j+1].key > heap[j].key)
483 j = j+1;
484 heap[i] = heap[j];
485 locator[heap[i].val] = i;
486 i = j;
487 }
488 else if (j+1 < queue->nnodes && heap[j+1].key > gain) {
489 j = j+1;
490 heap[i] = heap[j];
491 locator[heap[i].val] = i;
492 i = j;
493 }
494 else
495 break;
496 }
497
498 heap[i].key = gain;

Callers 15

MocGeneral2WayBalance2Function · 0.85
MocGeneral2WayBalanceFunction · 0.85
MocFM_2WayEdgeRefineFunction · 0.85
Greedy_KWayVolBalanceFunction · 0.85
Greedy_KWayEdgeRefineFunction · 0.85
Greedy_KWayEdgeBalanceFunction · 0.85
FM_2WayNodeRefineFunction · 0.85
FM_2WayNodeRefine2Function · 0.85
FM_2WayNodeRefineEqWgtFunction · 0.85
FM_2WayNodeBalanceFunction · 0.85

Calls 1

CheckHeapFunction · 0.85

Tested by

no test coverage detected