A topological sort is a permutation of the vertices of a graph such that an edge implies that appears before in (Skiena 1990, p. 208). Only acyclic digraphs can be topologically sorted. The topological sort of a graph can be computed using TopologicalSort[g] in the Wolfram Language package Combinatorica` .
Topological Sort
Explore with Wolfram|Alpha
References
Skiena, S. "Topological Sorting." §5.4.3 in Implementing Discrete Mathematics: Combinatorics and Graph Theory with Mathematica. Reading, MA: Addison-Wesley, pp. 208-209, 1990.Referenced on Wolfram|Alpha
Topological SortCite this as:
Weisstein, Eric W. "Topological Sort." From MathWorld--A Wolfram Web Resource. https://mathworld.wolfram.com/TopologicalSort.html