causaldag.classes.ancestral_graph.AncestralGraph.parents_of

AncestralGraph.parents_of(nodes: Union[Hashable, Set[Hashable]]) → Set[Hashable][source]

Return the parents of the node or set of nodes nodes.

Parameters:nodes – Nodes.

Examples

>>> import causaldag as cd
>>> g = cd.AncestralGraph(directed={(1, 2), (2, 3)}, undirected={(1, 4)})
>>> g.parents_of(2)
{1}
>>> g.parents_of({2, 3})
{1, 2}