public static void InternalMain()
        {
            Diagraph g = new Diagraph(@"Graph/testdata/tinyDG.txt");

            Console.Write(g.toString());

            DirectedCycle dc = new DirectedCycle(g);

            Console.WriteLine(dc.hasCycle());
            Console.WriteLine(Graph.PrintFormat(dc.Cycle()));
        }
Ejemplo n.º 2
0
        public Topological(Diagraph G)
        {
            DirectedCycle finder = new DirectedCycle(G);

            if (!finder.hasCycle())
            {
                DepthFirstOrder dfs = new DepthFirstOrder(G);
                order   = dfs.reversePost();
                rankArr = new int[G.V];
                int i = 0;
                foreach (int v in order)
                {
                    rankArr[v] = i++;
                }
            }
        }