NetworkX

Previous topic

networkx.topological_sort

Next topic

networkx.is_directed_acyclic_graph

networkx.topological_sort_recursive

topological_sort_recursive(G, nbunch=None)

Return a list of nodes 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.

Parameters:

G : NetworkX digraph

nbunch : container of nodes (optional)

Explore graph in specified order given in nbunch

Notes

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

This is a recursive version of topological sort.