pywhy_graphs.ADMG#
- class pywhy_graphs.ADMG(incoming_directed_edges=None, incoming_bidirected_edges=None, incoming_undirected_edges=None, directed_edge_name: str = 'directed', bidirected_edge_name: str = 'bidirected', undirected_edge_name: str = 'undirected', **attr)[source]#
Acyclic directed mixed graph (ADMG).
A causal graph with two different edge types: bidirected and traditional directed edges. Directed edges constitute causal relations as a causal DAG did, while bidirected edges constitute the presence of a latent confounder.
- Parameters:
- incoming_directed_edgesinput directed edges (optional, default: None)
Data to initialize directed edges. All arguments that are accepted by
networkx.DiGraph
are accepted.- incoming_bidirected_edgesinput bidirected edges (optional, default: None)
Data to initialize bidirected edges. All arguments that are accepted by
networkx.Graph
are accepted.- incoming_undirected_edgesinput undirected edges (optional, default: None)
Data to initialize undirected edges. All arguments that are accepted by
networkx.Graph
are accepted.- directed_edge_namestr
The name for the directed edges. By default ‘directed’.
- bidirected_edge_namestr
The name for the bidirected edges. By default ‘bidirected’.
- undirected_edge_namestr
The name for the directed edges. By default ‘undirected’.
- attrkeyword arguments, optional (default= no attributes)
Attributes to add to graph as key=value pairs.
Notes
Edge Type Subgraphs
The data structure underneath the hood is stored in two networkx graphs:
networkx.Graph
andnetworkx.DiGraph
to represent the non-directed edges and directed edges. Non-directed edges in an ADMG can be present as bidirected edges standing for latent confounders, or undirected edges standing for selection bias.- Directed edges (<-, ->, indicating causal relationship) =
networkx.DiGraph
The subgraph of directed edges may be accessed by the
ADMG.sub_directed_graph
. Their edges in networkx format can be accessed byADMG.directed_edges
and the corresponding name of the edge type byADMG.directed_edge_name
.
- Directed edges (<-, ->, indicating causal relationship) =
- Bidirected edges (<->, indicating latent confounder) =
networkx.Graph
The subgraph of bidirected edges may be accessed by the
ADMG.sub_bidirected_graph
. Their edges in networkx format can be accessed byADMG.bidirected_edges
and the corresponding name of the edge type byADMG.bidirected_edge_name
.
- Bidirected edges (<->, indicating latent confounder) =
- Undirected edges (–, indicating selection bias) =
networkx.Graph
The subgraph of undirected edges may be accessed by the
ADMG.sub_undirected_graph
. Their edges in networkx format can be accessed byADMG.undirected_edges
and the corresponding name of the edge type byADMG.undirected_edge_name
.
- Undirected edges (–, indicating selection bias) =
By definition, no cycles may exist due to the directed edges. However, beyond that multiple types of edges between the same pairs of nodes are possible.
Examples using pywhy_graphs.ADMG
#
An introduction to Inducing Paths and how to find them
An introduction to causal graphs and how to use them
Drawing graphs and setting their layout for visual comparison