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!
==Correctness== In the reweighted graph, all paths between a pair {{mvar|s}} and {{mvar|t}} of nodes have the same quantity {{math|''h''(''s'') − ''h''(''t'')}} added to them. The previous statement can be proven as follows: Let {{mvar|p}} be an {{tmath|s-t}} path. Its weight W in the reweighted graph is given by the following expression: <math display="block">\left(w(s, p_1) + h(s) - h(p_1)\right) + \left(w(p_1, p_2) + h(p_1) - h(p_2)\right) + ... + \left(w(p_n, t) + h(p_n) - h(t)\right).</math> Every <math>+h(p_i)</math> is cancelled by <math>-h(p_i)</math> in the previous bracketed expression; therefore, we are left with the following expression for ''W'': <math display="block">\left(w(s, p_1) + w(p_1, p_2) + \cdots + w(p_n, t)\right)+ h(s) - h(t)</math> The bracketed expression is the weight of ''p'' in the original weighting. Since the reweighting adds the same amount to the weight of every {{tmath|s-t}} path, a path is a shortest path in the original weighting if and only if it is a shortest path after reweighting. The weight of edges that belong to a shortest path from ''q'' to any node is zero, and therefore the lengths of the shortest paths from ''q'' to every node become zero in the reweighted graph; however, they still remain shortest paths. Therefore, there can be no negative edges: if edge ''uv'' had a negative weight after the reweighting, then the zero-length path from ''q'' to ''u'' together with this edge would form a negative-length path from ''q'' to ''v'', contradicting the fact that all vertices have zero distance from ''q''. The non-existence of negative edges ensures the optimality of the paths found by Dijkstra's algorithm. The distances in the original graph may be calculated from the distances calculated by Dijkstra's algorithm in the reweighted graph by reversing the reweighting transformation.<ref name="clrs"/>
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)