예제 #1
0
        public void Get_Vertices_Test()
        {
            //arrange
            myGraph <string> testGraph = new myGraph <string>();
            var bob   = testGraph.AddVertex("Bob");
            var carol = testGraph.AddVertex("Carol");

            //Arrange
            var actual = testGraph.GetVertices();

            //Assert
            Assert.Equal(bob, actual[0]);
        }
예제 #2
0
        public void Add_Edge_Works()
        {
            //arrange
            myGraph <string> testGraph = new myGraph <string>();
            var bob   = testGraph.AddVertex("Bob");
            var carol = testGraph.AddVertex("Carol");

            //Arrange
            testGraph.AddEdge(bob, carol, 13);
            var actual = bob.Neighbors[0].Weight;

            //Assert
            Assert.Equal(13, actual);
        }
예제 #3
0
        public void Breadth_First_Test_A()
        {
            //arrange
            myGraph <string> testGraph = new myGraph <string>();
            var bob   = testGraph.AddVertex("Bob");
            var carol = testGraph.AddVertex("Carol");
            var diana = testGraph.AddVertex("Diana");

            testGraph.AddEdge(bob, carol, 13);
            testGraph.AddEdge(bob, diana, 9);

            //act
            var actual = testGraph.BreadthFirst(bob);

            //Assert
            Assert.Equal(testGraph.Size(), actual.Count());
        }
예제 #4
0
        public void Get_Neighbors_Test()
        {
            //arrange
            myGraph <string> testGraph = new myGraph <string>();
            var bob   = testGraph.AddVertex("Bob");
            var carol = testGraph.AddVertex("Carol");
            var diana = testGraph.AddVertex("Diana");

            testGraph.AddEdge(bob, carol, 13);
            testGraph.AddEdge(bob, diana, 9);

            //act
            var actual = testGraph.GetNeighbors(bob);

            //Assert
            Assert.Equal(diana, actual[1]);
        }
예제 #5
0
        //[InlineData(new[] { "Metroville", "Pandora," }, new TripResult(true, 82))]
        public void Airplane_Trip_Test()
        {
            //arrange
            myGraph <string> testFlight = new myGraph <string>();
            var pandora      = testFlight.AddVertex("Pandora");
            var metroville   = testFlight.AddVertex("Metroville");
            var narnia       = testFlight.AddVertex("Narnia");
            var arendelle    = testFlight.AddVertex("Arendelle");
            var naboo        = testFlight.AddVertex("Naboo");
            var monstropolis = testFlight.AddVertex("Monstropolis");

            testFlight.AddEdge(pandora, metroville, 82);
            testFlight.AddEdge(pandora, arendelle, 150);
            testFlight.AddEdge(narnia, metroville, 37);
            testFlight.AddEdge(narnia, naboo, 250);

            testFlight.AddEdge(narnia, monstropolis, 73);
            testFlight.AddEdge(naboo, metroville, 26);
            testFlight.AddEdge(arendelle, metroville, 99);
            testFlight.AddEdge(arendelle, monstropolis, 42);

            testFlight.AddEdge(monstropolis, metroville, 105);
            var expected = new TripResult(true, 82);

            string[] stops = new string[] { "Metroville", "Pandora," };

            //act
            TripResult actual = GraphChallenges.GraphChallenges.PlaneTrip(testFlight, stops);

            //Assert
            Assert.Equal(expected, actual);
        }
예제 #6
0
        public void Size_Method_Works()
        {
            //arrange
            myGraph <string> testGraph = new myGraph <string>();

            testGraph.AddVertex("Bob");

            //act
            var actual = testGraph.Size();

            //Assert
            Assert.Equal(1, actual);
        }
예제 #7
0
        public void Depth_First_Test()
        {
            //arrange
            myGraph <string> testGraph = new myGraph <string>();
            var bob   = testGraph.AddVertex("Bob");
            var carol = testGraph.AddVertex("Carol");
            var diana = testGraph.AddVertex("Diana");
            var bill  = testGraph.AddVertex("Bill");

            testGraph.AddEdge(bob, carol, 13);
            testGraph.AddEdge(bob, diana, 9);
            testGraph.AddEdge(diana, bill, 23);
            Vertex <string>[] expected = new Vertex <string>[] { bob, diana, bill, carol };


            //act
            var actual = testGraph.DepthFirst();


            //Assert
            Assert.Equal(expected, actual);
        }
예제 #8
0
        public void Breadth_First_Test_B()
        {
            //arrange
            myGraph <string> testGraph = new myGraph <string>();
            var bob   = testGraph.AddVertex("Bob");
            var carol = testGraph.AddVertex("Carol");
            var diana = testGraph.AddVertex("Diana");
            var bill  = testGraph.AddVertex("Bill");

            testGraph.AddEdge(bob, carol, 13);
            testGraph.AddEdge(bob, diana, 9);
            testGraph.AddEdge(diana, bill, 23);
            string expected = "Bob, Carol, Diana, Bill";


            //act
            var actual = testGraph.BreadthFirstHandler(bob);


            //Assert
            Assert.Equal(expected, actual);
        }
예제 #9
0
        public void Add_Vertex_Works()
        {
            //arrange
            myGraph <string> testGraph = new myGraph <string>();


            //act
            var actual   = testGraph.AddVertex("Bob");
            var expected = testGraph.Vertices[0];



            //Assert
            Assert.Equal(expected, actual);
        }