moral_graph#
- moral_graph(G)[source]#
Return the Moral Graph
Returns the moralized graph of a given directed graph.
- Parameters:
- GNetworkX graph
Directed graph
- Returns:
- HNetworkX graph
The undirected moralized graph of G
- Raises:
- NetworkXNotImplemented
If
G
is undirected.
Notes
A moral graph is an undirected graph H = (V, E) generated from a directed Graph, where if a node has more than one parent node, edges between these parent nodes are inserted and all directed edges become undirected.
https://en.wikipedia.org/wiki/Moral_graph
References
[1]Wray L. Buntine. 1995. Chain graphs for learning. In Proceedings of the Eleventh conference on Uncertainty in artificial intelligence (UAI’95)
Examples
>>> G = nx.DiGraph([(1, 2), (2, 3), (2, 5), (3, 4), (4, 3)]) >>> G_moral = nx.moral_graph(G) >>> G_moral.edges() EdgeView([(1, 2), (2, 3), (2, 5), (2, 4), (3, 4)])