pedWorks.py 文件源码

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

项目:PedWorks 作者: BrnCPrz 项目源码 文件源码
def draw_partition(graph, partition):
    # requires matplotlib.pyplot, uncomment above
    # uses community code and sample from http://perso.crans.org/aynaud/communities/ to draw matplotlib graph in shades of gray
    g = graph
    count = 0
    size = float(len(set(partition.values())))
    pos = nx.spring_layout(g)
    for com in set(partition.values()):
        count = count + 1
        list_nodes = [nodes for nodes in partition.keys()
                      if partition[nodes] == com]
        nx.draw_networkx_nodes(g, pos, list_nodes, node_size=20,
                               node_color=str(count / size))
    nx.draw_networkx_edges(g, pos, alpha=0.5)
    plt.show()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号