Пример #1
0
    def test_remove_connected_vertex(self):
        """Tests the remove_vertex method for a connected vertex.
        """
        data = { 'A' : ['B'], 'B' : ['A'] }
        graph = Graph(graph=data)

        self.assertTrue('B' in graph.connected_vertex('A'), 'There is an edge between A and B.')
        self.assertTrue('A' in graph.connected_vertex('B'), 'There is an edge between A and B.')

        graph.remove_vertex('A')

        self.assertFalse('A' in graph.connected_vertex('B'), 'No more edge between A and B.')
Пример #2
0
    def test_remove_isolated_vertex(self):
        """Tests the remove_vertex method for an isolated vertex.
        """
        data = { 'A' : [], 'B' : [] }
        graph = Graph(graph=data)

        self.assertTrue(graph.contains_vertex('A'), 'A is a vertex of the graph.')
        self.assertTrue(graph.contains_vertex('B'), 'B is a vertex of the graph.')

        graph.remove_vertex('A')

        self.assertFalse(graph.contains_vertex('A'), 'The graph does not contain a vertex A.')
        self.assertTrue(graph.contains_vertex('B'), 'The graph contains a vertex B.')