causal_networkx.io.load_from_numpy#

causal_networkx.io.load_from_numpy(arr, type='dag')[source]#

Load causal graph from a numpy array.

# TODO: add sparse support.

Parameters:

arr : np.ndarray of shape (n_nodes, n_nodes)

A numpy array specifying the connections between nodes, where the ijth component specifies the edge from i to j.

type : str, optional

The type of causal graph, by default ‘dag’. Must be one of ('dag', ``cpdag, admg, pag)``. For mixed-edge graphs, the arr specified will have specific values mapped to specific edges.

Returns:

G : instance of DAG | CPDAG

An instance of a causal graph.

Notes

Numpy support for ADMGs are not supported yet, as nodes can have two edges between any two nodes (i.e. a directed edge and a bidirected edge).