Reputation: 23
I'm trying to apply Djikstra's algorithm on this graph from my textbook, but I keep getting stuck on vertex A when trying to traverse from G->C. Here is the link to the graph image: LINK
I'll outline my steps below:
I start at the initial vertex(G).
A receives a cost of 6, E receives a cost of 1, H receives a cost of 4 since they are all initially infinity. G is marked as visited.
I go to the neighbor with the shortest cost; in this case its E.
At E, I set the cost of B as 1 + 2 = 3, and the cost of F as 1 + 2 = 3. E is then marked as visited.
I'd really appreciate some suggestions or corrections if I am approaching it wrong.
Upvotes: 2
Views: 82
Reputation: 99
At step 6 the nodes that have been visited are G, E and B. Now you have to pick the node with the minimum distance value, which is F. So the flaw in step 7 is really the assumption that it has to be a neighbour node.
Continuing from step 7:
Upvotes: 0
Reputation: 11
Since G has already been marked as visited, this node is no longer considered and thus A is also considered, since there are no more possible connections.
Upvotes: 1