Ejemplo n.º 1
0
        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++; }
        }
Ejemplo n.º 2
0
        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++;
                }
            }
        }