public Topological(Digraph g) { DirectedCycle cyclefinder = new DirectedCycle(g); if (!cyclefinder.HasCycle()) { DepthFirstOrder dfs = new DepthFirstOrder(g); Order = dfs.ReversePost();//逆后序排列 } }
public KosarajuSCC(Digraph g) { marked = new bool[g.V]; id = new int[g.V]; DepthFirstOrder order = new DepthFirstOrder(g.Reverse()); foreach (int s in order.ReversePost()) { if (!marked[s]) { Dfs(g, s); Count++; } } }