예제 #1
0
 def test_is_connected_sees_non_connected_graph(self):
     a, b, c, d  = Vertex('a'), Vertex('b'), Vertex('c'), Vertex('d')
     e = Vertex('e')
     g = Graph([a, b, c, d, e]) 
     g.add_edge(Edge(a, b))
     g.add_edge(Edge(b, c))
     g.add_edge(Edge(c, d))
     g.add_edge(Edge(d, a))
     self.assertFalse(g.is_connected())
예제 #2
0
 def test_is_connected_sees_connected_graph(self):
     """a graph is connected if there is a path
     from every node to every other node"""
     a, b, c, d  = Vertex('a'), Vertex('b'), Vertex('c'), Vertex('d')
     g = Graph([a, b, c, d]) 
     g.add_edge(Edge(a, b))
     g.add_edge(Edge(b, c))
     g.add_edge(Edge(c, d))
     g.add_edge(Edge(d, a))
     self.assertTrue(g.is_connected())