Beispiel #1
0
 def test_add_regular_edges_invalid(self):
     g = Graph([v, w, x])
     # degree > vertexcount-1
     with pytest.raises(GraphException):
         g.add_regular_edges(3)
     # degree * vertexcount not even
     with pytest.raises(GraphException):
         g.add_regular_edges(1)
Beispiel #2
0
 def test_add_regular_edges_0(self):
     g = Graph()
     g.add_regular_edges(0)
     assert g.vertices() == []
     assert g.edges() == []
     g = Graph([v, w, x])
     g.add_regular_edges(0)
     assert sorted(g.vertices()) == sorted([v, x, w])
     assert g.edges() == []
Beispiel #3
0
 def test_add_regular_edges_negative(self):
     g = Graph()
     with pytest.raises(ValueError):
         g.add_regular_edges(-1)
Beispiel #4
0
 def test_add_regular_edges_odd(self):
     g = Graph([v, w, x, y])
     g.add_regular_edges(1)
Beispiel #5
0
 def test_add_regular_edges_even(self):
     g = Graph([v, w, x])
     g.add_regular_edges(2)
     assert set(g.edges()) == set([vw, vx, wx])