Example #1
0
        static void Main(string[] args)
        {
            connector.ConnectRoutes();
            roadSearch = new RouteCalculator(connector.Nodes);
            Console.WriteLine("Hello and welcome to RoutCity!");
            Console.WriteLine("Here you can find the fastest way too you choosen part of the city.");
            Console.WriteLine("Given the options below make your choise : ");
            Console.WriteLine("Enter 1 : Show all Connections ");
            Console.WriteLine("Enter 2 : Choose your own path ");
            Console.WriteLine("Enter 3 : Exit the program ");

            while (true)
            {
                Console.WriteLine("Make a choise !");
                string userAnswer = Console.ReadLine();
                switch (userAnswer)
                {
                case "1":
                    ShowAllConnections(connector);
                    break;

                case "2":
                    ChoosePath();
                    break;

                case "3":
                    Console.WriteLine("Thanks for visiting and welcome back!");
                    return;

                default:
                    Console.WriteLine("Sorry, you have entered something invalid, try again!");
                    break;
                }
            }
        }
Example #2
0
        public void TestRouteConnectorAnNodeConnectionsWithCalculateRoute()
        {
            testConnector = new RouteConnector();
            testConnector.ConnectRoutes();
            calculator = new RouteCalculator(testConnector.Nodes);
            testVertex = calculator.FindShortestPath(testConnector.Nodes[0], testConnector.Nodes[1], 0);

            Assert.AreEqual(testVertex.VertexName, testConnector.Nodes[1].Name);
            Assert.IsTrue(testVertex.Distance < 10);
            Assert.IsTrue(testVertex.Distance > 0);
            Assert.IsTrue(testConnector.Nodes.Count == 10);
        }
Example #3
0
        public void TestThatEachNodeHasTwoToThreeConnections()
        {
            testConnector = new RouteConnector();
            testConnector.ConnectRoutes();

            for (int i = 0; i < testConnector.Nodes.Count; i++)
            {
                if (testConnector.Nodes[i].Connections.Count <= 1 || testConnector.Nodes[i].Connections.Count > 3)
                {
                    Assert.Fail();
                }
            }
            Assert.Pass();
        }
Example #4
0
        public void TestThatANodeHasAConnection()
        {
            testConnector = new RouteConnector();
            testConnector.ConnectRoutes();

            for (int i = 0; i < testConnector.Nodes.Count; i++)
            {
                if (testConnector.Nodes[i].Connections.Count == 0)
                {
                    Assert.Fail();
                }
            }
            Assert.Pass();
        }
Example #5
0
        public void TestIfANodeHasConnectionToItself()
        {
            testConnector = new RouteConnector();
            testConnector.ConnectRoutes();

            for (int i = 0; i < testConnector.Nodes.Count; i++)
            {
                for (int x = 0; x < testConnector.Nodes[i].Connections.Count; x++)
                {
                    if (testConnector.Nodes[i].Connections[x].NodeName == testConnector.Nodes[i].Connections[x].ConnectedNode)
                    {
                        Assert.Fail();
                    }
                }
            }
            Assert.Pass();
        }
Example #6
0
        public void A()
        {
            for (int i = 0; i < 20000; i++)
            {
                RouteConnector a = new RouteConnector();

                a.ConnectRoutes();
                for (int x = 0; x < a.Nodes.Count; x++)
                {
                    if (a.Nodes[x].Connections.Count == 1)
                    {
                        Console.WriteLine(i);
                        Assert.Fail();
                    }
                }
            }
            Assert.Pass();
        }
Example #7
0
        public void B()
        {
            Random one = new Random();
            Random two = new Random();

            for (int i = 0; i < 10000000; i++)
            {
                RouteConnector a = new RouteConnector();
                a.ConnectRoutes();
                RouteCalculator b = new RouteCalculator(a.Nodes);
                int             s = one.Next(0, a.Nodes.Count);
                int             u = two.Next(0, a.Nodes.Count);
                if (s != u)
                {
                    b.FindShortestPath(a.Nodes[s], a.Nodes[u], 0);
                }
            }
            Assert.Pass();
        }