Dijkstra shortest-path algorithm flowchart
This Dijkstra shortest-path algorithm flowchart provides a compact view of the single-source procedure for a graph with non-negative edge weights. It starts by assigning distance zero to the source and infinity to every other vertex, then groups the repeated minimum-selection, edge-relaxation, and visited-marking work into one readable subroutine.
Open it in the AI editor with a prompt pre-filled — keep what works, change what doesn't.
Scenario
A developer or student needs a concise representation of Dijkstra's algorithm that states the non-negative edge constraint and the relaxation loop.
Key decisions
- Non-negative input: The graph requirement is stated at input because Dijkstra's algorithm is not correct with negative edge weights.
- Distance initialization: Only the source starts at zero; all other tentative distances begin at infinity.
- Minimum selection: Each iteration chooses the unvisited vertex with the smallest known tentative distance.
- Unreachable output: Vertices still at infinity are explicitly reported as unreachable rather than assigned a false path.
When to reuse this
Use this for single-source shortest paths with non-negative weights. Choose Bellman-Ford or another suitable algorithm when negative edges are possible.
Frequently asked questions
Why must weights be non-negative?
What does relaxing an edge mean?
How are unreachable vertices represented?
More flowchart examples
Try the diagram makers.
Tweak it with chat, export PNG/SVG, or fork it for your own use case.