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]); }
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); }
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()); }
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]); }
//[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); }
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); }
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); }
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); }
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); }