graphical_models.classes.dags.dag.DAG.to_dataframe

DAG.to_dataframe(node_list=None)[source]

Turn this DAG into a dataframe, where the indices and columns are node names and a nonzero entry indicates the presence of an edge.

Parameters

node_list – Order to use when creating the dataframe. If None, uses a sorted order.

Returns

The graph as a DataFrame.

Return type

pandas.DataFrame

Examples

>>> from graphical_models import DAG
>>> d = DAG(arcs={(0, 1)})
>>> d.to_dataframe()
   0  1
0  0  1
1  0  0
>>> d.to_dataframe(node_list=[1, 0])
   1  0
1  0  0
0  1  0