What is an intuitive explanation of Dijkstra's shortest path algorithm on a graph with negative weights?
-
See . What does it mean for an ant to traverse a negative edge from [math] u \to v [/math] with weight [math] -2 [/math]? Does it shift back all other ants that go through [math] v [/math] by [math] 2 [/math] units?
-
Answer:
Dijkstra's algorithm doesn't work correctly on graphs with negative edges. Therefore, it is perfectly OK that the metaphor with ants doesn't work for such graphs. In Dijkstra's algorithm, you process vertices in the order that corresponds to their minimal distances from the source. During the execution of the algorithm, there are moments when you declare the distance to some vertex to be final -- even though you haven't seen some of the edges in the graph yet. The reason why you can be sure that the distance is final is the assumption that the lengths of the unseen edges are non-negative. Suppose that you run Dijkstra's algorithm from vertex A. It will proceed in the following order: The final distance to A is 0. The final distance to B is 1. The final distance to C is 2. The final distance to D is 9. Oops, we just improved the shortest path to B to 0, even though B has already been processed. Fail. If you have a graph with negative edges but no negative cycles, you can still use a different algorithm (e.g., Bellman-Ford) to compute the lengths of single-source shortest paths. In graphs with negative cycles, it is possible that for some pairs of vertices there is no shortest walk (because you can always walk around the negative cycle more times), and finding the shortest path (i.e., one without repeated vertices) becomes NP-hard.
Michal Forišek at Quora Visit the source
Related Q & A:
- Where did a downloaded file from SharePoint come from? (it's SharePoint path?Best solution by SharePoint
- What's the difference between prim and dijkstra's algorithm?Best solution by Stack Overflow
- What is the difference between a Computer science (A.S.) and Computer Information Systems (A.S?Best solution by Yahoo! Answers
- What's the difference between being a pre-pharmacy major and a pharmacy major?Best solution by answers.yahoo.com
- For a U.S. Passport, what's the difference exactly between a passport book and a passport card?Best solution by ChaCha
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.