def test_topo_sort2(self): graph = dep_finder.Graph(Q={'B', 'C', 'E'}, B={'D'}, C={'D'}, D={'E', 'F', 'G', 'A'}) expected = ['A', 'E', 'F', 'G', 'D', 'B', 'C', 'Q'] actual = dep_finder.topo_sort(graph) self.assertEqual(expected, actual)
def test_disconnected_graph2(self): graph = dep_finder.Graph(D={'E', 'G'}, E={'F', 'M'}, F={'H'}, M={'J'}, I={}) expected = ['G', 'H', 'F', 'I', 'J', 'M', 'E', 'D'] actual = dep_finder.topo_sort(graph) self.assertEqual(expected, actual)
def test_simple_topo_sort(self): graph = dep_finder.Graph(O={'LL', 'E'}, E={'H'}) expected = ['H', 'E', 'LL', 'O'] actual = dep_finder.topo_sort(graph) self.assertEqual(expected, actual)