def test_graph3(self): graph_filename = graph_sample_folder + 'graph3_cycle.txt' try: topo_sort = sort(graph_filename) self.fail('topological sort should have raised an Error!') except ValueError as err: self.assertTrue(cycle_equal(err.cycle, ['a', 'b', 'c']))
def test_graph14(self): graph_filename = graph_sample_folder + 'graph14_cycle.txt' try: topo_sort = sort(graph_filename) self.fail('topological sort should have raised an Error!') except ValueError as err: # there are many cycles in graph14 # test that the cycle exists self.assertTrue(contains_cycle(err.cycle, graph_filename))
def test_graph11(self): graph_filename = graph_sample_folder + 'graph11_cycle.txt' try: topo_sort = sort(graph_filename) self.fail('topological sort should have raised an Error!') except ValueError as err: cycle1 = ['H', 'C', 'F', 'I', 'B', 'D'] cycle2 = ['I', 'B', 'D'] self.assertTrue( cycle_equal(err.cycle, cycle1) or cycle_equal(err.cycle, cycle2))
def test_graph8(self): graph_filename = graph_sample_folder + 'graph8.txt' topo_sort = sort(graph_filename) self.assertTrue(do_edges_respect_sort(topo_sort, graph_filename))