BayesNetFragment.moralGraph

BayesNetFragment.moralGraph()

Returns the moral graph of the BayesNet, formed by adding edges between all pairs of nodes that have a common child, and then making all edges in the graph undirected.

Returns:

The moral graph

Return type:

pyagrum.UndiGraph

Example

import pyagrum as gum

bn = gum.fastBN("A->B->C<-D;C->E")
fragment = gum.BayesNetFragment(bn)
fragment.installAscendants("C")  # A, B, C, D
sorted(fragment.moralGraph().edges())  # the parents B and D of C are married
# [(0, 1), (1, 2), (1, 3), (2, 3)]

Class

BayesNetFragment