if (dag.containCycles()) throw new IllegalStateException("DAG with cycles");
if (dag.containCycles()) throw new IllegalStateException("DAG with cycles");
if (dag.containCycles()) throw new IllegalStateException("DAG with cycles");
if (dag.containCycles()) throw new IllegalStateException("DAG with cycles");