Example #1
0
 def test_forest(self):
     self.assertEqual(
         ['a', 'b', 'c', 'd'],
         topsort(OrderedDict([
             ('d', []),
             ('b', ['c']),
             ('c', []),
             ('a', ['b']),
         ]))
     )
Example #2
0
 def test_three_nodes(self):
     self.assertEqual(
         ['a', 'b', 'c'],
         topsort(dict(a=['b'], b=['c'], c=[]))
     )
Example #3
0
 def test_single_node(self):
     self.assertEqual(
         ['a'],
         topsort(dict(a=[]))
     )
Example #4
0
 def test_two_nodes(self):
     self.assertEqual(
         ['a', 'b'],
         topsort(dict(a=['b'], b=[]))
     )
Example #5
0
 def test_empty_graph(self):
     self.assertEqual(
         [],
         topsort(dict())
     )