【发布时间】:2018-11-25 12:21:16
【问题描述】:
我正在寻找一种简洁、简单的方法来绘制仅具有正加权边的加权 NetworkX 图。
我能想到的唯一方法是:
pos=nx.spring_layout(G)
# filter and only draw positive edges
positive_edges = [(u,v) for (u,v,d) in G.edges(data=True) if d['weight'] >0]
nx.draw_networkx_nodes(G,pos)
nx.draw_networkx_edges(G,pos,edgelist=positive_edges)
plt.axis('off')
plt.show()
我想知道是否有更简单的方法。我想像这样:
nx.draw(G, only_positive_edge=True)
或
nx.draw(G, zero_weighted_edge_invisible=True)
【问题讨论】:
标签: python matplotlib graph networkx