Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Johnson's algorithm
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Algorithm description== Johnson's algorithm consists of the following steps:<ref name="clrs"/><ref name="black"/> #First, a new [[Vertex (graph theory)|node]] {{mvar|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 {{mvar|q}}, to find for each vertex {{mvar|v}} the minimum weight {{math|''h''(''v'')}} of a path from {{mvar|q}} to {{mvar|v}}. If this step detects a negative cycle, the algorithm is terminated. #Next the edges of the original graph are reweighted using the values computed by the Bellman–Ford algorithm: an edge from {{mvar|u}} to {{mvar|v}}, having length {{tmath|w(u, v)}}, is given the new length {{math|''w''(''u'',''v'') + ''h''(''u'') − ''h''(''v'')}}. #Finally, {{mvar|q}} is removed, and [[Dijkstra's algorithm]] is used to find the shortest paths from each node {{mvar|s}} to every other vertex in the reweighted graph. The distance in the original graph is then computed for each distance {{mvar|D}}({{mvar|u}}, {{mvar|v}}), by adding {{mvar|''h''(''v'') − ''h''(''u'')}} to the distance returned by Dijkstra's algorithm.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)