TU Wien:Diskrete Mathematik für Informatik UE (Gittenberger)/Übungen WS13/Beispiel 24
Zur Navigation springen
Zur Suche springen
Find a graph and two vertices such that Dijkstra’s algorithm does not compute the distance correctly.
Solution[Bearbeiten | Quelltext bearbeiten]
x | 2 | 3 | y | Node | Predecessor |
---|---|---|---|---|---|
0 | ∞ | ∞ | ∞ | x | - |
3 | 1 | ∞ | 3 | x | |
3 | 2 | y | 3 | ||
3 | 2 | x |
The algorithm finds the path with weight 2, while the shortest path from to is with weight 1.