Dijkstra's algorithm: Difference between revisions

Content deleted Content added
BunnysBot (talk | contribs)
m Fix CW Error #61 with GenFixes (T1)
Pseudocode: missing step: add neighbor to Q
Line 56:
16 dist[''v''] ← ''alt''
17 prev[''v''] ← ''u''
18 add ''v'' to Q with distance ''alt''
18
19
1920 '''return''' dist[], prev[]
To find the shortest path between vertices {{mono|<var>source</var>}} and {{mono|<var>target</var>}}, the search terminates after line 10 if {{mono|<var>u</var> {{=}} <var>target</var>}}. The shortest path from {{mono|<var>source</var>}} to {{mono|<var>target</var>}} can be obtained by reverse iteration:
1 ''S'' ← empty sequence