Exemplo n.º 1
0
 def test_ancestors(self):
     graph = Graph()
     graph.add_edges([
         Edge('a', 'b', 1),
         Edge('a', 'c', 1),
         Edge('c', 'd', 1)])
     self.assertCountEqual(graph.ancestors('a'), ['a'])
     self.assertCountEqual(graph.ancestors('b'), ['a', 'b'])
     self.assertCountEqual(graph.ancestors('c'), ['a', 'c'])
     self.assertCountEqual(graph.ancestors('d'), ['a', 'c', 'd'])
Exemplo n.º 2
0
 def test_ancestors_with_crossing_paths(self):
     graph = Graph()
     graph.add_edges([
         Edge('a', 'b', 1),
         Edge('a', 'c', 1),
         Edge('c', 'd', 1),
         Edge('b', 'd', 1)])
     self.assertCountEqual(graph.ancestors('d'), ['a', 'b', 'c', 'd'])