Chapter 4: Paths in Graphs
Q2E
Just like the previous problem, but this time with the Bellman-Ford algorithm.

Q4E
Here's a proposal for how to find the length of the shortest cycle in an undirected graph with unit edge lengths. When a back edge, say , is encountered during a depth-first search, it forms a cycle with the tree edges from . The length of the cycle is where the level of a vertex is its distance in the DFS tree from the root vertex. This suggests the following algorithm:
• Do a depth-first search, keeping track of the level of each vertex.
• Each time a back edge is encountered, compute the cycle length and save it if it is smaller than the shortest one previously seen. Show that this strategy does not always work by providing a counterexample as well as a brief (one or two sentence) explanation.
Q5E
Question: Often there are multiple shortest paths between two nodes of a graph. Give a linear-time algorithm for the following task.
Input: Undirected graph G = (V , E )with unit edge lengths; nodes
Output: The number of distinct shortest paths from utov.
Q6E
Question: Prove that for the array prev computed by Dijkstra's algorithm, the edges form a tree.
Q7E
You are given a directed graph with (possibly negative) weighted edges, along with a specific node and a tree . Give an algorithm that checks whether T is a shortest-path tree for G with starting point s . Your algorithm should run in linear time.