Detect Cycles in Directed Graphs
Color nodes to find back edges.
Why Cycles Matter
A directed cycle means dependencies loop back on themselves. Spotting one tells you no topological order or valid schedule can exist.
Undirected Is Different
Cycle detection here is about direction. Following edges the wrong way does not count, so undirected tricks do not apply.
All lessons in this course
- Topological Sort with Kahn's Algorithm
- Detect Cycles in Directed Graphs
- Strongly Connected Components
- Bridges & Articulation Points