The BFS procedure is already described in the above code. Modify the code to make it (shortest path algorithm) work on a weighted directed graph (i.e., edges have weights) You can use Priority queue from STL. Output will be the shortest path froma given source to a given destination. Test it with data6
Code Snippet that may be helpful:
priority_queue < Vertex *, vector <Vertex *>, PrioritizeVertices> prior_q;
for( int i = 0; i < allVertices.size( ); i++ ) {
prior_q.push(allVertices[i]);
}
class PrioritizeVertices {
public :
bool operator()(Vertex *x, Vertex *y )
{
if (x->dist > y->dist) return true;
else return false;
}
};