Exemple #1
0
 def test_add_vertex(self):
     d = DirectedGraph({1: [2, 3], 2: [4], 3: [4]})
     d.add_vertex(5)
     self.assertTrue(5 in d)
     self.assertEqual(d.get_indegree(5), 0)
     self.assertEqual(d.get_outdegree(5), 0)
     self.assertEqual(d[5], [])
Exemple #2
0
def test_add_vertex():
    graph = DirectedGraph({1: [2, 3], 2: [4], 3: [4]})
    graph.add_vertex(5)
    assert 5 in graph
    assert graph.get_indegree(5) == 0
    assert graph.get_outdegree(5) == 0
    assert graph.get_neighbors(5) == []