def test_remove_unexisting_edge_with_unexisting_vertex(self): """Tests the remove_edge method in a graph between an existing vertex and a non-existing one. """ graph = Graph(graph = { 'A' : [] }) self.assertFalse(graph.has_edge('A', 'C'), 'There cannot be edge between A and C.') graph.remove_edge('A', 'C') self.assertFalse(graph.has_edge('A', 'C'), 'Nothing changed.')
def test_remove_unexisting_edge(self): """Tests the remove_edge method in a graph without edge between two vertex """ graph = Graph(graph = { 'A' : [], 'B' : [] }) self.assertFalse(graph.has_edge('A', 'B'), 'There is no edge between A and B.') graph.remove_edge('A', 'B') self.assertFalse(graph.has_edge('A', 'B'), 'Nothing changed.')
def test_remove_edge_undirected(self): """Tests the remove_edge method in an undirected graph. """ graph = Graph(graph = { 'A' : ['B'], 'B' : ['A'] }) self.assertTrue(graph.has_edge('A', 'B'), 'There is an edge between A and B.') graph.remove_edge('A', 'B') self.assertFalse(graph.has_edge('A', 'B'), 'No more edge between A and B.')
def test_remove_edge_directed(self): """Tests the remove_edge method in a directed graph. """ graph = Graph(graph = { 'A' : ['B'], 'B' : ['A'] }, is_directed = True) self.assertTrue(graph.has_edge('A', 'B'), 'There is an edge from A to B.') self.assertTrue(graph.has_edge('B', 'A'), 'There is an edge from B to A.') graph.remove_edge('A', 'B') self.assertFalse(graph.has_edge('A', 'B'), 'There is no more edge from A to B.') self.assertTrue(graph.has_edge('B', 'A'), 'But there is still an edge from B to A.')