causaldag.classes.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

>>> import causaldag as cd
>>> g = cd.DAG(arcs={(1, 2), (2, 3)})
>>> g.topological_sort
[1, 2, 3]