Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shortest path after doubling edge weights

Suppose we have a weighted directed graph G and we've found the shortest path between vertices u and v in G using A* search or any other shortest path algorithm. Now suppose that we double all of the edge weights in G. Does the shortest path change?

My argument is as follows: the shortest path does not change. Call the original path P and suppose that there exists a second, different path P' from u to v such that after doubling the weights of the edges, P' is shorter than P. Then,

    weight(P') < weight(P)

after the doubling. However, dividing both sides by 2 we see that P' must have also been shorter before the doubling, so P was not the shortest path to begin with and we have a contradiction. Thus, P remains the shortest path after doubling the edge weights.

Could someone critique this solution? Is it correct?

like image 339
Ryan Avatar asked Apr 17 '15 14:04

Ryan


People also ask

Does the shortest path change when weights of all edges are multiplied by 10?

Does the shortest path change when weights of all edges are multiplied by 10? If we multiply all edge weights by 10, the shortest path doesn't change. The reason is simple, weights of all paths from s to t get multiplied by same amount. The number of edges on a path doesn't matter.

How do you find the shortest path in a weighted graph?

Given a directed graph where every edge has weight as either 1 or 2, find the shortest path from a given source vertex 's' to a given destination vertex 't'. Expected time complexity is O(V+E). A Simple Solution is to use Dijkstra's shortest path algorithm, we can get a shortest path in O(E + VLogV) time.

How do you use BFS to find shortest path in a weighted graph?

And so, the only possible way for BFS (or DFS) to find the shortest path in a weighted graph is to search the entire graph and keep recording the minimum distance from source to the destination vertex.

Can BFS handle negative weights?

BFS is applicable to unweighted graphs (or graphs where all edges have the same weight). For weighted graphs one can use algorithms such as Dijkstra's (which is a "modified BFS"), or A* (which is a "modified Dijkstra's") . However both Dijkstra's or A* do not work correctly with negative weights.


1 Answers

Yes, the shortest path remains the same. Applying a linear transformation to the edge weights does not change the shortest path, so long as you do not negate the edge weights.

like image 132
Ryan Avatar answered Oct 10 '22 07:10

Ryan