Free tool · runs in your browser
Dijkstra’s algorithm visualization, step by step
Choose a start and a target, then press Step: the algorithm always visits the closest unvisited node and relaxes its edges. Gold is the node being visited, teal nodes are final.
Questions
What does Dijkstra’s algorithm do?
It finds the shortest paths from one start node to every other node in a graph whose edge weights are not negative.
Why does it always pick the closest unvisited node?
With non-negative weights, no later detour can make that node’s distance shorter, so its distance is final once it is picked.
What is its time complexity?
With a binary-heap priority queue it runs in O((V + E) log V) for V nodes and E edges.