def test_remove_vertex(self, rm_edge): """ Ensures a vertex and its corresponding edges are removed. """ vertex_one = Vertex(0) # Create some components vertex_two = Vertex(1) edge_one = Edge(0, vertex_one, vertex_two) g = Graph() # Generate graph and add components g.add_vertex(vertex_one) g.add_vertex(vertex_two) g.add_edge(edge_one) g.remove_vertex(vertex_one) # Remove the vertex assert vertex_one not in g.get_vertices() assert vertex_two in g.get_vertices() assert rm_edge.called_with(edge_one) # Ensure remove edge was called
def test_get_vertices(self): """ Ensures vertices are returned correctly. """ vertex_one = Vertex(0) vertex_two = Vertex(1) g = Graph() g._vertices = [vertex_one, vertex_two] assert g.get_vertices() == [vertex_one, vertex_two]