예제 #1
0
 def test_is_regular_should_return_true_for_regular(self):
     """Should return true when each node has the
     same number of edges"""
     vertices = [Vertex('a'), Vertex('b'), Vertex('9')]
     g = Graph(vertices, [])
     g.add_regular_edges()
     self.assertTrue(g.is_regular())
예제 #2
0
 def test_regular_edges_works_with_three_vertices(self):
     """to build .add_regular_edges,
     we'll need a way tp count a Vertex's 
     number of edges"""
     vertices = [Vertex('a'), Vertex('b'), Vertex('c')]
     g = Graph(vertices, [])
     g.add_regular_edges()
     self.assertTrue(len(g.edges()) == 3)
     self.assertTrue(g.is_regular())
예제 #3
0
 def test_is_regular_should_return_false_for_nonregular(self):
     """Should return false when each node has the
     same number of edges"""
     vertices = Vertex('a'), Vertex('c')
     g = Graph(vertices, [])
     b = Vertex('b')
     g.add_vertex(b)
     e = Edge(b, vertices[1])
     g.add_edge(e)
     self.assertFalse(g.is_regular())
예제 #4
0
 def test_regular_edges_works_with_six_vertices(self):
     """to build .add_regular_edges,
     we'll need a way tp count a Vertex's 
     number of edges"""
     import string
     six_letters = [c for c in string.ascii_lowercase][:6]
     vertices = [Vertex(l) for l in six_letters]
     g = Graph(vertices, [])
     g.add_regular_edges()
     #pp = pprint.PrettyPrinter()
     #pp.pprint(g)
     self.assertTrue(len(g.edges()) == 6)
     self.assertTrue(g.is_regular())