Exemplo n.º 1
0
        private int count;     //强连通分量的数量
        public KosarajuSCC(Digraph G)
        {
            marked = new bool[G.VNumber()];
            id     = new int[G.VNumber()];
            //第一次深度优先,得到反向有向图顶点的逆后序排列
            DepthFirstOrder order = new DepthFirstOrder(G.Reverse());

            foreach (int s in order.ReversePost())
            {
                if (!marked[s])
                {
                    Dfs(G, s);//第二次深度优先搜索,得到有向图的强连通分量
                    count++;
                }
            }
        }
Exemplo n.º 2
0
 public DirectedDFS(Digraph G, int s)
 {
     marked = new bool[G.VNumber()];
     Dfs(G, s);
 }