topologicalSort

fun <TNode> topologicalSort(roots: List<TNode>, successors: (TNode) -> List<TNode>, skip: (TNode) -> Boolean = { false }): List<TNode>?

A topological sort, which processes an acyclic graph and returns a topologically sorted list of its nodes, in which each node precedes any appearance of its successors. Returns null if the input graph is found to have a cycle.