Example #1
0
        public static int Execute(CountRoutesFilter filter)
        {
            if (filter.maxCost == int.MaxValue && filter.maxStops == int.MaxValue)
            {
                throw new Exception("Please, select a max value or max cost or i'll be in a overflow :(");
            }

            using (IRouteSearchAlgorithm alg = AlgorithmFactory.RouteSearchAlgorithm(filter.graph))
            {
                alg.SetMaxStops(filter.maxStops);
                alg.SetMaxCost(filter.maxCost);
                alg.SetExactlyStops(filter.exactlyStops);

                return(alg.NumberOfRoutes(filter.start, filter.end));
            }
        }
        public string CountRoutesExactlyStops(Node start, Node end, int exactlyStops)
        {
            var filter = CountRoutesFilter.ExactlyStops(this._graph, start, end, exactlyStops);

            return(GetCountRoutes.Execute(filter).ToString());
        }
        public string CountRoutesMaxCost(Node start, Node end, int maxCost)
        {
            var filter = CountRoutesFilter.MaxCost(this._graph, start, end, maxCost);

            return(GetCountRoutes.Execute(filter).ToString());
        }