def metrics_fuse(G):
    degree = degree_centrality(G)
    closeness = closeness_centrality(G)
    betweenness = nx.betweenness_centrality(G)
    core = core_number(G)
    pageranks = pagerank(G)
    (hubs, authorities) = hits(G)
    fused = dict()
    for node in G.nodes:
        deg = degree[node]
        cl = closeness[node]
        bet = betweenness[node]
        co = core[node]
        pr = pageranks[node]
        auth = authorities[node]
        M = ((((((0.05 * deg) + (0.15 * cl)) + (0.1 * bet)) + (0.3 * co)) + (0.25 * pr)) + (0.15 * auth))
        fused[node] = M
    pageranks = sorted(pageranks.items(), key=(lambda x: x[1]), reverse=True)
    print('使用PageRank算法，影响力前10的节点为：')
    for i in range(10):
        print('节点 {}'.format(pageranks[i][0]))
    pos = nx.random_layout(G)
    top_nodes = [k for (k, v) in pageranks[:10]]
    other_nodes = [k for (k, v) in pageranks[10:]]
    nx.draw_networkx_nodes(G, pos, top_nodes, node_size=200, node_color='Red', alpha=0.6)
    nx.draw_networkx_nodes(G, pos, other_nodes, node_size=200, node_color='Green', alpha=0.6)
    nx.draw_networkx_edges(G, pos)
    labels = dict()
    for (k, v) in pageranks[:10]:
        labels[k] = k
    nx.draw_networkx_labels(G, pos, labels=labels)
    plt.savefig('./pagerank_result.png')
    plt.show()
    print('---------------------------------------------')
    authorities = sorted(authorities.items(), key=(lambda x: x[1]), reverse=True)
    print('使用HITS算法，影响力前10的节点为：')
    for i in range(10):
        print('节点 {}'.format(authorities[i][0]))
    pos = nx.random_layout(G)
    top_nodes = [k for (k, v) in authorities[:10]]
    other_nodes = [k for (k, v) in authorities[10:]]
    nx.draw_networkx_nodes(G, pos, top_nodes, node_size=200, node_color='Red', alpha=0.6)
    nx.draw_networkx_nodes(G, pos, other_nodes, node_size=200, node_color='Green', alpha=0.6)
    nx.draw_networkx_edges(G, pos)
    labels = dict()
    for (k, v) in authorities[:10]:
        labels[k] = k
    nx.draw_networkx_labels(G, pos, labels=labels)
    plt.savefig('./hits_result.png')
    plt.show()
    print('---------------------------------------------')
    fused = sorted(fused.items(), key=(lambda x: x[1]), reverse=True)
    print('使用混合算法，影响力前10的节点为：')
    for i in range(10):
        print('节点 {}'.format(fused[i][0]))
    pos = nx.random_layout(G)
    top_nodes = [k for (k, v) in fused[:10]]
    other_nodes = [k for (k, v) in fused[10:]]
    nx.draw_networkx_nodes(G, pos, top_nodes, node_size=200, node_color='Red', alpha=0.6)
    nx.draw_networkx_nodes(G, pos, other_nodes, node_size=200, node_color='Green', alpha=0.6)
    nx.draw_networkx_edges(G, pos)
    labels = dict()
    for (k, v) in fused[:10]:
        labels[k] = k
    nx.draw_networkx_labels(G, pos, labels=labels)
    plt.savefig('./fused_result.png')
    plt.show()
    print('---------------------------------------------')
    return fused
def metrics_fuse(G):
    degree = degree_centrality(G)
    closeness = closeness_centrality(G)
    betweenness = nx.betweenness_centrality(G)
    core = core_number(G)
    pageranks = pagerank(G)
    (hubs, authorities) = hits(G)
    fused = dict()
    for node in G.nodes:
        deg = degree[node]
        cl = closeness[node]
        bet = betweenness[node]
        co = core[node]
        pr = pageranks[node]
        auth = authorities[node]
        M = ((((((0.05 * deg) + (0.15 * cl)) + (0.1 * bet)) + (0.3 * co)) + (0.25 * pr)) + (0.15 * auth))
        fused[node] = M
    pageranks = sorted(pageranks.items(), key=(lambda x: x[1]), reverse=True)
    print('使用PageRank算法，影响力前10的节点为：')
    for i in range(10):
        print('节点 {}'.format(pageranks[i][0]))
    pos = nx.random_layout(G)
    top_nodes = [k for (k, v) in pageranks[:10]]
    other_nodes = [k for (k, v) in pageranks[10:]]
    nx.draw_networkx_nodes(G, pos, top_nodes, node_size=200, node_color='Red', alpha=0.6)
    nx.draw_networkx_nodes(G, pos, other_nodes, node_size=200, node_color='Green', alpha=0.6)
    nx.draw_networkx_edges(G, pos)
    labels = dict()
    for (k, v) in pageranks[:10]:
        labels[k] = k
    nx.draw_networkx_labels(G, pos, labels=labels)
    plt.savefig('./pagerank_result.png')
    plt.show()
    print('---------------------------------------------')
    authorities = sorted(authorities.items(), key=(lambda x: x[1]), reverse=True)
    print('使用HITS算法，影响力前10的节点为：')
    for i in range(10):
        print('节点 {}'.format(authorities[i][0]))
    pos = nx.random_layout(G)
    top_nodes = [k for (k, v) in authorities[:10]]
    other_nodes = [k for (k, v) in authorities[10:]]
    nx.draw_networkx_nodes(G, pos, top_nodes, node_size=200, node_color='Red', alpha=0.6)
    nx.draw_networkx_nodes(G, pos, other_nodes, node_size=200, node_color='Green', alpha=0.6)
    nx.draw_networkx_edges(G, pos)
    labels = dict()
    for (k, v) in authorities[:10]:
        labels[k] = k
    nx.draw_networkx_labels(G, pos, labels=labels)
    plt.savefig('./hits_result.png')
    plt.show()
    print('---------------------------------------------')
    fused = sorted(fused.items(), key=(lambda x: x[1]), reverse=True)
    print('使用混合算法，影响力前10的节点为：')
    for i in range(10):
        print('节点 {}'.format(fused[i][0]))
    pos = nx.random_layout(G)
    top_nodes = [k for (k, v) in fused[:10]]
    other_nodes = [k for (k, v) in fused[10:]]
    nx.draw_networkx_nodes(G, pos, top_nodes, node_size=200, node_color='Red', alpha=0.6)
    nx.draw_networkx_nodes(G, pos, other_nodes, node_size=200, node_color='Green', alpha=0.6)
    nx.draw_networkx_edges(G, pos)
    labels = dict()
    for (k, v) in fused[:10]:
        labels[k] = k
    nx.draw_networkx_labels(G, pos, labels=labels)
    plt.savefig('./fused_result.png')
    plt.show()
    print('---------------------------------------------')
    return fused