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 Black.
Entry modified 19 April 2004.
HTML page formatted Fri Feb 23 10:06:07 2018.
Cite this as:
Paul E. Black, "DAG shortest paths", in Dictionary of Algorithms and Data Structures [online], Vreda Pieterse and Paul E. Black, eds. 19 April 2004. (accessed TODAY) Available from: https://www.nist.gov/dads/HTML/dagShortPath.html