Skip to content
Free public beta until December 4, 2026: every course is open, no card needed. After that, the first chapter of each course stays free and full access is a one-time $39 ($19 for up to 100 founding members chosen for helpful feedback). Your progress is kept. How the beta works

Bellman-Ford algorithm

Finds shortest paths from one vertex to all others even when some edge weights are negative, by relaxing every edge repeatedly.

The Bellman-Ford algorithm relaxes every edge of the graph |V|-1 times, correctly handling negative edge weights (where Dijkstra's algorithm fails), and can detect a negative-weight cycle if one more relaxation pass still improves a distance.

Read the full section →
Graph settings

Calculator