graphical_models.classes.dags.dag.DAG.to_amat

DAG.to_amat(node_list=None) -> (numpy.ndarray, <class 'list'>)[source]

Return an adjacency matrix for this DAG.

Parameters

node_list – List indexing the rows/columns of the matrix.

See also

from_amat

Return type

(amat, node_list)

Example

>>> from graphical_models import DAG
>>> g = DAG(arcs={(1, 2), (1, 3), (2, 3)})
>>> g.to_amat()[0]
array([[0, 1, 1],
       [0, 0, 1],
       [0, 0, 0]])
>>> g.to_amat()[1]
[1, 2, 3]