graphical_models.classes.dags.dag.DAG.is_topological
- DAG.is_topological(order: list) bool [source]
Check that
order
is a topological order consistent with this DAG, i.e., ifi
->``j`` in the DAG, theni
comes beforej
in the order.- Parameters
order – the order to check.
Examples
>>> from graphical_models import DAG >>> g = DAG(arcs={(1, 2), (1, 3)}) >>> g.is_topological([1, 2, 3]) True >>> g.is_topological([1, 3, 2]) True >>> g.is_topological([2, 1, 3]) False