moral_graph#

moral_graph(G)[source]#

返回道德图

返回给定有向图的道德图。

参数:
GNetworkX 图

有向图

返回值:
HNetworkX 图

G 的无向道德图

抛出:
NetworkXNotImplemented

如果 G 是无向图。

说明

道德图是根据有向图生成的无向图 H = (V, E),其中如果一个节点有多个父节点,则在这些父节点之间插入边,并且所有有向边都变为无向边。

https://en.wikipedia.org/wiki/Moral_graph

参考文献

[1]

Wray L. Buntine. 1995. Chain graphs for learning. In Proceedings of the Eleventh conference on Uncertainty in artificial intelligence (UAI’95)

示例

>>> 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)])