graphical_models.classes.dags.dag.DAG.ancestors_of
- DAG.ancestors_of(nodes: Hashable) Set[Hashable] [source]
Return the ancestors of
nodes
.- Parameters
nodes – The node.
See also
- Returns
Return all nodes j such that there is a directed path from j to
node
.- Return type
Set[node]
Example
>>> from graphical_models import DAG >>> g = DAG(arcs={(1, 2), (2, 3)}) >>> g.ancestors_of(3) {1, 2, 3}