############################################## refinement = 'indeg_guided' vals = [0.1, 0.2, 0.5, 0.7] first = True n = 1000 # Query graph, the bigger one clusters = pd.random_clusters(n, 8) inter = 0.1 intra = 0.1 oG, oGT, olabeling = pd.custom_cluster_matrix(n, clusters, inter, 1, intra, 0) c = Codec(0.15, 0.5, 5) k, epsilon, classes, sze_idx, reg_list, nirr = c.compress(oG, refinement) query = c.reduced_matrix(oG, k, epsilon, classes, reg_list) # Database c = Codec(0.2, 0.5, 5) num_c = 8 for r in range(5): for i in vals: clusters = pd.random_clusters(n, num_c) G, GT, labeling = pd.custom_cluster_matrix(n, clusters, i, 1, i, 0) k, epsilon, classes, sze_idx, reg_list, nirr = c.compress( G, refinement) red = c.reduced_matrix(G, k, epsilon, classes, reg_list) if query.shape[0] > red.shape[0]: sd = metrics.spectral_dist(query, red)
tm = time.time() k, epsilon, classes, sze_idx, reg_list, nirr = c.compress(G, 'indeg_guided') tcompression1 = time.time() - tm #print(f"TIME: tcompression1:{tcompression1:.2f}") # Compression G1 c = Codec(0.285, 0.285, 1) c.verbose = False tm = time.time() k2, epsilon, classes2, sze_idx, reg_list2, nirr2 = c.compress(G2, 'indeg_guided') tcompression2 = time.time() - tm #print(f"TIME: tcompression2:{tcompression2:.2f}") # Reduced graph tm = time.time() red = c.reduced_matrix(G, k, epsilon, classes, reg_list) red2 = c.reduced_matrix(G2, k2, epsilon, classes2, reg_list2) tred = time.time() - tm #print(f"TIME: red:{tred:.2f}") # Original SD tm = time.time() sd_o = metrics.spectral_dist(G,G2) tsd = time.time() - tm #print(f"TIME: tsd:{tsd:.2f}") # Reduced SD tm = time.time() sd_red = metrics.spectral_dist(red,red2) tsd_red = time.time() - tm #print(f"TIME: tsd_red:{tsd_red:.2f}")