0

Consider the following strategy to convert a graph with negative edge weights to one that does not have negative edge weights. Let the maximum magnitude negative edge weight in the graph be -k. Then, for each edge in the graph with weight w, update the weight to w+k+1. Consider the following claim:

To solve the shortest path problem in the original graph, we can run Dijkstra's algorithm on the modified graph and subtract the added weights to get the original

The claim is not true in general

The claim is true for all graphs

The claim is true for connected acyclic graphs

The claim is not true in general for connected graphs with cycles.

Rajnish suryavanshi
  • 3,168
  • 2
  • 17
  • 23

1 Answers1

1

Not true in general: Consider the graph with nodes A,B,C and arcs A->B, A->C, B->C with weights 1,1,-1 in that order. The shortest path from A to C is A->B->C with weight 0. Your strategy adds two to all weights, making A->C shorter (weight 3).

asp
  • 172
  • 5