public void ShortestPathTest()
        {
            string fileName = @"Graph\testG2.txt";
            var    g1       = new SparseGraph <double>(7, false);
            var    gr1      = new ReadGraph <double>(g1, fileName);

            g1.Show();
            var path = new ShortestPath <double>(g1, 0);

            Console.WriteLine("BFS: ");
            path.ShowPath(6);
        }
        public void ReadGraphTest()
        {
            string fileName = @"Graph\testG1.txt";

            var g1  = new SparseGraph <double>(13, false);
            var rg1 = new ReadGraph <double>(g1, fileName);

            g1.Show();

            var g2  = new DenseGraph <double>(13, false);
            var rg2 = new ReadGraph <double>(g2, fileName);

            g2.Show();
        }
예제 #3
0
        static void Main(string[] args)
        {
            string fileName = @"Graph\testG1.txt";
            var    g1       = new SparseGraph <double>(8, false);
            var    gr1      = new ReadGraph <double>(g1, fileName);

            g1.Show();

            // test Kruskal
            Console.WriteLine("Test Kruskal: ");
            var kruskalMST = new KruskalMST <double>(g1);
            var mst        = kruskalMST.MSTEdges;

            foreach (var edge in mst)
            {
                Console.WriteLine(edge);
            }
            Console.WriteLine("The MST weight is: " + kruskalMST.MSTWeight);
        }
예제 #4
0
        public void TestPrimMST()
        {
            string fileName = @"Graph\testG1.txt";
            var    g1       = new SparseGraph <double>(8, false);
            var    gr1      = new ReadGraph <double>(g1, fileName);

            g1.Show();

            // test prim
            Console.WriteLine("Test Prim MST: ");
            var primMST = new PrimMST <double>(g1);
            var mst     = primMST.MSTEdges;

            foreach (var edge in mst)
            {
                Console.WriteLine(edge);
            }
            Console.WriteLine("The MST weight is: " + primMST.MSTWeight);
        }
예제 #5
0
        public void TestLazyPrimMST()
        {
            string fileName = @"Graph\testG1.txt";
            var    g1       = new SparseGraph <double>(8, false);
            var    gr1      = new ReadGraph <double>(g1, fileName);

            g1.Show();

            // test lazy prim
            Console.WriteLine("Test Lazy Prim MST: ");
            var pq          = new MinHeap <Edge <double> >();
            var lazyPrimMST = new LazyPrimMST <double>(g1, pq);
            var mst         = lazyPrimMST.MSTEdges;

            foreach (var edge in mst)
            {
                Console.WriteLine(edge);
            }
            Console.WriteLine("The MST weight is: " + lazyPrimMST.MSTWeight);
        }