Search code examples
graph-theoryundirected-graph

How are ancestors and descendants defined in an undirected graph?


I found this definition of an ancestor and this definition of a descendant. They look meaningful, but unfortunately only for rooted trees.

Also I found an informal definition for DAGs.

However, what I'm interested in is the FORMAL DEFINITION of ancestors and descendants for an undirected graph.


Solution

  • I found an interesting post that reveals the problem from a different angle.

    Quote: "We can think of undirected graphs as being equivalent to directed graphs that have bidirectional edges between nodes. When we trace all ancestors of a node, we are recursively collecting nodes along the path into that node. If we continue recursively collecting nodes in the bidirectional representation of an undirected graph, then we will end up collecting all of the nodes in the connected component of the graph that are connected to the node we are asking for ancestors. The same argument applies to descendants."

    With this in mind, we can determine:

    • "ancestors: All nodes that have a path into a node in graph G."
    • "descendants: All nodes that have a path from a node in graph G."