相关疑难解决方法(0)

使用networkx在两个节点之间绘制多个边

我需要在两个节点之间绘制一个具有多个边(具有不同权重)的有向图.也就是说,我有节点A和B以及长度= 2的边(A,B)和长度= 3的(B,A).

我曾尝试使用G = nx.Digraph和G = nx.Multidigraph.当我绘制它时,我只能查看一个边缘而只能看到其中一个标签.有什么办法吗?

python label graph edges networkx

9
推荐指数
4
解决办法
6269
查看次数

How do I draw edge labels for MultiGraph in NetworkX?

In the class networkx.MultiGraph, an edge is keyed by (u, v, key), for instance, ('n1', 'n2', 'key1'). I would like to draw edge labels (say weight, (u, v, key): 10) for MultiGraph by using the function networkx.draw_networkx_edge_labels.

However, edge labels are keyed by a two-tuple (u, v) in draw_networkx_edge_labels, instead of a 3-tuple (u, v, key), as is the case in MultiGraph. This raises ValueError: too many values to unpack.


PS: …

python matplotlib networkx

8
推荐指数
1
解决办法
3030
查看次数

标签 统计

networkx ×2

python ×2

edges ×1

graph ×1

label ×1

matplotlib ×1