예제 #1
0
        public void GetPath_ExistPath_Price()
        {
            BellmanFord bellmanFord = new BellmanFord("TestPath.txt");

            bellmanFord.GetPath("St. Petersburg", "Moscow");

            int price = 10;

            Assert.AreEqual(price, bellmanFord.totalPricePath);
        }
예제 #2
0
        // Get the shortest solution according to the specified route settings
        public List <Edge> GetSolution()
        {
            try
            {
                var shortestRoute = Settings.ShortestRouteSetting;
                if (shortestRoute == ShortestRoute.BellmanFord)
                {
                    var bellmanFord = new BellmanFord(this);
                    return(bellmanFord.GetPath(RootCube, IsSolved()));
                }

                var dijkstra = new Dijkstra(this);
                dijkstra.Execute(RootCube);
                return(dijkstra.GetPath(SolvedNode));
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }
예제 #3
0
        public void GetPath_ExistPath_Path()
        {
            var bellmanFord = new BellmanFord("TestPaths.txt");

            bellmanFord.GetPath("Vladivostok", "Moscow");

            var coasts = new List <int>
            {
                13,
                35
            };

            var citiesName = new List <string>
            {
                "Vladivostok",
                "Moscow"
            };

            var expected = (citiesName, coasts);

            var path = (bellmanFord.pathByCities, bellmanFord.pathByPrice);

            Assert.IsTrue(AreEqual(path, expected));
        }
예제 #4
0
        public void GetPath_BadInputData_Exception()
        {
            BellmanFord bellmanFord = new BellmanFord("TestPath.txt");

            Assert.Throws <Exception>(() => bellmanFord.GetPath("Abooba", "Khabarovsk"));
        }
예제 #5
0
        public void GetPath_BadFileData_Exception()
        {
            BellmanFord bellmanFord = new BellmanFord("IncorrectInput.txt");

            Assert.Throws <Exception>(() => bellmanFord.GetPath("Khabarovsk", "St. Petersburg"));
        }
예제 #6
0
        public void GetPath_NoExistPath_Exception()
        {
            BellmanFord bellmanFord = new BellmanFord("TestPath.txt");

            Assert.Throws <Exception>(() => bellmanFord.GetPath("Khabarovsk", "St. Petersburg"));
        }