In the Directed Acyclic Graph, the Topological sort is a way of the linear ordering of vertices in such a way that for every directed edge (x, y), vertex x will come before y in the ordering.
Topological sorting is possible if and only if the graph has no directed cycles i.e., it is a Directed Acyclic Graph (DAG). There may exist multiple topological orderings for a given DAG. The ordering of the nodes is called topological ordering.
It has been seen that graph having a directed cycle is the only restriction for having a topological sort.