def test_image_video_kohonen(self): fLOG( __file__, self._testMethodName, OutputPrint=__name__ == "__main__") temp = get_temp_folder(__file__, "temp_graph_distance") graph1 = [("a", "b"), ("b", "c"), ("b", "d"), ("d", "e"), ("e", "f"), ("b", "f"), ("b", "g"), ("f", "g"), ("a", "g"), ("a", "g"), ("c", "d"), ("d", "g"), ("d", "h"), ("aa", "h"), ("aa", "c"), ("f", "h"), ] graph2 = copy.deepcopy(graph1) + \ [("h", "m"), ("m", "l"), ("l", "C"), ("C", "r"), ("a", "k"), ("k", "l"), ("k", "C"), ] graph1 = GraphDistance(graph1) graph2 = GraphDistance(graph2) graph2["C"].label = "c" store = {} if len(list(graph1.enumerate_all_paths(True))) != 17: raise Exception("expecting 17 here") if len(list(graph2.enumerate_all_paths(True))) != 19: raise Exception("expecting 19 here") distance, graph = graph1.distance_matching_graphs_paths(graph2, use_min=False, store=store) if graph["h"].Label != "h": raise Exception("we expect this node to be merged in the process") if distance is None: raise Exception("expecting something different from None") outfile1 = os.path.join(temp, "unittest_GraphDistance4_sub1.png") outfile2 = os.path.join(temp, "unittest_GraphDistance4_sub2.png") outfilef = os.path.join(temp, "unittest_GraphDistance4_subf.png") if is_travis_or_appveyor() == "travis": warnings.warn("graphviz is not available") return vertices, edges = graph1.draw_vertices_edges() draw_graph_graphviz(vertices, edges, outfile1) vertices, edges = graph2.draw_vertices_edges() draw_graph_graphviz(vertices, edges, outfile2) assert os.path.exists(outfile2) vertices, edges = graph.draw_vertices_edges() draw_graph_graphviz(vertices, edges, outfilef) assert os.path.exists(outfilef)
def test_make_video(self): fLOG(__file__, self._testMethodName, OutputPrint=__name__ == "__main__") if is_travis_or_appveyor() == "travis": warnings.warn("graphviz is not available") return temp = get_temp_folder(__file__, "temp_graphviz") fout = os.path.join(temp, "image.png") out = draw_graph_graphviz([(1, "eee", "red")], [(1, 2, "blue"), (3, 4), (1, 3)], fout) fLOG(out) assert os.path.exists(fout) assert os.path.exists(fout + ".gv")
def test_make_video(self): fLOG( __file__, self._testMethodName, OutputPrint=__name__ == "__main__") if is_travis_or_appveyor() == "travis": warnings.warn("graphviz is not available") return temp = get_temp_folder(__file__, "temp_graphviz") fout = os.path.join(temp, "image.png") out = draw_graph_graphviz([(1, "eee", "red")], [(1, 2, "blue"), (3, 4), (1, 3)], fout) fLOG(out) assert os.path.exists(fout) assert os.path.exists(fout + ".gv")
def test_image_video_kohonen(self): fLOG(__file__, self._testMethodName, OutputPrint=__name__ == "__main__") temp = get_temp_folder(__file__, "temp_graph_distance") graph1 = [ ("a", "b"), ("b", "c"), ("b", "d"), ("d", "e"), ("e", "f"), ("b", "f"), ("b", "g"), ("f", "g"), ("a", "g"), ("a", "g"), ("c", "d"), ("d", "g"), ("d", "h"), ("aa", "h"), ("aa", "c"), ("f", "h"), ] graph2 = copy.deepcopy(graph1) + \ [("h", "m"), ("m", "l"), ("l", "C"), ("C", "r"), ("a", "k"), ("k", "l"), ("k", "C"), ] graph1 = GraphDistance(graph1) graph2 = GraphDistance(graph2) graph2["C"].label = "c" store = {} if len(list(graph1.enumerate_all_paths(True))) != 17: raise Exception("expecting 17 here") if len(list(graph2.enumerate_all_paths(True))) != 19: raise Exception("expecting 19 here") distance, graph = graph1.distance_matching_graphs_paths(graph2, use_min=False, store=store) if graph["h"].Label != "h": raise Exception("we expect this node to be merged in the process") if distance is None: raise Exception("expecting something different from None") outfile1 = os.path.join(temp, "unittest_GraphDistance4_sub1.png") outfile2 = os.path.join(temp, "unittest_GraphDistance4_sub2.png") outfilef = os.path.join(temp, "unittest_GraphDistance4_subf.png") if is_travis_or_appveyor() == "travis": warnings.warn("graphviz is not available") return vertices, edges = graph1.draw_vertices_edges() draw_graph_graphviz(vertices, edges, outfile1) vertices, edges = graph2.draw_vertices_edges() draw_graph_graphviz(vertices, edges, outfile2) assert os.path.exists(outfile2) vertices, edges = graph.draw_vertices_edges() draw_graph_graphviz(vertices, edges, outfilef) assert os.path.exists(outfilef)