Consider the following statements:
S1 : DFS of a directed graph always produces the same number of edges in the traversal, irrespective of the starting vertex.
S2 : If all of the back edges that are found while DFS traversal on directed graph are removed, the resulting graph is acyclic.
Which of the following statements above are valid ?
(A) Both S1 and S2 are valid
(B) Only S1 is valid
(C) Only S2 is valid
(D) Neither s1 nor S2 is valid
Explanation: Statement S1 : consider the graph
Starting with A (source vertex ) we will get 2 edges
Starting with B will get only 1 edge
Starting with C we will get no edge
Therefore DFS on directed graph may not give same number of edges.
Statement S2 : Back edges are those edges (u,v) connecting a vertex u to an ancestor u in a
depth-first tree. Self-loops are considered to be back edges. Back edges describe descendant-to-ancestor relations, as they lead from “high” to “low” nodes.
Suppose that there is a back edge (u, v). Then vertex v is an ancestor of vertex u in the depth-first forest. There is thus a path from v to u in G, and the back edge (u,v) completes a cycle. Removing the back edge will break the cycle.
Therefore removing all the back edges will make the graph acyclic. So the statement is true.
Quiz of this Question