network_similarity.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:Compare-two-control-flow 作者: viennadd 项目源码 文件源码
def get_graph_from_filename(filename):
    text = read_file(filename)
    d = text_to_json_dict(text)
    G = adjacency_list_to_graph(d['adjacency'])
    return G


# def main():
#     G = get_graph_from_id(27)
#     
#     G2 = get_graph_from_id(21)
# 
#     length = int(min(len(G.nodes()), len(G2.nodes())) * .9)
#     
#     n_pair_subgraphs = 0
#     n_isomorphic = 0
#     for subgraphs in subgraphs_product(G, G2, length):
#         n_pair_subgraphs += 1
#         if nx.is_isomorphic(subgraphs[0], subgraphs[1]):
#             n_isomorphic += 1
#             print('a = %s' % subgraphs[0].edges())
#             print('b = %s' % subgraphs[1].edges())
# 
#     print('total = %d, isomorphic = %d' % (n_pair_subgraphs, n_isomorphic))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号