ChatDiagram
Flowchart · Algorithm · Shortest Path

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.

Typ FlussdiagrammStandard Sugiyama layered DAG + orthogonal routingEngine schematex-flowchartAktualisiert 22.9.2026
Dijkstra shortest-path algorithm
Drawing preview
Die Anfrage

“Create a top-down Dijkstra shortest-path algorithm flowchart: read a non-negative weighted graph and source s, set the source distance to 0 and all other distances to infinity, then repeatedly select the unvisited vertex with minimum distance, relax its outgoing edges, and mark it visited. Leave vertices whose distance remains infinity marked unreachable, output shortest distances and predecessors, and end.”

Dann probieren SieAdd a priority-queue update after each relaxed edge.Change the output to show only the path to a target vertex.
Was diese Zeichnung zeigt

Die dahinterstehenden Entscheidungen verstehen.

01Non-negative input

The graph requirement is stated at input because Dijkstra's algorithm is not correct with negative edge weights.

02Distance initialization

Only the source starts at zero; all other tentative distances begin at infinity.

03Minimum selection

Each iteration chooses the unvisited vertex with the smallest known tentative distance.

04Unreachable output

Vertices still at infinity are explicitly reported as unreachable rather than assigned a false path.

Use this for single-source shortest paths with non-negative weights. Choose Bellman-Ford or another suitable algorithm when negative edges are possible.

Alle Flussdiagramm-Vorlagen durchsuchen →

FAQ

Häufige Fragen

Why must weights be non-negative?

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?

It means updating a neighbor's tentative distance and predecessor if going through the current vertex is shorter.

How are unreachable vertices represented?

Their distance remains infinity and the flow marks them unreachable before output.