Tut5 Questions
Tut5 Questions
Tutorial-5
1. Run the DFS-based topological ordering algorithm on the following graph. Whenever you have a choice of
vertices to explore, always pick the one that is alphabetically first.
(a) Indicate the pre and post numbers of the nodes.
(b) What are the sources and sinks of the graph?
2. Run the strongly connected components algorithm on the following directed graphs G. When doing DFS
on GR : whenever there is a choice of vertices to explore, always pick the one that is alphabetically first.
(a) In what order are the strongly connected components (SCCs) found ?
(b) Which are source SCCs and which are sink SCCs?
(c) Draw the “metagraph” (each meta-node is an SCC of G)?
3. Either prove or give a counterexample: if u,v is an edge in an undirected graph, and during depth-first
search post(u) < post(v), then v is an ancestor of u in the DFS tree.
4. Give an efficient algorithm which takes as input a directed graph G = (V, E) , and determines whether or
not there is a vertex s ∈ V from which all other vertices are reachable.
1
Practice Problems 5
1. . Design a linear-time algorithm which, given an undirected graph G and a particular edge e in it, determines
whether G has a cycle containing e.
2. How can the number of strongly connected components of a graph change if a new edge is added ?
3. Prove that for any directed graph G, we have ((GT )SCC )T ) = GSCC . That is, the transpose of the compo-
nent graph of GT is the same as the component graph of G.