Graph Theory37 sections · 1633 units
Open in Course

Building the Condensation Graph

(Implementation)

After finding all SCCs using Kosaraju or Tarjan, build the condensation graph:

for each original edge (u, v)
    scc_u := component[u]
    scc_v := component[v]
    if scc_u != scc_v then
        add edge scc_u -> scc_v to condensation

Use a set (or mark duplicates) to avoid adding the same condensation edge multiple times.

The condensation graph is a DAG. You can run DP on it for problems like "longest path through SCCs" or "minimum SCCs to remove."