c(pp)/dijkstra-parallel-example.c
void printPath(int i, int start, int *parent, int *distance){
	int j, count, temp, path[DIM];

	// initialize path array with no connections
	for (j = 0; j < DIM; j++){
		path[j] = INF;
	}

	// removes "d(0-0) = 0	path: 0" from print output
	if (i != start){
		temp = distance[i];
		printf("\nd(%d-%d) = %d\t\tpath: ", start, i, temp);
		j = i;

		// going backwards through parents until start is reached
		count = 0;
		while(j != start) {
			j = parent[j];
			path[count] = j;
			count++;
		}

		// reversing path for nicer printing (start -> ... -> end)
		reverseArray(path, 0, DIM - 1); 

		// printing the path and resetting path array
		for (j = 0; j < DIM; j++){
			temp = path[j];
			if (temp != INF){
				printf("%d -> ", temp);
			}
			path[j] = INF;
		}
		printf("%d", i); // end node
	}
}
// 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