コード例 #1
0
ファイル: GraphFabicTest.cs プロジェクト: zoorinz/CES_TL
        public void TestMethod1()
        {
            IList <City> cities = new List <City>();
            IList <Edge> edges  = new List <Edge>();

            for (int i = 0; i < 4; i++)
            {
                City city = new City(i.ToString());
                city.ID = i;
                cities.Add(city);
            }

            Company      company      = new Company("company");
            IList <Type> allowedTypes = new List <Type>();

            allowedTypes.Add(new Type("type"));
            edges.Add(new Edge(3.0f, 3.0f, 3.0f, company, cities[0], cities[1], allowedTypes));
            edges.Add(new Edge(4.0f, 4.0f, 4.0f, company, cities[1], cities[2], allowedTypes));
            edges.Add(new Edge(2.0f, 2.0f, 2.0f, company, cities[2], cities[3], allowedTypes));
            edges.Add(new Edge(1.0f, 1.0f, 1.0f, company, cities[1], cities[3], allowedTypes));
            var parcel = new Parcel(new City(""), new City(""), new Dimension(1, 1, 1),
                                    new User("", ""), new User("", ""), new List <Type>());
            var graph = GraphFabric.CreateGraphPrice(cities, edges, "description", parcel);
            int j     = 3 + 3;
        }
コード例 #2
0
        public SearchResultDTO ClickCalculate(Parcel parcel, City source, City destination)
        {
            List <Edge> edges;
            List <City> cities;

            cities = MappingService.GetCities();
            edges  = MappingService.GetEdges(cities);    //context.GetAllEdges();

            Graph <City, string> graphPrice     = GraphFabric.CreateGraphPrice(cities, edges, "priceCost", parcel);
            Graph <City, string> graphTime      = GraphFabric.CreateGraphTime(cities, edges, "timeCost");
            Graph <City, string> graphPriceTime = GraphFabric.CreateGraphTime(cities, edges, "price times cost");

            RouteCalculatorService routeCalcPrice = new RouteCalculatorService(graphPrice);
            ShortestPathResult     resultPrice    = routeCalcPrice.CalculateShortestPath(source, destination);
            List <City>            pathPrice      = routeCalcPrice.GetCityPath(resultPrice);

            RouteCalculatorService routeCalcTime = new RouteCalculatorService(graphTime);
            ShortestPathResult     resultTime    = routeCalcPrice.CalculateShortestPath(source, destination);
            List <City>            pathTime      = routeCalcTime.GetCityPath(resultTime);

            RouteCalculatorService routePriceTime  = new RouteCalculatorService(graphPriceTime);
            ShortestPathResult     resultPriceTime = routeCalcPrice.CalculateShortestPath(source, destination);
            List <City>            pathPriceTime   = routeCalcTime.GetCityPath(resultPriceTime);

            this.SaveParcel(parcel);

            var cPath = new PathDTO()
            {
                Cities   = ReturnCityDtos(pathPrice),
                Duration = 42,
                Price    = resultPrice.Distance
            };

            var fPath = new PathDTO()
            {
                Cities   = ReturnCityDtos(pathTime),
                Duration = resultTime.Distance,
                Price    = 42
            };

            var bPath = new PathDTO()
            {
                Cities   = ReturnCityDtos(pathPriceTime),
                Duration = resultPriceTime.Distance,
                Price    = 42
            };

            return(new SearchResultDTO
            {
                Cheapest = cPath,
                Fastest = fPath,
                Best = bPath
            });
        }