Overview
Dijkstra's Algorithm maintains tentative distances and repeatedly settles the unsettled node with the smallest known distance, relaxing its outgoing edges.
Finds shortest paths from one source in a graph with nonnegative edge weights.
Compact metadata for implementation and discovery.
Dijkstra's Algorithm maintains tentative distances and repeatedly settles the unsettled node with the smallest known distance, relaxing its outgoing edges.
Quick facts
Runtime and memory behavior at a glance.
Best
O((V + E) log V)
Average
O((V + E) log V)
Worst
O((V + E) log V)
Space
O(V)
dist[v] = min(dist[v], dist[u] + weight(u, v))Updates a neighbor distance if the path through the current node is shorter.
Show tentative distances updating while the lowest-distance node is settled.
With a standard priority queue, duplicate queue entries are acceptable if stale entries are skipped when popped.
What each reference supports for this entry.
Textbook reference for the algorithmic family and analysis of Dijkstra's Algorithm.
Good next jumps from the relationship graph, ranked for useful discovery.
Pathfinding · Core
Incremental Dijkstra is a named variant of Dijkstra's Algorithm with a more specific construction or operating tradeoff.
Compare with thisPathfinding · Core
Multi-source Dijkstra starts with several initial sources.
Compare with thisPathfinding · Core
Both solve shortest paths, but Bellman-Ford supports negative edge weights.
Compare with thisPathfinding · Core
Block A* is a route-search alternative to Dijkstra's Algorithm with different heuristic or replanning behavior.
Compare with thisA* adds a heuristic estimate to Dijkstra-style path search.
Both solve shortest paths, but Bellman-Ford supports negative edge weights.
Bidirectional Dijkstra runs Dijkstra-style search from both directions.
Johnson's Algorithm runs Dijkstra from each source after reweighting.
Efficient Dijkstra implementations use a priority queue for tentative distances.