def test_del_vertex(self): d = DirectedGraph({1: [2, 3], 2: [4], 3: [4]}) self.assertEqual(d.get_outdegree(1), 2) self.assertEqual(d.get_indegree(4), 2) self.assertEqual(len(d), 4) self.assertTrue(2 in d) d.del_vertex(2) self.assertEqual(d.get_outdegree(1), 1) self.assertEqual(d.get_indegree(4), 1) self.assertEqual(len(d), 3) self.assertFalse(2 in d)
def test_del_vertex(): graph = DirectedGraph({1: [2, 3], 2: [4], 3: [4]}) assert graph.get_outdegree(1) == 2 assert graph.get_indegree(4) == 2 assert len(graph) == 4 assert 2 in graph graph.del_vertex(2) assert graph.get_outdegree(1) == 1 assert graph.get_indegree(4) == 1 assert len(graph) == 3 assert 2 not in graph