Concept Flow - Cycle detection in graphs
Start at a node
Mark node as visited
Explore neighbors
Is neighbor unvisited?
Yes→Recurse on neighbor
Detect cycle if neighbor is in recursion stack
Backtrack
Repeat for all nodes
Cycle found?
Yes→Report cycle
No
No cycle in graph
Start from each node, mark it visited, explore neighbors recursively, detect cycle if a neighbor is already in the current recursion path.