compute_v_structures#

compute_v_structures(G)[source]#

生成代表 G 中 v-结构的三节点元组。

自 3.4 版本弃用:compute_v_structures 实际上生成碰撞结构(colliders)。它将在 3.6 版本中移除。请改用 nx.dag.v_structuresnx.dag.colliders

碰撞结构是定向无环图(DAG)中的三元组,其中两个父节点指向同一个子节点。V-结构是不相邻的两个父节点指向同一个子节点的碰撞结构。在因果图设置中,父节点之间没有直接依赖关系,但以子节点为条件会产生关联。

参数:
G

一个 networkx DiGraph

生成:
v-结构的三元组表示

每个 v-结构是一个包含父节点、碰撞节点(即子节点)和另一个父节点的三元组。

引发:
NetworkXNotImplemented

如果 G 是无向图。

另请参阅

v_structures
colliders

注意

此函数最初用于有向无环图(DAG),但也可用于有环图。由于有环因果图文献 [2] 中提及碰撞结构,因此此函数允许有环图。如果您需要输入图是无环图的特性,建议您像示例中那样测试其是否为无环图。

参考文献

[1]

Pearl 的 PRIMER 第2章 第50页:v-结构定义。

[2]

A Hyttinen, P.O. Hoyer, F. Eberhardt, M J ̈arvisalo, (2013) “Discovering cyclic causal models with latent variables: a general SAT-based procedure”, UAI’13: Proceedings of the Twenty-Ninth Conference on Uncertainty in Artificial Intelligence, pg 301–310, doi:10.5555/3023638.3023669

示例

>>> G = nx.DiGraph([(1, 2), (0, 4), (3, 1), (2, 4), (0, 5), (4, 5), (1, 5)])
>>> nx.is_directed_acyclic_graph(G)
True
>>> list(nx.compute_v_structures(G))
[(0, 4, 2), (0, 5, 4), (0, 5, 1), (4, 5, 1)]