Three Algorithms on Graphs
[14/100%]Construct a minimum spanning tree for the undirected graph with vertex set and edge set . The third parameter in brackets is the edge weight.
Let be an edge of maximum weight in some simple cycle of the graph . Prove that
there exists a minimum spanning tree of the graph which is also a minimum spanning tree of the graph ;
if has no other edges of the same weight, then no minimum spanning tree contains .
Let be a minimum spanning tree for a weighted undirected graph with vertices, an edge labeling. Let be the sequence of edges of , ordered by increasing . Let be an arbitrary spanning tree for with edges , ordered by increasing . Show that for all . Hint. Consider the forest of trees consisting of edges , and edges .
A drawback of Kruskal's algorithm is the need to check for the presence of cycles at each step, which is itself a fairly difficult task. The following algorithm was independently proposed by V. Jarník, R. Prim, and E. Dijkstra.
-
Choose an arbitrary vertex ; it is itself a tree (without edges).
-
At each step, add to the existing tree the edge of least weight, one of whose vertices belongs to the tree and the other does not. Prove the correctness of this algorithm for connected graphs, by analogy with Theorem 80 (Correctness of Kruskal’s algorithm): the result of running Kruskal’s algorithm is a minimum spanning tree of the input graph with edge-labeling function .
Let be a depth-first spanning tree constructed by the depth-first search algorithm for the graph . Prove that for every back edge , either is an ancestor of in , or is an ancestor of in .
Modify the depth-first search algorithm so that it computes and prints the list of all bridges of the graph.
Starting from vertex , traverse (number) the vertices of the given undirected graph using the depth-first search algorithm and construct the tree of this traversal. . Which back edge and cycle in were discovered first in this traversal? Compute the value for each vertex and determine all bridges of the graph . Assume that all adjacency lists are ordered by increasing vertex number, and the vertex with the smallest number is chosen.
Modify the depth-first search algorithm so that it allows listing all connected components of an undirected graph.
If in a directed graph there exists a vertex from which all other vertices are reachable, then for it too one can define the notion of a spanning (now directed) tree: a tree with root . Determine which of the spanning tree construction algorithms can be adapted for constructing a spanning tree in a directed graph: Kruskal's algorithm, the Jarník-Prim-Dijkstra algorithm, the depth-first search algorithm.
For the following weighted graph and vertex , determine the lengths of the shortest paths from to the other vertices of and construct the tree of these paths. Here .
Where in the proof of correctness of Dijkstra's algorithm is the nonnegativity of edge weights used? Give an example of a graph (with negative weights) for which Dijkstra's algorithm gives an incorrect answer.
Theorem 83 (Correctness of Dijkstra's algorithm): Dijkstra's algorithm constructs the shortest-path tree from vertex to every vertex reachable from it, and for each such vertex determines the length of the shortest path to it from . In the proof, by induction on : let , , denote the value of and the contents of the arrays , after iterations of the algorithm's main loop, and let be the vertex chosen at step .
Show that in the proof of the induction step of Theorem 83 on p. 248, the vertex can only be second-to-last on the shortest path from to .
How many times can the value change for a single vertex during the execution of Dijkstra's algorithm on a graph with six vertices? Give an example for each possible case.
Let a vertex be chosen in a graph , and suppose that for every vertex reachable from there is a unique shortest path from to . Prove that the edges of all these paths form a directed tree rooted at .