Content deleted Content added
changed w(u,p1) to w(s,p1) in the correctness of the algorithm |
|||
Line 9:
Johnson's algorithm consists of the following steps:
#First, a new [[Vertex (graph theory)|node]] {{math|''q''}} is added to the graph, connected by zero-weight [[Edge (graph theory)|edges]] to each of the other nodes.
#Second, the [[Bellman–Ford algorithm]] is used, starting from the new vertex {{math|''q''}}, to find for each vertex {{math|''v''}} the
#Next the edges of the original graph are reweighted using the values computed by the Bellman–Ford algorithm: an edge from {{math|''u''}} to {{math|''v''}}, having length {{math|''w(u,v)''}}, is given the new length {{math|''w(u,v)'' + ''h(u)'' − ''h(v)''}}.
#Finally, {{math|''q''}} is removed, and [[Dijkstra's algorithm]] is used to find the shortest paths from each node {{math|''s''}} to every other vertex in the reweighted graph.
|