CS330 Introduction to Algorithms November 12, 2012 Spanning trees, single source shortest paths II. 1. Run the DAG single source shortest paths algorithm in the following graph starting from S . The graph is given by its adjacency list along with edge weights. S:A:3→B:3→C:1 A:D:4→E:1 B:D:1→E:2 C:B:1 E: 2. How can you tell after at most n iterations of the Bellman-Ford algorithm, whether there is a negative cycle in the graph? 3. Give an algorithm that can count the total number of paths (not necessary shortest paths) from the source to all other nodes in the above graph, while traversing the graph in the same order as in exercise 1. 4. (CLRS 23.1-1) Let (u, v) be a minimum-weight edge in a connected graph G. Show that (u, v) belongs to some minimum spanning tree of G. 5. Show that a subpath of a shortest path is always a shortest path. 6. Let G be a graph with weighted edges, so that negative edge weights are allowed but G does not contain any non-positive weight cycles. Show that in this case all shortest paths are simple. (A path is simple if it doesn't contain cycles.) 7. Let G be a directed graph where all edges have positive edge weights. Show how you can apply any of the single source shortest paths algorithms to nd the longest paths from a given source to all other nodes. 8. (CLRS 24.3-5) Show an example of a directed graph where Dijkstra's algorithm could relax the edges of a shortest path out of order. 9. (CLRS 23.1-8) Let T be a minimum spanning tree of graph G, and let L be the sorted list of the edge weights of T . Show that for any minimum spanning tree T 0 of G, the list L is also a sorted list of edge weights for T 0 .