internal static int bdfs(BState s) { BTrans t; BScc c; BScc scc = new BScc(); scc.bstate = s; scc.rank = rank; scc.theta = rank++; scc.nxt = scc_stack; scc_stack = scc; s.incoming = 1; for (t = s.trans.nxt; t != s.trans; t = t.nxt) { if (t.to.incoming == 0) { int result = bdfs(t.to); scc.theta = Math.Min(scc.theta, result); } else { for (c = scc_stack.nxt; c != null; c = c.nxt) if (c.bstate == t.to) { scc.theta = Math.Min(scc.theta, c.rank); break; } } } if (scc.rank == scc.theta) { if (scc_stack == scc) { /* s is alone in a scc */ s.incoming = -1; for (t = s.trans.nxt; t != s.trans; t = t.nxt) if (t.to == s) s.incoming = 1; } scc_stack = scc.nxt; } return scc.theta; }
internal static void simplify_bscc() { BState s; rank = 1; scc_stack = null; if (bstates == bstates.nxt) return; for (s = bstates.nxt; s != bstates; s = s.nxt) s.incoming = 0; /* state color = white */ bdfs(bstates.prv); for (s = bstates.nxt; s != bstates; s = s.nxt) if (s.incoming == 0) remove_bstate(s, null); }