c(pp)/dijkstra-sequential-example.c
// utility function that prints distance between start node and all other nodes
utility function that prints distance between start node and all other nodes
utility function that prints distance between start node and all other nodes
void printPath(int i, int start, int *path, int *parent, int *distance){
	int count, temp, j;
	if (i != start){
		temp = distance[i];
		printf("\nd(%d-%d) = %d\tpath: ", start, i, temp);
		j = i;
		count = 0;
		while(j != start) {
			j = parent[j];
			path[count] = j;
			count++;
		}
		reverseArray(path, 0, DIM - 1); 
		for (j = 0; j < DIM; j++){
			temp = path[j];
			if (temp != INF){
				printf("%d -> ", temp);
			}
			path[j] = INF;
		}
		printf("%d", i); 
	}
}
void printPath ( int i , int start , int * path , int * parent , int * distance ) { int count , temp , j ; if ( i != start ) { temp = distance [ i ] ; printf ( " \n \t " , start , i , temp ) ; j = i ; count = 0 ; while ( j != start ) { j = parent [ j ] ; path [ count ] = j ; count ++ ; } reverseArray ( path , 0 , DIM - 1 ) ; for ( j = 0 ; j < DIM ; j ++ ) { temp = path [ j ] ; if ( temp != INF ) { printf ( " " , temp ) ; } path [ j ] = INF ; } printf ( " " , i ) ; } }
utility function that prints distance between start node and all other nodes
utility function that prints distance between start node and all other nodes
// removes "d(0-0) = 0	path: 0" from print output // going backwards through parents until start is reached // reversing path for nicer printing (start -> ... -> end) // printing the path and resetting path array // end node