Exemplo n.º 1
0
        public void testPerf(Graph g)
        {
            long milliseconds;

            Stopwatch stopDij = new Stopwatch();
            stopDij.Start();
            Dijkstra dj = new Dijkstra(g, g.getNodeAt(0));
            stopDij.Stop();
            milliseconds = stopDij.ElapsedMilliseconds;
            Console.WriteLine("Dijkstra : " + milliseconds + " ms");

            Stopwatch stopBell = new Stopwatch();
            stopBell.Start();
            Bellman bm = new Bellman(g, g.getNodeAt(0));
            stopBell.Stop();
            milliseconds = stopBell.ElapsedMilliseconds;
            Console.WriteLine("Bellman : " + milliseconds + " ms");

            Stopwatch stopDFS = new Stopwatch();
            stopDFS.Start();
            DepthFirst dfs = new DepthFirst(g , g.getNodeAt(0));
            stopDFS.Stop();
            milliseconds = stopDFS.ElapsedMilliseconds;
            Console.WriteLine("DFS : " + milliseconds + " ms");

            Stopwatch stopFloyd = new Stopwatch();
            stopFloyd.Start();
            Floyd fl = new Floyd(g);
            stopFloyd.Stop();
            milliseconds = stopFloyd.ElapsedMilliseconds;
            Console.WriteLine("Floyd : " + milliseconds + " ms");
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            /*

            Object[,] graphComponent = new Object[,] {
            {"Paris",    int.MaxValue, 1, int.MaxValue, int.MaxValue, 11, int.MaxValue, int.MaxValue},
            {"Bordeaux", int.MaxValue,  int.MaxValue, 5, int.MaxValue, int.MaxValue, int.MaxValue, int.MaxValue},
            {"Bayonne",  int.MaxValue,  int.MaxValue,  int.MaxValue,  5,  int.MaxValue, int.MaxValue, int.MaxValue},
            {"Pau",      3,   int.MaxValue, int.MaxValue, int.MaxValue, int.MaxValue, int.MaxValue, 3},
            {"Bangkok",  int.MaxValue,  int.MaxValue, int.MaxValue,int.MaxValue, int.MaxValue, 8, 13},
            {"Yangon", int.MaxValue, int.MaxValue, int.MaxValue, int.MaxValue, 3, int.MaxValue, int.MaxValue},
            {"Tarbes", int.MaxValue, int.MaxValue, int.MaxValue, int.MaxValue, int.MaxValue, int.MaxValue , int.MaxValue},
            };
            */

            Object[,] graphComponent = new Object[,] {
             {"Paris",    0, 1, 10, 3, int.MaxValue, int.MaxValue, int.MaxValue},
            {"Bordeaux", 4,   0, 3, 1, int.MaxValue, int.MaxValue, 5},
            {"Pau",      3,   7, 0, 1, int.MaxValue, 10, int.MaxValue},
             {"Bangkok",  52,  4, 1, 0, 8, int.MaxValue, int.MaxValue},
            {"Yangon", int.MaxValue, int.MaxValue, int.MaxValue, 8, int.MaxValue, int.MaxValue, int.MaxValue},
            {"Tarbes", int.MaxValue, 5, int.MaxValue, int.MaxValue, int.MaxValue, 0, int.MaxValue},
            {"Bayonne",  int.MaxValue,  int.MaxValue,  int.MaxValue,  int.MaxValue,  int.MaxValue, int.MaxValue, 0},
            };

            Graph g = new Graph(graphComponent);
            g.display();

            g.displayCurrentMatrix();

            SaveManager sm = new SaveManager();
            sm.saveGraph(g);

            StronglyConnectedComponent scc = new StronglyConnectedComponent();
            scc.displaySCC(g);

            /*
            Actions a = new Actions();
            a.testPerf(g);
            */
            Bellman bm = new Bellman(g, g.getNodeAt(0));
            bm.display();

            Dijkstra dj = new Dijkstra(g, g.getNodeAt(0));
            dj.display();

            /*
             *
            Floyd flo = new Floyd(g);
            flo.display();
             *
            DepthFirst dfs = new DepthFirst(g, g.getNodeAt(0));
            dfs.displayDFSPath();

            TreeDepthFirst tdfs = new TreeDepthFirst(g, g.getNodeAt(0));
            Graph zi = tdfs.getDFSGraph();

            zi.display();
             */
        }