Computer Science Asked by mgus on October 21, 2021
Assume an undirected graph and a DFS traversal on it. I am interested in the DFS tree which encodes the discoverer/discovered (parent/child) relationships of the traversal. Just to make sure we are on the same page, define a discovered vertex x as one that has been visited but descendants of it are still being processed, i.e., we have not yet returned back to x. Define, a processed vertex x as one that we have returned to after we have recursed into all of its descendants and we mark it as such upon return.
Let us define the following edge types on that tree
Those are the only two types of edges one can have on undirected graph DFS. Now, I have been reading The Algorithm Design Manual (page 173) which discusses the following:
I can understand the cases when y is undiscovered or discovered but not yet processed.
However, the book says that if y is processed then we can say that it’s the 2nd time (i.e., we have seen the edge (x,y) from y before); this is because we should have seen all edges coming out of y before marking it as processed. The part I don’t understand is when such a case can occur. How can we see y again after we have marked it processed? Can you give me an example of such a graph?
Here is the simplest example.
Let the graph contain two vertices, $x$ and $y$ with one edge ${x,y}$. Here is a run of the algorithm.
You can note that, at step 4.1 when $y$ has been marked as "processed", we are seeing y again by the same edge ${x, y}$.
Here is an exercise that characterizes such occasions.
Exercise. Suppose we are given a BFS or DFS of a connected undirected graph with more than one vertices. Let $y$ be a vertex. Show the following two propositions are equivalent.
Answered by John L. on October 21, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP