After each iteration of the while loop, the set \(S\) will contain vertices \(v\) whose \(d[v]\) and \(p[v]\) values are known to be correct.
for all v ∈ V do { d[v] ← ∞; p[v] ← v }
d[s] ← 0; p[s] ← s
S ← ∅
while there is a vertex v ∈ V\S with d[v] < ∞ do {
v ← vertex in V\S with minimum d value
S ← S ∪ {v}
for each edge (v,w) do {
if w is not in S then {
if d[v] + l[v,w] < d[w] then {
d[w] ← d[v] + l[v,w]
p[w] ← v
}
}
}
}