public void GetPath_ExistPath_Price()
        {
            BellmanFord bellmanFord = new BellmanFord("TestPath.txt");

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

            int price = 10;

            Assert.AreEqual(price, bellmanFord.totalPricePath);
        }
Esempio n. 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);
            }
        }
        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));
        }
        public void GetPath_BadInputData_Exception()
        {
            BellmanFord bellmanFord = new BellmanFord("TestPath.txt");

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

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

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