Can there be multiple parents and/or multiple roots for a DAG?
2 Answers
Nothing in a DAG prevents a node from having more than one parent. Similarly, nothing prevents a DAG from having multiple roots. Thus, yes, you can have these two features in a DAG.

- 21
- 3
A DAG is a graph that flows in one direction, where no element can be a child of itself. You can still have multiple children and multiple parents for a single node of the graph.
A graph is formed by a collection of vertices and edges, where the vertices are structureless objects that are connected in pairs by edges. In the case of a directed graph, each edge has an orientation, from one vertex to another vertex. A path in a directed graph can be described by a sequence of edges having the property that the ending vertex of each edge in the sequence is the same as the starting vertex of the next edge in the sequence; a path forms a cycle if the starting vertex of its first edge equals the ending vertex of its last edge. A directed acyclic graph is a directed graph that has no cycles.
Source: Wikipedia
At the very minimum, a directed acyclic graph must have:
- Nodes: A place to store the data.
- Directed Edges: Arrows that point in one direction (the thing that makes this data structure different)
- Some great ancestral node with no parents. (Fun fact: Most ancestry trees are actually DAGs and not actually trees because cousins at some point get married to each other.)
- Leaves: Nodes with no children

- 1,608
- 3
- 29
- 51
-
Aren't ALL ancestry trees not actually trees because every node has more than one parent? – Calimocho Sep 07 '22 at 08:27