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

Function PQueueUpdate

OTHER/METIS/pqueue.c:294–360  ·  view source on GitHub ↗

* This function deletes a node from a partition and reinserts it with * an updated gain **************************************************************************/

Source from the content-addressed store, hash-verified

292* an updated gain
293**************************************************************************/
294int PQueueUpdate(PQueueType *queue, int node, int oldgain, int newgain)
295{
296 int i, j;
297 idxtype *locator;
298 ListNodeType *newnode;
299 KeyValueType *heap;
300
301 if (oldgain == newgain)
302 return 0;
303
304 if (queue->type == 1) {
305 /* First delete the node and then insert it */
306 PQueueDelete(queue, node, oldgain);
307 return PQueueInsert(queue, node, newgain);
308 }
309 else { /* Heap Priority Queue */
310 heap = queue->heap;
311 locator = queue->locator;
312
313 ASSERT(locator[node] != -1);
314 ASSERT(heap[locator[node]].val == node);
315 ASSERT(heap[locator[node]].key == oldgain);
316 ASSERT(CheckHeap(queue));
317
318 i = locator[node];
319
320 if (oldgain < newgain) { /* Filter-up */
321 while (i > 0) {
322 j = (i-1)>>1;
323 if (heap[j].key < newgain) {
324 heap[i] = heap[j];
325 locator[heap[i].val] = i;
326 i = j;
327 }
328 else
329 break;
330 }
331 }
332 else { /* Filter down */
333 while ((j=2*i+1) < queue->nnodes) {
334 if (heap[j].key > newgain) {
335 if (j+1 < queue->nnodes && heap[j+1].key > heap[j].key)
336 j = j+1;
337 heap[i] = heap[j];
338 locator[heap[i].val] = i;
339 i = j;
340 }
341 else if (j+1 < queue->nnodes && heap[j+1].key > newgain) {
342 j = j+1;
343 heap[i] = heap[j];
344 locator[heap[i].val] = i;
345 i = j;
346 }
347 else
348 break;
349 }
350 }
351

Callers 15

MocGeneral2WayBalance2Function · 0.85
MocGeneral2WayBalanceFunction · 0.85
MocFM_2WayEdgeRefineFunction · 0.85
Greedy_KWayEdgeRefineFunction · 0.85
Greedy_KWayEdgeBalanceFunction · 0.85
FM_2WayNodeRefineFunction · 0.85
FM_2WayNodeRefine2Function · 0.85
FM_2WayNodeRefineEqWgtFunction · 0.85
MocInit2WayBalance2Function · 0.85
MocFM_2WayEdgeRefine2Function · 0.85
FM_2WayEdgeRefineFunction · 0.85

Calls 3

PQueueDeleteFunction · 0.85
PQueueInsertFunction · 0.85
CheckHeapFunction · 0.85

Tested by

no test coverage detected