Why it matters

Bellman-Ford handles negative weights unlike Dijkstra. Foundation of distance-vector routing.

Advertisement

The architecture

Relax all edges V-1 times.

V-th pass detects negative cycle.

O(V·E) time.

Bellman-Ford deep diveRelax edgesV-1 timesCheckV-th passDetectnegative cycleBellman 1958 + Ford 1956; used in RIP distance-vector routing
Bellman-Ford deep dive.
Advertisement

How it works end to end

V-1 relaxations.

V-th detects negative cycle.

O(V·E) time.