FLOWCHART

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.

UPDATED 2026-09-23
USE-CASEAlgorithm
EXAMPLEDijkstra shortest-path algorithm flowchart
Make this diagram your own.

Open it in the AI editor with a prompt pre-filled — keep what works, change what doesn't.

CASE ANALYSIS

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.

FAQ

Frequently asked questions

Why must weights be non-negative?01
Dijkstra's greedy minimum-distance selection is not reliable when a later negative edge can reduce a finalized distance.
What does relaxing an edge mean?02
It means updating a neighbor's tentative distance and predecessor if going through the current vertex is shorter.
How are unreachable vertices represented?03
Their distance remains infinity and the flow marks them unreachable before output.
Open this example in the editor →

Tweak it with chat, export PNG/SVG, or fork it for your own use case.