Editing Shortest Path Faster Algorithm

Jump to: navigation, search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 23: Line 23:
  
 
====Proof of correctness====
 
====Proof of correctness====
We will prove that the algorithm never computes incorrect shortest path lengths.
+
We will prove that the algorithm terminates and that it computes the correct shortest path lengths.
  
 
:''Lemma'': Whenever the queue is checked for emptiness, any vertex currently capable of causing relaxation is in the queue.
 
:''Lemma'': Whenever the queue is checked for emptiness, any vertex currently capable of causing relaxation is in the queue.
Line 31: Line 31:
 
:''Proof'': If no further relaxations are possible, the algorithm continues to remove vertices from the queue, but does not add any more into the queue, because vertices are added only upon successful relaxations. Therefore the queue becomes empty and the algorithm terminates. If any further relaxations are possible, the queue is not empty, and the algorithm continues to run. <math>_{_\blacksquare}</math>
 
:''Proof'': If no further relaxations are possible, the algorithm continues to remove vertices from the queue, but does not add any more into the queue, because vertices are added only upon successful relaxations. Therefore the queue becomes empty and the algorithm terminates. If any further relaxations are possible, the queue is not empty, and the algorithm continues to run. <math>_{_\blacksquare}</math>
  
The algorithm fails to terminate if negative-weight cycles are reachable from the source. See [[Bellman–Ford algorithm#Proof of detection of negative-weight cycles|here]] for a proof that relaxations are always possible when negative-weight cycles exist. In a graph with no cycles of negative weight, when no more relaxations are possible, the correct shortest paths have been computed ([[Shortest path#Relaxation|proof]]). Therefore in graphs containing no cycles of negative weight, the algorithm will never terminate with incorrect shortest path lengths.
+
The algorithm fails to terminate if and only if negative-weight cycles are reachable from the source. See [[Bellman–Ford algorithm#Proof of detection of negative-weight cycles|here]] for a proof that relaxations are always possible when negative-weight cycles exist. In a graph with no cycles of negative weight, when no more relaxations are possible, the correct shortest paths have been computed ([[Shortest path#Relaxation|proof]]). Therefore in graphs containing no cycles of negative weight, the algorithm always terminates and always computes the correct shortest path lengths.
  
 
==References==
 
==References==
Although, [http://en.wikipedia.org/wiki/Shortest_Path_Faster_Algorithm Wikipedia] cites [http://wenku.baidu.com/view/3b8c5d778e9951e79a892705.html Duan Fanding] as the originator of the algorithm under this name, this algorithm is first discovered by Yen as his first improvement to Bellman-Ford.
+
Details of the algorithm were obtained from code written by Gelin Zhou (University of Waterloo) who himself attributes the algorithm to a slide presented in a computer science class at MIT. The contributors to this article are unable to find a reference to it in the informatics literature. The algorithm almost certainly either originated among or was popularized by Chinese informatics competitors.
 
+
 
+
The actual details used in this article were deduced from code (privately communicated to the authors) written by Gelin Zhou (University of Waterloo) who himself attributes the algorithm to a slide presented in a computer science class at MIT. The contributors to this article are unable to find a reference to it in the informatics literature. The algorithm was almost certainly popularized by Chinese informatics competitors.
+
 
+
[[Category:Algorithms]]
+
[[Category:Graph theory]]
+

Please note that all contributions to PEGWiki are considered to be released under the Attribution 3.0 Unported (see PEGWiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

Cancel | Editing help (opens in new window)