def get_minor_minimal_from_list(labels): new_labels = [] # non_embedable_dic = {label: False for label in labels} embed_problems_list = [] t0 = time() counter = 0 all_counter = 0 new_non_embedding = [] for label in labels: # not_valid = False all_embed = True curr_graph = GraphMinor.from_sage_graph_label(label) list_edge_contracted_removed = curr_graph.get_list_of_minors() + curr_graph.get_list_of_1_edge_removed() del curr_graph gc.collect() # print "now analyzing label " + label + "\n" for temp_graph in list_edge_contracted_removed: # t1 = time() # print "t1: " + str(t1-t0) # print "current temp_graph ", temp_graph # print "temp_graph: ", temp_graph.getCanonicalLabel() # if temp_graph.getCanonicalLabel() in non_embedable_dic: # break embed_status = embeddingtest.graph_embeds(temp_graph.get_gembed_format()) if embed_status == False: # non_embedable_dic[temp_graph.getCanonicalLabel()] = False curr_new_label = temp_graph.getCanonicalLabel() if curr_new_label not in labels and curr_new_label not in new_non_embedding: new_non_embedding.append(curr_new_label) # break # not_valid = True all_embed = False elif embed_status == None: embed_problems_list.append(temp_graph.getCanonicalLabel()) pdb.set_trace() # else: # new_labels.append(label) # counter += 1 for temp_graph in list_edge_contracted_removed: del temp_graph del list_edge_contracted_removed gc.collect() # if not not_valid: if all_embed: new_labels.append(label) counter += 1 print "found another one! up to " + str(counter) + " graphs now!" all_counter += 1 t1 = time() print all_counter, "labels analyzed in t1: " + str(t1-t0) print counter, " labels have been added to the list" return [new_labels, list(set(new_non_embedding))]
def main(): import embeddingtest # dirOutput = os.getcwd() # folders = dirOutput.split('/') # dirOutput = dirOutput.strip(folders[-1]) # dirOutput = dirOutput + "output/" # filename = "labels-8262" # labels_list = pickle.load( open( dirOutput + filename, "rb" ) ) # # print labels_list # g = GraphMinor.from_sage_graph_label(labels_list[0]) g = GraphMinor.from_sage_graph_label("I?TcdB?Nw") print "g: ", g print "g: ", relabel_edge_list(g.edge_list)[1] print g.get_gembed_format() print "embeddingtest: " + str(embeddingtest.graph_embeds(g.get_gembed_format()))