Generate all DAGs that are Markov equivalent to the current graph.
Returns:
| Type |
Description |
list[DAG]
|
Collection of DAG instances, each representing a distinct DAG in
the equivalence class.
|
Examples:
>>> G = DAG(graph="X -> Z -> Y")
>>> dags = G.equivalent_dags()
>>> len(dags)
3
Source code in causalinf/gcm.py
| def equivalent_dags(self):
"""
Generate all DAGs that are Markov equivalent to the current graph.
Returns
-------
list[DAG]
Collection of `DAG` instances, each representing a distinct DAG in
the equivalence class.
Examples
--------
>>> G = DAG(graph="X -> Z -> Y")
>>> dags = G.equivalent_dags()
>>> len(dags)
3
"""
eqs = dagitty.equivalentDAGs(self.__dagitty__)
res = []
for eq in eqs:
dag, _ = self.__dagitty2inputs__(eq)
res += [self.__rebuild_graph__(dag)]
return res
|