DAG.moralizedAncestralGraph
- DAG.moralizedAncestralGraph(nodes)
Compute the moralized ancestral graph of the nodes from the DAG.
- Parameters:
nodes (
iterableofint) – the node ids (a set, a list…; a single node id is given as{id})- Returns:
the moralized ancestral graph of the nodes from the DAG.
- Return type:
Example
import pyagrum as gum
dag = gum.fastDAG("A->C;B->C;C->D;E->D")
mag = dag.moralizedAncestralGraph({dag.idFromName("C")})
sorted(dag.nameFromId(i) for i in mag.nodes()) # C and its ancestors
# ['A', 'B', 'C']
sorted(sorted(dag.nameFromId(i) for i in e) for e in mag.edges())
# [['A', 'B'], ['A', 'C'], ['B', 'C']]
Class