# Dijkstra shortest path yields unintuitive results

Considering the following nodes with edge weights in red, Dijkstra's shortest path algorithm seems to return incorrect results, at least by the definition of the steps on wikipedia. By those rules, the distance from 0 to 2 will be calculated by passing through 1 instead of 3.

The final distances (from 0) would come out to:

0 -> 0

1 -> 0.2

2 -> 1000.2

3 -> 0.5

The weights in this case are bi-directional but I don't see a way for information of the connection between 2 and 3 to ever affect the final distance between 0 and 2. Am I missing something about the limitations of this algorithm on this type of graph or are the steps listed incorrect?

• In which order do you evaluate the nodes? What exactly do you do/get evaluating node 3? – greybeard Jan 1 '20 at 10:49
• @greybeard I misunderstood which way to propagate the current node from the instructions. I was originally taking the neighbor that had the lowest tentative distance and following a path from 0 -> 1 -> 2 -> 3. Node 3 would have a distance of 0.5 since it was one of the first values I calculated and is much lower than 1000.3. – tirefire Jan 1 '20 at 21:39