Could you tell me what is wrong with my breadth first search function. I havent implemented the shortest path function but i tried to test it by displaying the predecessors but it does not work. Here is the code.
graph2.h(could not get the code brackets to work, sorry about that)
//display all vertices and who they connect to
void testDisplay()
{
for each(vertex * v in vertexList)
{
cout << v->data << ": ";
for each(vertex * u in v->neighbors)
{
cout << u->data << ", ";
}
cout << endl;
}
}
void testBreadthFirstSearch(string a)
{
breadthFirstSearch(findVertex(a));
displayPredecesors();
}
void displayPredecesors()
{
for each(vertex *v in vertexList)
{
cout<< v->predecesor;
}
}
Thanks I hadn't seen that. Does it mater if I put it at 111 instead of 109? I also found that the displayPredecessors function was incorrect, I corrected it but now the program stops when I compile. I get this error when I debug... Unhandled exception at 0x00F6B136 in Directed Graph.exe: 0xC0000005: Access violation reading location 0x00000014.
Breadth first search is still wrong. I think you're getting your vertices mixed up. s is the original vertex that you called it with. x is the current vertex you're exploring. v is one of x's neighbors, so I think lines 107-112 should be: