c(pp)/dijkstra-parallel-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 *parent, int *distance){
	int j, count, temp, path[DIM];
	for (j = 0; j < DIM; j++){
		path[j] = INF;
	}
	if (i != start){
		temp = distance[i];
		printf("\nd(%d-%d) = %d\t\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 * parent , int * distance ) { int j , count , temp , path [ DIM ] ; for ( j = 0 ; j < DIM ; j ++ ) { path [ j ] = INF ; } if ( i != start ) { temp = distance [ i ] ; printf ( " \n \t \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
// initialize path array with no connections // 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