ADaptive-Structural-Fingerprint icon indicating copy to clipboard operation
ADaptive-Structural-Fingerprint copied to clipboard

calculation of structural interaction

Open sungeun532 opened this issue 2 years ago • 0 comments

i think the function structural_interaction in code utils_nhop_neighbors.py should be modified like this..

    for i, is_neighbor in enumerate(ri_index):
        for j, js_neighbor in enumerate(ri_index):
            intersection = list(set(is_neighbor).intersection(set(js_neighbor)))
            union = list(set(is_neighbor).union(set(js_neighbor)))
            union_rest = list(set(union).difference(set(intersection)))
    
            intersection_ri_all_i, intersection_ri_all_j = [], []
            union_ri_all_i, union_ri_all_j = [], []
            adj_delta[i][j] = 0
            if len(intersection) == 0:
                adj_delta[i][j] = 0.0001
                break
            **elif len(union_rest) == 0: # correct : intersection == union case simliarytiy maximum
                adj_delta[i][j] = 1.0
                break**
            else:
                for inter_neighbor in intersection:
                    intersection_ri_all_i.append(ri_all[i][is_neighbor.tolist().index(inter_neighbor)])
                    intersection_ri_all_j.append(ri_all[j][js_neighbor.tolist().index(inter_neighbor)])
    
                for rest_neighbor in union_rest:
                    if rest_neighbor in is_neighbor:
                        union_ri_all_i.append(ri_all[i][is_neighbor.tolist().index(rest_neighbor)])
                        union_ri_all_j.append(0)
                    else:
                        union_ri_all_j.append(ri_all[j][js_neighbor.tolist().index(rest_neighbor)])
                        union_ri_all_i.append(0)
    
                k_max = max(intersection_ri_all_j, intersection_ri_all_i)
                k_min = min(intersection_ri_all_j, intersection_ri_all_i)
                **final_max = k_max + union_ri_all_j + union_ri_all_i # correct** 
    
                union_num = np.sum(np.array(final_max), axis=0)
                inter_num = np.sum(np.array(k_min), axis=0)
    
                adj_delta[i][j] = inter_num/union_num

I corrected two parts, first, in case len(union_rest)==0, two nodes' (i and j) intersection set and union set are perfectly same, then these two nodes should have the highest intercation score? and, second, when we calculate the denominator of jacard similarity, max term should also consider union_ri_all_i,? is it rigiht? if not, plese give explain in more detail..

sungeun532 avatar Jul 10 '22 12:07 sungeun532