public DirectedCycles(DiGraph G) { var V = G.V(); marked = new bool[V]; edgeTo = new int[V]; onStack = new bool[V]; }
public DepthFirstPostOrder(DiGraph G) { var V = G.V(); marked = new bool[V]; reversePostOrder = new StackLinkedList <int>(); for (var v = 0; v < V; ++v) { if (marked[v]) { continue; } dfs(G, v); } }
public StronglyConnectedComponents(DiGraph G) { count = 0; var V = G.V(); marked = new bool[V]; id = new int[V]; var ts = new DepthFirstPostOrder(G.reverse()); foreach (var v in ts.PostOrder()) { if (!marked[v]) { dfs(G, v); count++; } } }