causal_networkx.io.to_numpy#
- causal_networkx.io.to_numpy(causal_graph)[source]#
Convert causal graph to a numpy adjacency array.
- Parameters:
causal_graph : instance of
DAG
The causal graph.
- Returns:
numpy_graph :
np.ndarray
of shape (n_nodes, n_nodes)The numpy array that represents the graph. The values representing edges are mapped according to a pre-defined set of values. See Notes.
Notes
The adjacency matrix is defined where the ijth entry of
numpy_graph
has a non-zero entry if there is an edge from i to j. The ijth entry is symmetric with the jith entry if the edge is ‘undirected’, or ‘bidirected’. Then specific edges are mapped to the following values:directed edge (->): 1
undirected edge (–): 2
bidirected edge (<->): 3
circle endpoint (-o): 4
Circle endpoints can be symmetric, but they can also contain a tail, or a directed edge at the other end.