* Initialise d & pi*
for each vertex v within V( g )
g.d[v] := infinity
g.pi[v] := nil
g.d[s] := 0;
* Set S to empty *
S := { 0 }
Q := V(g)
* While (V-S) is not null*
while not Empty(Q)
1. Sort the vertices within V-S according to the current best estimate of their distance from the source
u := Extract-Min ( Q );
2. Add vertex u, the closest vertex into V-S, to S, Add Node( S, u );
3. Relax all of the vertices yet in V-S connected to u
relax( Node u, Node v, double w[][] )
if d[v] > d[u] + w[u]v] then
d[v] := d[u] + w[u][v]
pi[v] := u
In brief, this algorithm begins by assigning a weight of infinity to all of vertices, and then choosing a source & assigning a weight of zero to it. Vertices are added up to the set for which shortest paths are known. While a vertex is chosen, the weights of its adjacent vertices are relaxed. Once all of vertices are relaxed, their predecessor's vertices are updated (pi). The cycle of selection, weight relaxation & predecessor update is repeated till the shortest path to all vertices has been determined.