Course A requires course B. Task X must finish before task Y. These are dependencies, and dependencies form directed acyclic graphs. If there's a cycle, no valid ordering exists.
Topological sort gives you an order where every edge points forward. Build systems use it. Package managers use it. Compilers use it.
I'll show you how to detect cycles, construct topological orders with DFS or BFS (Kahn's algorithm), and apply this to longest paths and DP on DAGs.