Content deleted Content added
Add example in intro, sections, italics for math. |
=Description of the algorithm= Rewritten (in the pseudocode S is a set of vertices, not spanning tree) |
||
Line 17:
==Description of the algorithm==
The algorithm works by keeping for each vertex ''v'' the cost ''d''[''v''] of the shortest path found so far. Initially, this value is 0 for the source vertex ''s''
and infinity for all other vertices, representing the fact that we do not know any path leading to those vertices. When the algorithm finishes, ''d''[''v''] will be
the cost of the shortest path from ''s'' to ''v'' or infinity, if no such path exists.
The algorithm also maintains two sets of vertices ''S'' and ''Q''. Set ''S'' contains all vertices for which we know that the value ''d''[''v''] is already the cost of the shortest path and set ''Q'' contains all other vertices.
Set ''S'' starts empty, and in each step one vertex is moved from ''Q'' to ''S''. This vertex chosen as the vertex with lowest value of ''d''[''u''].
When a vertex ''u'' is moved to ''S'', the algorithm checks for every
outgoing edge (''u'',''v''), whether it cannot be used to create a path
with lower cost than the cost currently stored in ''d''[''v''].
==Pseudocode==
|