InitializeSingleSource(G,s) (1) foreach each vertex v in V (2) v.distance = infinity (3) v.parent = NULL (4) v.distance = 0
Relax(u,v,w) (1) if v.distance > u.distance + w(u,v) (2) v.distance = u.distance + w(u,v) (3) v.parent = u
Dijkstra(G,w,s) (1) Initialize SingleSource(G,s) (2) S = NUL // the set of verticies discovered (3) Q=V // G=(V,E) // Q is a heap (4) While !Q.IsEmpty() (5) u = Q.ExtractMin() (6) S = S union {u} (7) foreach v adjacient to u (8) Relax(u,v,w);
BellmanFord(G,w,s) (1) Initialize SingleSource(G,s) (2) for i = 1 to |V| - 1 do (3) for each edge (u,v) in E (4) Relax(u,v,w) (5) foreach edge (u,v) in E (6) if v.distance > u.distance + w(u,v) (7) return False (8) return True