4 ms·
Nit: It's not negative weight cycles that mess up Dijkstra's, it's negative weights in general. Dijkstra's is effectively a greedy algorithm for finding shorte
by tylerhou 4y ago
Nit: It's not negative weight cycles that mess up Dijkstra's, it's negative weights in general.
Dijkstra's is effectively a greedy algorithm for finding shortest paths. By their very nature greedy algorithms cannot "look ahead." If there is a negative weight edge locked behind a expensive edge, Dijkstra's won't be able to see the negative weight edge until it's too late.
10
A -----------------> C
\ ^
\ 11 -15 /
\-----> B -----/