DSA Lab

Dijkstra and Bellman-Ford

Dijkstra and Bellman-Ford find the cheapest path from a start node to every other node in a weighted graph. Dijkstra is fast but needs non-negative weights; Bellman-Ford is slower but handles negative weights and detects negative cycles.

Dijkstra and Bellman-Ford: how it works

In this tool: shortest paths, negative edges. Put in your own values and watch it change. Each operation runs one step at a time and says in plain words what happened, with its calculation worked out. The code is shown in Python, C, C++ or Java with the line that just ran marked, and an Understand it panel gives the idea, why it works, the cost of each operation, common mistakes and a short quiz.

Lessons that use it