Singly connected directed graphs

1.2k views Asked by At

According to the definition available in CLRS 3rd edition, a singly connected directed graph is the one where for every pair of vertices (u,v) there is at most 1 unique path from u->v. Now most of the answers that I have read, state that we run DFS from every vertex in the graph and if in any case we find a Cross edge or a Forward edge, then the graph is not singly connected. I can understand the concept for forward edges, but running this algo on this graph

1 --> 2 <-- 3 will give us the result that it is NOT singly connected whereas this graph is singly connected. We have a cross edge from 3 -> 2 or 1 -> 2 depending upon which vertext started this entire procedure (1 or 3) . If we start the DFS from vertex 2, then we have 2 cross edges 1 -> 2 and 3 -> 2.Can anyone clarify please ?

1

There are 1 answers

4
amit On BEST ANSWER

The answer that suggests running DFS from every node means you should stop the DFS once you cannot continue (no outgoing edges left), and not start from a different node.

In this case, in your example, you will start (w.l.o) from 1, discover 2, and you are done. No back edgees
Next, is a completely new DFS, start from 3, discover 2, and done, again without back edges.

The idea is basically verifying the attribute by definition. You do a DFS from each node u until you either find that for each v there is at most one path from u to v (DFS is exhausted) or you found at some point a 2nd path from u to v, and then you are done.