← Back to All Algorithms

🔔 Bellman-Ford Algorithm

How It Works

Finds shortest paths even with negative edges. Detects negative cycles.

  1. Initialize: d[source] = 0, all others = ∞
  2. Repeat V-1 times: relax ALL edges
  3. Check for negative cycle (one more iteration)

Time: O(VE) — slower than Dijkstra but handles negatives

Click "Start" to run from node S