36 unsigned int count = 0;
43 for (i = 0; i < G->
nodes; ++i)
45 for (k = G->
outbeg[i]; k < G->outbeg[i] + G->
outcnt[i]; ++k)
60 if ( count > G->
arcs )
74 const unsigned int* entry,
75 const unsigned long long* value,
76 const unsigned int* order,
77 const unsigned int used,
78 const unsigned int size 83 if ( entry == NULL || value == NULL || order == NULL || used > size )
87 for (i = 0; i < used / 2; ++i)
89 if ( value[entry[i]] > value[entry[i + i]] )
91 if ( i + i + 1 < used && value[entry[i]] > value[entry[i + i + 1]] )
104 const unsigned long long* value,
110 unsigned long long val;
115 child = current + current;
116 ent = entry[current];
119 while ( child < used )
123 if ( child + 1 < used )
125 if ( value[entry[child + 1]] < value[e] )
131 if ( value[e] >= val )
140 entry[current] = ent;
141 order[ent] = current;
149 const unsigned long long* value,
154 unsigned long long val;
159 ent = entry[current];
162 while ( current > 0 )
164 parent = current / 2;
167 if ( value[e] <= val )
174 entry[current] = ent;
175 order[ent] = current;
183 unsigned long long* dist,
189 unsigned long long weight;
190 unsigned int iters = 0;
191 unsigned int used = 0;
198 assert( source < G->nodes );
199 assert( dist != NULL );
200 assert( pred != NULL );
205 for (i = 0; i < G->
nodes; ++i)
228 entry[0] = entry[
used];
235 assert( entry[used] < G->
nodes );
241 weight = G->
weight[e] + dist[tail];
244 if ( dist[head] > weight )
247 assert( used < G->nodes );
248 assert( head <= G->nodes );
255 assert( head < G->nodes );
284 unsigned long long* dist,
290 unsigned long long weight;
291 unsigned int iters = 0;
292 unsigned int used = 0;
299 assert( source < G->nodes );
300 assert( target < G->nodes );
301 assert( dist != NULL );
302 assert( pred != NULL );
307 for (i = 0; i < G->
nodes; ++i)
329 if ( tail == target )
334 entry[0] = entry[
used];
341 assert( entry[used] < G->
nodes );
347 weight = G->
weight[e] + dist[tail];
350 if ( dist[head] > weight )
353 assert( used < G->nodes );
354 assert( head <= G->nodes );
361 assert( head < G->nodes );
390 unsigned long long cutoff,
391 unsigned long long* dist,
397 unsigned long long weight;
398 unsigned int iters = 0;
399 unsigned int used = 0;
406 assert( source < G->nodes );
407 assert( target < G->nodes );
408 assert( dist != NULL );
409 assert( pred != NULL );
414 for (i = 0; i < G->
nodes; ++i)
436 if ( tail == target )
441 entry[0] = entry[
used];
448 assert( entry[used] < G->
nodes );
451 if ( dist[tail] >= cutoff )
458 weight = G->
weight[e] + dist[tail];
461 if ( dist[head] > weight )
464 assert( used < G->nodes );
465 assert( head <= G->nodes );
472 assert( head < G->nodes );
501 unsigned int* ignore,
502 unsigned long long cutoff,
503 unsigned long long* dist,
509 unsigned long long weight;
510 unsigned int iters = 0;
511 unsigned int used = 0;
518 assert( source < G->nodes );
519 assert( target < G->nodes );
520 assert( dist != NULL );
521 assert( pred != NULL );
522 assert( ignore[source] == 0 );
523 assert( ignore[target] == 0 );
528 for (i = 0; i < G->
nodes; ++i)
550 if ( tail == target )
555 entry[0] = entry[
used];
562 assert( entry[used] < G->
nodes );
565 if ( dist[tail] >= cutoff )
574 if ( ignore[head] != 0 )
577 weight = G->
weight[e] + dist[tail];
580 if ( dist[head] > weight )
583 assert( used < G->nodes );
584 assert( head <= G->nodes );
591 assert( head < G->nodes );
unsigned int dijkstraPair(const DIJKSTRA_GRAPH *G, unsigned int source, unsigned int target, unsigned long long *dist, unsigned int *pred, unsigned int *entry, unsigned int *order)
static void dijkstraSiftUp(unsigned int *entry, const unsigned long long *value, unsigned int *order, unsigned int current)
Definitions for Disjkstra's shortest path algorithm.
static DIJKSTRA_Bool dijkstraHeapIsValid(const unsigned int *entry, const unsigned long long *value, const unsigned int *order, const unsigned int used, const unsigned int size)
unsigned int dijkstraPairCutoff(const DIJKSTRA_GRAPH *G, unsigned int source, unsigned int target, unsigned long long cutoff, unsigned long long *dist, unsigned int *pred, unsigned int *entry, unsigned int *order)
DIJKSTRA_Bool dijkstraGraphIsValid(const DIJKSTRA_GRAPH *G)
unsigned int dijkstraPairCutoffIgnore(const DIJKSTRA_GRAPH *G, unsigned int source, unsigned int target, unsigned int *ignore, unsigned long long cutoff, unsigned long long *dist, unsigned int *pred, unsigned int *entry, unsigned int *order)
static void dijkstraSiftDown(unsigned int *entry, const unsigned long long *value, unsigned int *order, unsigned int used, unsigned int current)
unsigned int dijkstra(const DIJKSTRA_GRAPH *G, unsigned int source, unsigned long long *dist, unsigned int *pred, unsigned int *entry, unsigned int *order)