예제 #1
0
        public Topological(Digraph g)
        {
            var cycleFinder = new DirectedCycle(g);

            if (!cycleFinder.HasCycle())
            {
                var dfs = new DepthFirstOrder(g);
                _order = dfs.ReversePost();
            }
        }
예제 #2
0
        public KosarajuSharirSCC(Digraph g)
        {
            _marked = new List <bool>(new bool[g.V]);
            _id     = new List <int>(new int[g.V]);
            var order = new DepthFirstOrder(g.Reverse());

            foreach (var s in order.ReversePost())
            {
                if (!_marked[s])
                {
                    DFS(g, s);
                    Count++;
                }
            }
        }