topics related to shortest paths, we usually focus on solving problems in directed graphs. It should
be noted, however, that most such algorithms can be easily adapted for undirected graphs.
In this chapter, the terms “edge” and “arc” are used interchangeably. We discuss two wellknown
algorithms for constructing a shortest-paths tree: Dijkstra’s algorithm and the Bellman-
Ford algorithm. Dijkstra’s algorithm assumes that all edge weights in the graph are nonnegative,
whereas the Bellman-Ford algorithm allows negative-weight edges in the graph. If there is no
negative-weight cycle, the Bellman-Ford algorithm produces the shortest paths and their weights.
Otherwise, the algorithm detects the negative cycles and indicates that no solution exists.
reachable from the source, the shortest-path weights are well defined. Thus when talking about the