rendered paste bodyvoid Dijkstra(GraphRef G, int s) {
if(G == NULL) {
printf("Graph.c Dijkstra() NULL arugment \n");
exit(1);
}
if((s < 1 || s > G->order)) {
printf("Graph.c Dijkstra() precondition not met. \n");
exit(1);
}
initializeSingleSource(G, s);
PriorityQueueRef Q = newPriorityQueue(G->order, G->distances);
while(getNumElements(Q) > 0) {
int u = getMin(Q);
if(!isEmpty(G->Adj[u])) {
for(moveFirst(G->Adj[u]); !offEnd(G->Adj[u]); moveNext(G->Adj[u])) {
int v = getCurrent(G->Adj[u]);
/*printf("\n\nChecking if %d is inside.\n", v);*/
/*printPriorityQueue(Q, NULL);*/
relax1(G, u, v, Q);
}
}
deleteMin(Q);
}
/*printPriorityQueue(Q, NULL);*/
freePriorityQueue(&Q);
}