public void AdjacencyList_RemoveVertex_RemovesVerticesWithEdges() { int vertex1 = 10; int vertex2 = 20; int vertex3 = 30; int vertex4 = 40; string edge1 = "20-30"; string edge2 = "30-40"; AdjacencyList <int, string> adjacencyList = new AdjacencyList <int, string>(); adjacencyList.AddVertex(vertex1); adjacencyList.AddVertex(vertex2); adjacencyList.AddVertex(vertex3); adjacencyList.AddVertex(vertex4); adjacencyList.AddEdge(vertex2, vertex3, edge1); adjacencyList.AddEdge(vertex3, vertex4, edge2); Assert.Equal(4, adjacencyList.NumVertices); Assert.Equal(edge1, adjacencyList.FindEdge(vertex2, vertex3)); Assert.Equal(edge2, adjacencyList.FindEdge(vertex3, vertex4)); adjacencyList.RemoveVertex(vertex2); Assert.Equal(3, adjacencyList.NumVertices); Assert.Equal(edge2, adjacencyList.FindEdge(vertex3, vertex4)); }
public void AdjacencyList_FindEdge_LooksForEdgesByVertices() { int vertex1 = 10; int vertex2 = 20; int vertex3 = 30; int vertex4 = 40; string edge1 = "20-30"; string edge2 = "30-40"; AdjacencyList <int, string> adjacencyList = new AdjacencyList <int, string>(); adjacencyList.AddVertex(vertex1); adjacencyList.AddVertex(vertex2); adjacencyList.AddVertex(vertex3); adjacencyList.AddVertex(vertex4); adjacencyList.AddEdge(vertex2, vertex3, edge1); adjacencyList.AddEdge(vertex3, vertex4, edge2); Assert.Equal(edge1, adjacencyList.FindEdge(vertex2, vertex3)); Assert.Equal(edge2, adjacencyList.FindEdge(vertex3, vertex4)); }