graphical_models.classes.dags.dag.DAG.reverse_arc
- DAG.reverse_arc(i: Hashable, j: Hashable, ignore_error=False, check_acyclic=False)[source]
Reverse the arc
i
->j
toi
<-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
>>> from graphical_models import DAG >>> g = DAG(arcs={(1, 2)}) >>> g.reverse_arc(1, 2) >>> g.arcs {(2, 1)}