Exemplo n.º 1
0
        public void RunCycle(string path)
        {
            Digraph       G = new Digraph(path);
            DirectedCycle c = new DirectedCycle(G);

            if (c.HasCycle())
            {
                Console.WriteLine(string.Join("->", c.Cycle()));
            }
            else
            {
                Console.WriteLine("No cycle");
            }
        }
Exemplo n.º 2
0
        public Topological(Digraph G)
        {
            DirectedCycle cycle = new DirectedCycle(G);

            if (!cycle.HasCycle())
            {
                DepthFirstOrder dfo = new DepthFirstOrder(G);
                _order = dfo.ReversePost();
            }
            else
            {
                Console.WriteLine(string.Join(",", cycle.Cycle()));
            }
        }