Dijkstra's Shortest Path Algorithm
Find the shortest path between two nodes in a weighted graph
Controls
Graph Visualization
Start
End
Current
Visited
Step: 0 / 0
Current Distances
All Edges
Dijkstra's Algorithm Explanation
Greedy approach: Always choose the unvisited node with the smallest known distance from the start.
Time Complexity: O((V + E) log V) with a binary heap, where V is vertices and E is edges.
Important: Works only for graphs with non-negative edge weights.
- Initialize all distances to infinity except the start node (distance = 0)
- Select the unvisited node with the minimum distance
- For each unvisited neighbor, calculate the distance through the current node
- If this distance is less than the known distance, update it
- Mark the current node as visited
- Repeat until the end node is visited or all reachable nodes are visited