private Chapter1.Stack <int> Init(IDiGraph G) { DirectedCycle cyclefinder = new DirectedCycle(G); if (!cyclefinder.HasCycle()) { DepthFirstOrder dfs = new DepthFirstOrder(G); return(dfs.ReversePost); } return(null); }
public KosarajuSCC(IDiGraph G) { this.G = 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++; } } }