Ejemplo n.º 1
0
 static void QuestionsOnetoFive(RouteGraph routeGraph)
 {
     DisplaRouteDistance(routeGraph.TryFindRoute("A", "B", "C"));
     DisplaRouteDistance(routeGraph.TryFindRoute("A", "D"));
     DisplaRouteDistance(routeGraph.TryFindRoute("A", "D", "C"));
     DisplaRouteDistance(routeGraph.TryFindRoute("A", "E", "B", "C", "D"));
     DisplaRouteDistance(routeGraph.TryFindRoute("A", "E", "D"));
 }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            var routeGraph = new RouteGraph(Route.Parse("AB5, BC4, CD8, DC8, DE6, AD5, CE2, EB3, AE7"));

            QuestionsOnetoFive(routeGraph);
            QuestionSix(routeGraph);
            QuestionSeven(routeGraph);
            QuestionEightAndNine(routeGraph);
            QuestionTen(routeGraph);

            Console.ReadLine();
        }
Ejemplo n.º 3
0
        static void QuestionTen(RouteGraph routeGraph)
        {
            Func <ExtendedRoute, TraverseType> predicate = (ExtendedRoute er) =>
            {
                if (er.Distance < 30)
                {
                    if (er.EndsWith("C"))
                    {
                        return(TraverseType.ReturnAndContinue);
                    }

                    return(TraverseType.Continue);
                }

                return(TraverseType.Stop);
            };

            Console.WriteLine(routeGraph.Traverse("C", predicate).Count);
        }
Ejemplo n.º 4
0
        static void QuestionSeven(RouteGraph routeGraph)
        {
            Func <ExtendedRoute, TraverseType> predicate = (ExtendedRoute er) =>
            {
                if (er.Stops < 4)
                {
                    return(TraverseType.Continue);
                }

                if (er.Stops == 4 && er.EndsWith("C"))
                {
                    return(TraverseType.Return);
                }

                return(TraverseType.Stop);
            };

            Console.WriteLine(routeGraph.Traverse("A", predicate).Count);
        }
Ejemplo n.º 5
0
 static void QuestionEightAndNine(RouteGraph routeGraph)
 {
     Console.WriteLine(routeGraph.ShortestRoute("A", "C").Distance);
     Console.WriteLine(routeGraph.ShortestRoute("B", "B").Distance);
 }