causaldag.classes.dag.DAG.remove_node

DAG.remove_node(node: Hashable, ignore_error=False)[source]

Remove the node node from the graph.

Parameters:
  • node – node to be removed.
  • ignore_error – if True, ignore the KeyError raised when node is not in the DAG.

Examples

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