Definition: Solve the single-source shortest-path problem in a weighted directed acyclic graph by 1) doing a topological sort on the vertices by edge so vertices with no incoming edges are first and vertices with only incoming edges are last, 2) assign an infinite distance to every vertex (dist(v)=∞) and a zero distance to the source, and 3) for each vertex v in sorted order, for each outgoing edge e(v,u), if dist(v) + weight(e) < dist(u), set dist(u)=dist(v) + weight(e) and the predecessor of u to v.
See also Dijkstra's algorithm, Bellman-Ford algorithm.
If you have suggestions, corrections, or comments, please get in touch with Paul E. Black.
Entry modified 19 April 2004.
HTML page formatted Fri Mar 25 16:20:34 2011.
Cite this as:
Paul E. Black, "DAG shortest paths", in Dictionary of Algorithms and Data Structures [online], Paul E. Black, ed., U.S. National Institute of Standards and Technology. 19 April 2004. (accessed TODAY) Available from: http://www.nist.gov/dads/HTML/dagShortPath.html