def test_storing_known_isomorphisms(self): # Assert that, after processing a list of graphs containing some isomorphisms and anisomorphisms, the known # isomorphisms are correct tests.set_up_test_graphs() graphs = tests.isomorphic_graphs + tests.anisomorphic_graphs known_isomorphisms = process(graphs) self.assertEqual({1, 2}, known_isomorphisms[0]) self.assertEqual({0, 2}, known_isomorphisms[1]) self.assertEqual({0, 1}, known_isomorphisms[2]) self.assertEqual(set(), known_isomorphisms[3]) self.assertEqual(set(), known_isomorphisms[4])
def test_modules_to_graph(self): tests.set_up_test_graphs() modules = graph_to_modules(tests.non_trivial_graph) graph, _ = modules_to_graph(modules) labels = [vertex.label for vertex in graph.vertices] expected_labels = ["0", "1", "2+4", "3"] self.assertTrue(set(labels) == set(expected_labels)) modules = graph_to_modules(tests.modular_decomposition_graph) graph, _ = modules_to_graph(modules) labels = [vertex.label for vertex in graph.vertices] expected_labels = ["0+1+4", "2+3", "5+6"] self.assertTrue(set(labels) == set(expected_labels)) modules = graph_to_modules(tests.butterfly) graph, _ = modules_to_graph(modules) labels = [vertex.label for vertex in graph.vertices] expected_labels = ["0", "1+4", "2+3"] self.assertTrue(set(labels) == set(expected_labels)) modules2 = graph_to_modules(graph) graph2, _ = modules_to_graph(modules2) labels = [vertex.label for vertex in graph2.vertices] expected_labels = ["0", "1+4+2+3"] self.assertTrue(set(labels) == set(expected_labels)) modules3 = graph_to_modules(graph2) graph3, _ = modules_to_graph(modules3) labels = [vertex.label for vertex in graph3.vertices] expected_labels = ["0+1+4+2+3"] self.assertTrue(set(labels) == set(expected_labels)) modules4 = graph_to_modules(graph3) graph4, _ = modules_to_graph(modules4) labels = [vertex.label for vertex in graph4.vertices] expected_labels = ["0+1+4+2+3"] self.assertTrue(set(labels) == set(expected_labels)) g = tools.create_graph_helper([[1, 2], [1, 3], [2, 3]]) modules_triangle = graph_to_modules(g) graph, _ = modules_to_graph(modules_triangle) labels = [vertex.label for vertex in graph.vertices] expected_labels = ["1+2+3"] self.assertTrue(set(labels) == set(expected_labels))
def setUp(self): tests.set_up_test_graphs()