示例#1
0
        public Topological(EdgeWeightedDigraph graph)
        {
            var finder = new EdgeWeightedDirectedCycle(graph);

            if (!finder.HasCycle())
            {
                DepthFirstOrder dfs = new DepthFirstOrder(graph);
                order = dfs.ReversePost();
            }
        }
示例#2
0
        public Topological(Digraph digraph)
        {
            var cycleFinder = new DirectedCycle(digraph);

            if (!cycleFinder.HasCycle())
            {
                var dfs = new DepthFirstOrder(digraph);
                order = dfs.ReversePost();
            }
        }
        public TopologicalChecker(EdgeWeightedDigraph graph)
        {
            EdgeWeightedCycleChecker checker = EdgeWeightedCycleChecker.Create(graph);

            if (!checker.HasCycle)
            {
                DepthFirstOrder dfs = new DepthFirstOrder(graph);

                this.Order = dfs.ReversePost();
            }
        }
        private KosarajuSharirSCC(Digraph digraph)
        {
            DepthFirstOrder dfs = new DepthFirstOrder(digraph.Reverse());

            this._visited = new Boolean[digraph.VerticesCount];
            this._ids     = new Int32[digraph.VerticesCount];

            foreach (Int32 vertice in dfs.ReversePost())
            {
                if (!this._visited[vertice])
                {
                    this.DFS(digraph, vertice);

                    this.Count++;
                }
            }
        }
        private TopologicalChecker(Digraph digraph)
        {
            CycleChecker checker = CycleChecker.Create(digraph);

            if (!checker.HasCycle)
            {
                DepthFirstOrder dfs = new DepthFirstOrder(digraph);

                this.Order = dfs.ReversePost();

                this._rank = new Int32[digraph.VerticesCount];

                Int32 i = 0;

                foreach (Int32 v in this.Order)
                {
                    this._rank[v] = i++;
                }
            }
        }