Bellman Ford runs in O(VE) time, where V and E are the number of vertices and edges.
Here is a sample algorithm of Bellman-Ford
BF(G,w,s) // G = Graph, w = weight, s=source
Determine Single Source(G,s)
for i <- 1 to |V(G)| - 1 //|V(G)| Number of Vertices in the graph
do for each edge in G
do Relax edge
for each edge in G
do if Cost of Vertice r > Cost to Vertice r from Vertice u
return false
return true
See also: List of algorithms
|
Search Encyclopedia
|
Featured Article
|