0

why negative edges cycles are allowed in bellman ford algorithms while no negative edge allowed in dijkstra algorithms?

James McNellis
  • 348,265
  • 75
  • 913
  • 977
user507401
  • 2,809
  • 9
  • 25
  • 20

1 Answers1

6

Allowed? Bellman-Ford algorithm allows distinct edges with negative weights (not supported in Dijkstra algorithm), but neither algorithm "allows" negative cycles. The shortest path problem makes no sense in presence of a negative cycle, so there's no meaningful way to "allow" negative cycles in any such algorithm.

Bellman-Ford algorithm can be made to detect the presence of a negative cycle and abort execution (abort, since no correct solution exists in that case).

AnT stands with Russia
  • 312,472
  • 42
  • 525
  • 765