Exemplo n.º 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);
        }
Exemplo 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);
            }
        }
Exemplo n.º 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));
        }
Exemplo n.º 4
0
        public void GetPath_BadInputData_Exception()
        {
            BellmanFord bellmanFord = new BellmanFord("TestPath.txt");

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

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

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