Exercise 1684Combinatorics › Graph theoryL1Added 3 Nov 2026
Dijkstra's algorithm
#Dijkstra#shortest path#weighted graph
Statement
Describe Dijkstra's algorithm for single-source shortest paths.
Hint
Maintain tentative distances; repeatedly extract the vertex with minimum distance and relax its neighbors.
Show solutionHide solution
Solution
Algorithm.
1. Set , for .
2. Priority queue with all vertices.
3. Extract vertex with minimum ; mark as finalized.
4. For each neighbor of : relax .
Correctness. Nonnegative weights guarantee that the extracted vertex's distance is final.
Complexity. .
Conclusion. Dijkstra solves SSSP in weighted nonnegative graphs.