causaldag.classes.dag.DAG.reverse_arc

DAG.reverse_arc(i: Hashable, j: Hashable, ignore_error=False, check_acyclic=False)[source]

Reverse the arc i -> j to i <- j.

Parameters:
  • i – source of arc to be reversed.
  • j – target of arc to be reversed.
  • ignore_error – if True, ignore the KeyError raised when arc is not in the DAG.
  • check_acyclic – if True, check that the DAG remains acyclic after adding the edge.

Examples

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