0PricingLogin
Competitive Programming Academy · Lesson

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

  1. Topological Sort with Kahn's Algorithm
  2. Detect Cycles in Directed Graphs
  3. Strongly Connected Components
  4. Bridges & Articulation Points
← Back to Competitive Programming Academy