causal_networkx.algorithms.d_separated#

causal_networkx.algorithms.d_separated(G, x, y, z=None)[source]#

Check d-separation among ‘x’ and ‘y’ given ‘z’ in graph G.

This algorithm wraps networkx.algorithms.d_separated, but allows one to pass in a ADMG instance instead.

It first converts all bidirected edges into explicit unobserved confounding nodes in an explicit networkx.DiGraph, which then calls networkx.algorithms.d_separated to determine d-separation. This inherently increases the runtime cost if there are many bidirected edges, because many nodes must be added.

Parameters:

G : ADMG

Causal graph.

x : set

First set of nodes in G.

y : set

Second set of nodes in G.

z : set

Set of conditioning nodes in G. Can be empty set.

Notes

This wraps the networkx implementation, which only allows DAGs. Since ADMG is not represented.

Examples using causal_networkx.algorithms.d_separated#