NetworkX

Previous topic

networkx.kosaraju_strongly_connected_components

Next topic

networkx.topological_sort_recursive

Quick search

networkx.topological_sort

topological_sort(G)

Return a list of nodes of the digraph G in topological sort order.

A topological sort is a nonunique permutation of the nodes such that an edge from u to v implies that u appears before v in the topological sort order.

If G is not a directed acyclic graph no topological sort exists and the Python keyword None is returned.

This algorithm is based on a description and proof at http://www2.toki.or.id/book/AlgDesignManual/book/book2/node70.htm

See also is_directed_acyclic_graph()