def obtain_edit_distance_from_eqc_and_H(H,eqc): eqcgraphs = [] for graphstr in eqc: graph = comparison.num2CG(graphstr,len(H)) eqcgraphs.append(graph) hamming_distance = [] for graph in eqcgraphs: hamming_distance.append(determine_edit_distance(graph,H)) return hamming_distance
def obtain_edit_distance_from_eqc_only(H,eqc): eqcgraphs = [] for graphstr in eqc: graph = comparison.num2CG(graphstr,len(H)) eqcgraphs.append(graph) hamming_distance = [] for comb in combinations(eqcgraphs,2): hamming_distance.append(determine_edit_distance(comb[0],comb[1])) return hamming_distance
def obtain_out_degrees_from_eqc(H,eqc): eqcgraphs = [] for graphstr in eqc: graph = comparison.num2CG(graphstr,len(H)) eqcgraphs.append(graph) outdegrees = [] for graph in eqcgraphs: outdegrees.append(determine_out_degrees(graph)) return outdegrees
def compat(G): n = len(G) num = g2num(G) # sample all the graph for gStar star_l = all_undersamples(G) hits = {} # brute force all graphs for i in range(0, 2**(n**2)): tmpG = num2CG(i, n) tmp_l = all_undersamples(tmpG) c = compatible(tmp_l, star_l) if len(sum(c)) > 0: hits[i] = c return hits
def compat(G): n = len(G) num = g2num(G) # sample all the graph for gStar star_l = all_undersamples(G) hits = {} # brute force all graphs for i in range(0, 2 ** (n ** 2)): tmpG = num2CG(i, n) tmp_l = all_undersamples(tmpG) c = compatible(tmp_l, star_l) if len(sum(c)) > 0: hits[i] = c return hits
def cc_all(i, nodes, steps): # print i g = num2CG(i, nodes) return i, cc_undersamples(g, steps=steps)
def iall(i, nodes): print i g = num2CG(i, nodes) return compact_call_undersamples(g)
def ilength(i, nodes): print i g = num2CG(i, nodes) return len(call_undersamples(g))
def icompat(i, nodes): print i g = num2CG(i, nodes) return compat(g)
def tuple2graph(t, n): g = num2CG(t[0], n) return add_bd_by_adj(g, num2adj(t[1], n))