Content deleted Content added
m →Example |
|||
Line 30:
==Correctness==
In the reweighted graph, all paths between a pair {{
:<math>\bigl(w(s, p_1) + h(s) - h(p_1)\bigr) + \bigl(w(p_1, p_2) + h(p_1) - h(p_2)\bigr) + ... + \bigl(w(p_n, t) + h(p_n) - h(t)\bigr).</math>
Line 40:
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"/>
==Analysis==
|