Code Problem

here
Last edited on
For BFS i am getting 1,2,4,5,7,6 Should i be getting 1,2,3,4,5,6?

When creating the edge list, you insert the nodes at the front of the list, so the list for node 1 is 2,4,3 instead of 3,4,2. That's why the results are the way they are.
You push nodes at the front of the adjacency list, so the list for node 1 is 2,4,3, not 3,4,2. That's why your results aren't what you expect.
Last edited on
Topic archived. No new replies allowed.