Question: Consider a directed graph with some negative edge weights ( but no negative cycles ) . A negative cycle is just a cycle where the
Consider a directed graph with some negative edge weights but no negative cycles A negative cycle is just a cycle where the sum total of the edge weights on the cycle is negative. Shortest paths may not really make sense if there is a negative cycle why; this is why we impose this restriction I want to find the shortest path from a vertex s to a vertex t of this graph. I come up with an idea to convert this problem into one solvable by Dijkstras algorithm. To do this, I find the most negative weight and add the same large enough value m to each and every edge weight of the graph, so that all the edge weights become positive. I now run Dijkstras algorithm on this graph with the modified edge weights and find a shortest path p from s to t in this modified graph. I claim that since all I did is add the same amount of weight to each edge, hence the same path p will be a shortest path from s to t in the original graph as well.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
