How does Dijkstra's algorithm handle negative weights in a graph?

1 answer

Answer

1289963

2026-07-20 18:55

+ Follow

Dijkstra's algorithm does not work well with negative weights in a graph because it assumes all edge weights are non-negative. Negative weights can cause the algorithm to give incorrect results or get stuck in an infinite loop. To handle negative weights, a different algorithm like Bellman-Ford should be used.

ReportLike(0ShareFavorite

Copyright © 2026 eLLeNow.com All Rights Reserved.