Concept Flow - Cycle Detection in Directed Graph
Start DFS at each unvisited node
Mark node as visited and in recursion stack
For each neighbor
If neighbor not visited
→DFS on neighbor
If neighbor in recursion stack
→Cycle detected
Remove node from recursion stack
Repeat for all nodes
No cycle found
We run DFS from each node, track visited nodes and recursion stack to find back edges indicating cycles.
