def test_topological_sort_2(self): """ Does another basic topological sort work? """ pairs = [ (1,2), (1,3), (2,4), (3,4), (5,6), (4,5) ] result, has_cycles = topological_sort(pairs) self.assert_(not has_cycles) self.assertEquals(result, [1, 2, 3, 4, 5, 6])
def test_topological_sort_3(self): """ Does cycle detection work? """ pairs = [ (1,2), (2,3), (3,1) ] result, has_cycles = topological_sort(pairs) self.assert_(has_cycles)