private bool[] marked; // reached vertices #endregion Fields #region Constructors 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++; } }
private int count; // number of strong components 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++; } } }
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++; } } }