public void BasicTest()
        {
            //Graph with three vertexes
            Graph graph = new Graph(3);

            graph.Add(0, 1, 2);
            graph.Add(1, 2, 1);
            graph.Add(0, 2, 5);

            // Min cost path from vertex (0) to vertex (2)
            int[] result = new int[]{0, 1, 2};

            Assert.That(graph.ShortestPath(0, 2), Is.EqualTo(result));
        }
        public void ForestTest()
        {
            Graph graph = new Graph(6);

            graph.Add(0, 1, 1);
            graph.Add(0, 2, 1);
            graph.Add(1, 2, 1);
            graph.Add(3, 5, 1);
            graph.Add(3, 4, 1);
            graph.Add(4, 5, 1);

            int[] result = new int[0];

            Assert.That(graph.ShortestPath(0, 5), Is.EqualTo(result));
        }
        public void GraphWithBridgeTest()
        {
            Graph graph = new Graph(7);

            graph.Add(0, 1, 4);
            graph.Add(0, 2, 5);
            graph.Add(1, 3, 3);
            graph.Add(2, 3, 1);
            graph.Add(3, 4, 2);
            graph.Add(4, 5, 4);
            graph.Add(4, 6, 3);
            graph.Add(5, 6, 2);

            int[] result = new int[]{0, 2, 3, 4, 5};

            Assert.That(graph.ShortestPath(0, 5), Is.EqualTo(result));
        }
        public void CompleteGraphTest()
        {
            Graph graph = new Graph(5);

            graph.Add(0, 1, 3);
            graph.Add(0, 2, 7);
            graph.Add(0, 3, 9);
            graph.Add(0, 4, 1);
            graph.Add(1, 2, 5);
            graph.Add(1, 3, 5);
            graph.Add(1, 4, 3);
            graph.Add(2, 3, 2);
            graph.Add(2, 4, 9);
            graph.Add(3, 4, 8);

            int[] result = new int[]{0, 1, 3};

            Assert.That(graph.ShortestPath(0, 3), Is.EqualTo(result));
        }
        public void RegularGraphTest()
        {
            Graph graph = new Graph(6);

            graph.Add(0, 1, 2);
            graph.Add(0, 2, 4);
            graph.Add(1, 2, 1);
            graph.Add(2, 3, 5);
            graph.Add(1, 3, 8);
            graph.Add(1, 4, 10);
            graph.Add(3, 4, 2);
            graph.Add(3, 5, 6);
            graph.Add(4, 5, 3);

            int[] result = new int[]{0, 1, 2, 3, 4, 5};

            Assert.That(graph.ShortestPath(0, 5), Is.EqualTo(result));
        }
        public void WeirdGraphTest()
        {
            Graph graph = new Graph(8);

            graph.Add(0, 1, 2);
            graph.Add(1, 3, 1);
            graph.Add(1, 2, 4);
            graph.Add(3, 2, 2);
            graph.Add(2, 4, 2);
            graph.Add(2, 5, 2);
            graph.Add(5, 7, 3);
            graph.Add(5, 6, 5);
            graph.Add(6, 7, 1);

            int[] result = new int[]{6, 7, 5, 2, 3, 1, 0};

            Assert.That(graph.ShortestPath(6, 0), Is.EqualTo(result));
        }
        public void TreeGraphTest()
        {
            Graph graph = new Graph(8);

            graph.Add(0, 1, 1);
            graph.Add(0, 2, 1);
            graph.Add(2, 3, 1);
            graph.Add(2, 4, 1);
            graph.Add(2, 5, 1);
            graph.Add(4, 6, 1);
            graph.Add(4, 7, 1);

            int[] result = new int[]{1, 0, 2, 4, 6};

            Assert.That(graph.ShortestPath(1, 6), Is.EqualTo(result));
        }