Skip to main content
๐Ÿ“œ WAYPOINT LESSON

Condensation: Every Digraph Is a DAG

โญโญโญ advancedโณ 35 min read๐Ÿ“ Lesson 150 of 281

Shrink each SCC to one node and the result is acyclic โ€” DP on the condensation inherits every Intermediate DAG technique.

The condensation is a DAG

If the condensation had a cycle, its SCCs would merge into one โ€” so it is acyclic by construction. Consequences:

  • Distinct condensation edges need a SET of (comp[u], comp[v]) pairs.
  • "Can u reach v" now runs on a DAG: longest path, reachability bitsets, path counting โ€” all inherit.
  • Two-step shape: SCC for cycles, then DAG DP for order.

Classic bug: self-loops and duplicate edges vanish in the condensation.