Esempio n. 1
0
        public Topological(Digraph g)
        {
            DirectedCycle cyclefinder = new DirectedCycle(g);

            if (!cyclefinder.HasCycle())
            {
                DepthFirstOrder dfs = new DepthFirstOrder(g);
                Order = dfs.ReversePost();//逆后序排列
            }
        }
Esempio n. 2
0
        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++;
                }
            }
        }