Johnson's algorithm: Difference between revisions

Content deleted Content added
Danielx (talk | contribs)
clarify why reweighting does not change shortest paths
SmackBot (talk | contribs)
m Dated {{Citation needed}}. (Build p607)
Line 23:
Notice that the bracketed expression is the weight of p in the original weighting.
 
Since the reweighting adds the same amount to the weight of every s-t path, a path is a shortest path in the original weighting if and only if it is a shortest path after reweighting. If the graph did not contain a negative cycle, then due to the way the values {{math|''h(v)''}} were computed, all modified edge lengths are non-negative{{factCitation needed|date=February 2011}}, ensuring 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.
 
==Analysis==