Stanford Competetive Programming/06BGA(BFS).cpp
void PrintPath (vector<node> &Node, int s, int v) {
	if (v == s) {
		cout << s << "\t";
	} else if (Node[v].parent == INT_MIN) {
		cout << "No path from " << s << " to " << v << " exists." << endl;
	} else {
		PrintPath (Node, s, Node[v].parent);
		cout << v << "\t";
	}
}
/* The following procedure prints out the vertices on a shortest path from s to v, assuming that
*  BFS has already been run to compute the shortest-path tree. 
*/
The following procedure prints out the vertices on a shortest path from s to v, assuming that
BFS has already been run to compute the shortest-path tree.
The following procedure prints out the vertices on a shortest path from s to v assuming that BFS has already been run to compute the shortest - path tree .
void PrintPath (vector<node> &Node, int s, int v) {
	if (v == s) {
		cout << s << "\t";
	} else if (Node[v].parent == INT_MIN) {
		cout << "No path from " << s << " to " << v << " exists." << endl;
	} else {
		PrintPath (Node, s, Node[v].parent);
		cout << v << "\t";
	}
}
void PrintPath ( vector < node > & Node , int s , int v ) { if ( v == s ) { cout << s << " \t " ; } else if ( Node [ v ] . parent == INT_MIN ) { cout << " " << s << " " << v << " " << endl ; } else { PrintPath ( Node , s , Node [ v ] . parent ) ; cout << v << " \t " ; } }
The following procedure prints out the vertices on a shortest path from s to v, assuming that
BFS has already been run to compute the shortest-path tree.
The following procedure prints out the vertices on a shortest path from s to v assuming that BFS has already been run to compute the shortest - path tree .