A topological sort is carried out on a directed graph with no cycles.Such a graph is called a directed, acyclic graph, often abbreviated DAG
A graph with no cycles is called a tree.
Step 1: Find a vertex that has no successors.
Step 2: Delete this vertex from the graph, and insert its label at the beginning of a list.
Steps 1 and 2 are repeated until all the vertices are gone. At this point, the list shows the
vertices arranged in topological order.