示例#1
0
 def test_add_edge(self):
     g = DiGraph()
     for i in range(7):
         g.add_node(i)
     g.add_edge(1, 2, 3)
     g.add_edge(1, 2, 3)
     g.add_edge(1, 2, 4)
     self.assertFalse(g.add_edge(1, 87, 3))
     g.add_edge(92, 2, 3)
     self.assertFalse(g.add_edge(1, 5, -3))
     self.assertFalse(g.add_edge(1, 1, 3))
     g.add_edge(4, 5, 3)
     self.assertEqual(g.e_size(), 2)
示例#2
0
 def test_e_size(self):
     g = DiGraph()
     for i in range(7):
         g.add_node(i)
     g.add_edge(1, 1, 3)
     g.add_edge(1, 2, 4)
     g.add_edge(1, 6, -8)
     g.add_edge(2, 1, 7)
     g.add_edge(2, 1, 7)
     g.add_edge(5, 2, 4)
     g.add_edge(32, 45, 4)
     g.add_edge(1, 9, 4)
     g.add_edge(1, 2, 3)
     self.assertEqual(g.e_size(), 3)