1

I am new to graph theory and confused with ancestors definition in DAG(or in general graph).

For example in the following DAG

1--->2--->3<---4<---5

If I start DFS from 1 vertex first then path covered is 1--2--3. Then next if I start DFS from vertex 5, then the path covered is 5--4. Vertex 3 is not visited again. So visited order is 1 2 3 5 4.
What about the ancestors of 3. Are they only 1,2 or 4,5 also ? what about ancestor Ancestor of 4. Is it only 5 or 1,2 also as they were also visited before visiting 5 ?

Gowtam
  • 495
  • 2
  • 8
  • 20

1 Answers1

0

The ancestors of a vertex v in a DAG is the set of all vertices v' != v such that v is reachable from v'. So in your example, the ancestors of 3 would be 1, 2, 4 and 5.

Of course it's different if you are just looking at a particular path: so the ancestors of 3 in the path 1->2->3 would just be 1 and 2.

Mo B.
  • 5,307
  • 3
  • 25
  • 42
  • Youi are right. In the definition of ancestors, 'v is reachable from v' is important. So ancestors of 3 can be 1, 2, 4 and 5. – Gowtam Dec 06 '20 at 00:23