def shortTest(): gedlibpy.restart_env() print("Here is the mini Python function !") gedlibpy.load_GXL_graphs( "include/gedlib-master/data/datasets/Mutagenicity/data/", "include/gedlib-master/data/collections/Mutagenicity.xml") listID = gedlibpy.get_all_graph_ids() gedlibpy.set_edit_cost("CHEM_1") gedlibpy.init() gedlibpy.set_method("BIPARTITE", "") gedlibpy.init_method() g = listID[0] h = listID[1] gedlibpy.run_method(g, h) print("Node Map : ", gedlibpy.get_node_map(g, h)) print("Assignment Matrix : ") afficheMatrix(gedlibpy.get_assignment_matrix(g, h)) print("Upper Bound = " + str(gedlibpy.get_upper_bound(g, h)) + ", Lower Bound = " + str(gedlibpy.get_lower_bound(g, h)) + ", Runtime = " + str(gedlibpy.get_runtime(g, h)))
def classiqueTest(): gedlibpy.restart_env() gedlibpy.load_GXL_graphs( 'include/gedlib-master/data/datasets/Mutagenicity/data/', 'collections/MUTA_10.xml') listID = gedlibpy.get_all_graph_ids() afficheId = "" for i in listID: afficheId += str(i) + " " print("Number of graphs = " + str(len(listID)) + ", list of Ids = " + afficheId) gedlibpy.set_edit_cost("CHEM_1") gedlibpy.init() gedlibpy.set_method("IPFP", "") gedlibpy.init_method() g = listID[0] h = listID[0] gedlibpy.run_method(g, h) liste = gedlibpy.get_all_map(g, h) print("Forward map : ", gedlibpy.get_forward_map(g, h), ", Backward map : ", gedlibpy.get_backward_map(g, h)) print("Node Map : ", gedlibpy.get_node_map(g, h)) print("Upper Bound = " + str(gedlibpy.get_upper_bound(g, h)) + ", Lower Bound = " + str(gedlibpy.get_lower_bound(g, h)) + ", Runtime = " + str(gedlibpy.get_runtime(g, h)))
def addGraphTest(): gedlibpy.restart_env() gedlibpy.load_GXL_graphs( 'include/gedlib-master/data/datasets/Mutagenicity/data/', 'collections/MUTA_10.xml') currentID = gedlibpy.add_graph() print(currentID) gedlibpy.add_node(currentID, "_1", {"chem": "C"}) gedlibpy.add_node(currentID, "_2", {"chem": "O"}) gedlibpy.add_edge(currentID, "_1", "_2", {"valence": "1"}) listID = gedlibpy.get_all_graph_ids() print(listID) print(gedlibpy.get_graph_node_labels(10)) print(gedlibpy.get_graph_edges(10)) for i in listID: print(gedlibpy.get_graph_node_labels(i)) print(gedlibpy.get_graph_edges(i))
for i in listID: for j in listID: script.run_method(i, j) distances[map_id_to_index[i], map_id_to_index[j]] = script.get_upper_bound(i, j) median_set_index = np.argmin(np.sum(distances, 0)) sod = np.min(np.sum(distances, 0)) return median_set_index, sod if __name__ == "__main__": #Chargement du dataset gedlibpy.load_GXL_graphs( '../include/gedlib-master/data/datasets/Letter/HIGH/', '../include/gedlib-master/data/collections/Letter_Z.xml') gedlibpy.set_edit_cost("LETTER") gedlibpy.init() gedlibpy.set_method("IPFP", "") gedlibpy.init_method() dataset, my_y = pygraph.utils.graphfiles.loadDataset( "../include/gedlib-master/data/datasets/Letter/HIGH/Letter_Z.cxl") listID = gedlibpy.get_all_graph_ids() median, sod, sods_path, set_median = compute_median(gedlibpy, listID, dataset, verbose=True)