Introduction
• The Bellman-FordAlgorithm finds the shortest paths
from a single source to all other vertices in a weighted
graph.
• Unlike Dijkstra’s algorithm, it works with negative
weights.
• It also detects negative weight cycles.
3
4.
How It Works
•Initialization: dist[source] = 0, others = ∞
• Repeat |V|-1 times:
Relax all edges:
if dist[u] + w < dist[v]: dist[v] = dist[u] + w
• Cycle Check: One more pass — if still updates, negative
cycle exists.
4