A Directed Acyclic Graph (DAG) is a directed graph with no cycles. "Directed" means edges have a direction ( is not the same as ). "Acyclic" means you can never follow edges and return to where you started.
Topological sort only works on DAGs. If your graph has a cycle like , there is no valid ordering. must come before , before , and before , which is a contradiction. Detecting whether a graph is a DAG is part of the topological sort process. If the algorithm cannot order all nodes, you know a cycle exists.