A topological sort of a directed acyclic graph is an ordering of the vertices so that if uv is an edge of the graph, then u comes before v in the ordering. A typical application is project planning, where each edge uv represents a constraint that task u must be completed before task v starts.
Topological sort can be solved in O(V+E) time using DepthFirstSearch.
PineWiki