graphical_models.classes.dags.dag.DAG.topological_sort

DAG.topological_sort() List[Hashable][source]

Return a topological sort of the nodes in the graph.

Returns

A topological sort of the nodes in a graph.

Return type

List[Node]

Examples

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