causaldag.classes.dag.DAG.sources

DAG.sources() → Set[Hashable][source]

Get all nodes in the graph that have no parents.

Returns:Nodes in the graph that have no parents.
Return type:List[node]

Example

>>> import causaldag as cd
>>> g = cd.DAG(arcs={(1, 2), (1, 3), (2, 3)})
>>> g.sources()
{1}