causaldag.classes.dag.DAG.neighbors_of

DAG.neighbors_of(nodes: Union[Hashable, Set[Hashable]]) → Set[Hashable][source]

Return all nodes that are adjacent to the node or set of nodes node.

Parameters:nodes – A node or set of nodes.

Examples

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