0PricingLogin
Competitive Programming Academy · Lesson

Bellman-Ford & Negative Edges

Handle negatives and detect cycles.

When Dijkstra Fails

Dijkstra trusts that a popped distance is final, but a negative edge can later make a path cheaper. So it breaks.

Enter Bellman-Ford

Bellman-Ford handles negative edge weights. It is slower than Dijkstra but robust where greedy logic cannot be trusted.

All lessons in this course

  1. Dijkstra with a Heap
  2. 0-1 BFS with a Deque
  3. Bellman-Ford & Negative Edges
  4. Floyd-Warshall All-Pairs
← Back to Competitive Programming Academy