Directed Graph Cycle Detection
visited tracks globally discovered vertices.
inStack tracks the current DFS path.
An edge to an in-stack vertex indicates a directed cycle.
Time complexity: O(V+E).
Kahn's topological-sort approach can also detect directed cycles.