Exemple #1
0
 def test_topsort_simple(self):
     graph = DepGraph({
         'a': ['c'],
         'b': [],
         'c': ['b'],
     })
     assert ['b', 'c', 'a'] == graph.topsort()
Exemple #2
0
 def test_topsort_double_cycle(self):
     graph = DepGraph({
         'a': ['b', 'c'],
         'c': ['a', 'b'],
         'b': ['c', 'a'],
     })
     assert ['a', 'b', 'c'] == graph.topsort()
 def test_topsort_double_cycle(self):
     graph = DepGraph({
         'a': ['b', 'c'],
         'c': ['a', 'b'],
         'b': ['c', 'a'],
     })
     assert ['a', 'b', 'c'] == graph.topsort()
 def test_topsort_simple(self):
     graph = DepGraph({
         'a': ['c'],
         'b': [],
         'c': ['b'],
     })
     assert ['b', 'c', 'a'] == graph.topsort()
Exemple #5
0
 def test_topsort_cycle_plus(self):
     graph = DepGraph({
         'a': ['b', 'c'],
         'c': ['a', 'b'],
         'b': ['c', 'a', 'd'],
         'd': []
     })
     assert ['d', 'a', 'b', 'c'] == graph.topsort()
 def test_topsort_cycle_plus(self):
     graph = DepGraph({
         'a': ['b', 'c'],
         'c': ['a', 'b'],
         'b': ['c', 'a', 'd'],
         'd': []
     })
     assert ['d', 'a', 'b', 'c'] == graph.topsort()
Exemple #7
0
 def test_topsort_same_level(self):
     graph = DepGraph({
         'a': ['b', 'd', 'e', 'c'],
         'e': [],
         'c': [],
         'd': [],
         'b': [],
     })
     # same level sort by name
     assert ['b', 'c', 'd', 'e', 'a'] == graph.topsort()
 def test_topsort_same_level(self):
     graph = DepGraph({
         'a': ['b', 'd', 'e', 'c'],
         'e': [],
         'c': [],
         'd': [],
         'b': [],
     })
     # same level sort by name
     assert ['b', 'c', 'd', 'e', 'a'] == graph.topsort()