show_graph.py 文件源码

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

项目:community-detection 作者: msionkin 项目源码 文件源码
def show_graph_communities(graph, partition, color_map=None, with_labels=False):
    if color_map is None:
        color_map = generate_color_map(partition)
    pos = nx.spring_layout(graph,k=0.1,iterations=50)
    comm_nodes = utils.partition_to_comm_nodes_map(partition)
    for comm, nodes in comm_nodes.items():
        nx.draw_networkx_nodes(graph, pos, nodelist=nodes, node_size=400,
                               node_color=color_map.get(comm), label=comm, cmap=plt.cm.jet)
    if with_labels:
        nx.draw_networkx_labels(graph, pos, font_size=12)
    nx.draw_networkx_edges(graph, pos, alpha=0.3)
    plt.legend()
    plt.axis('off')
    plt.show()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号