Content deleted Content added
Poor Yorick (talk | contribs) No edit summary |
No edit summary |
||
Line 6:
BF(G,w,s) // G = Graph, w = weight, s=source
Determine Single Source(G,s);
set Distance(s) = 0; Predecessor(s) = nil;
for i <- 1 to |V(G)| - 1 //|V(G)| Number of Vertices in the graph▼
for each vertex v
set Distance(v) = infinity, Predecessor(v) = nil;
for each edge in G▼
for each edge (u,v) in G do
if Distance(v) > Distance(u) + w(u,v) then
return false▼
set Distance(v) = Distance(u) + w(u,v), Predecessor(v) = u;
return true▼
▲ for each edge (u,r) in G do
if Distance(r) > Distance(u) + w(u,r);
▲ return false;
▲ return true;
|