Dijkstra's Algorithm finds the shortest path distances from a single source node to all other vertices in a weighted graph with non-negative edge weights.
Finds the fastest driving route from your location to all destinations by continuously expanding the shortest tentative drive times.
~4,483 steps (Linearithmic)
O((V + E) log V) Time
O(V + E) Graph Memory
Memory growth rate as N expands.
Relative efficiency rating for large N.
| Operation | Time Complexity | Space Complexity |
|---|---|---|
| Min-Heap Implementation | O((V + E) log V) | O(V) |
function dijkstra(graph, start) {
const dist = {};
// priority queue relaxation
return dist;
}Calculates shortest driving routes.
Powers OSPF internet router path selection.
Validate your conceptual understanding, operation mechanics, and core concepts of Dijkstra.
Dijkstra requires non-negative edge weights. If your graph contains negative weight edges, use the Bellman-Ford algorithm instead!
Weighted graph loaded. Click Run Dijkstra to visualize shortest paths from Source A.
| Node | Distance from A | Parent | Visited |
|---|---|---|---|
| A | 0 | - | No |
| B | ∞ | - | No |
| C | ∞ | - | No |
| D | ∞ | - | No |
| E | ∞ | - | No |