Let be a simple undirected graph. Let be a depth first search tree of . Let be a breadth first search tree of . Consider the following statements.
- No edge of is a cross edge with respect to . (A cross edge in is between two nodes neither of which is an ancestor of the other in ).
- For every edge of , if is at depth and is at depth in , then .
Which of the statements above must necessarily be true?
View worked solution
Answer: A
We analyze the two statements for a simple undirected graph :
Statement I: In a Depth First Search (DFS) of an undirected graph, every edge of is classified as either a tree edge or a back edge. If there is an edge in , the vertex visited first (say ) must complete its exploration only after all its reachable descendants (including ) are explored. Thus, one vertex must be an ancestor of the other, meaning there are no cross edges. Hence, Statement I is true.
Statement II: In a Breadth First Search (BFS) tree , the depth difference between two adjacent vertices and in can be at most , i.e., . It is possible that (i.e., they are at the same depth).
For example, consider a triangle graph with vertices . If we start BFS from (depth ), both and will be at depth . The edge connects two vertices at the same depth, so . Hence, Statement II is false.
Thus, only Statement I is necessarily true.
Free practice · Your answers on this page are not saved.
