我正在创建一个支持自循环的多图。在标记边缘时,不自主循环标签不会打印。在下面的代码中,节点'aa'
上缺少自循环标签import networkx as nx
from networkx.utils import is_list_of_ints, flatten
import matplotlib.pyplot as plt
G=nx.MultiGraph()
G.add_edge('aa','bb',weight=0.6)
G.add_edge('aa','cc',weight=0.2)
G.add_edge('cc','dd',weight=0.1)
G.add_edge('aa','aa',weight=0.3)
plt.figure(figsize=(10,10), facecolor="w", frameon=False)
pos = nx.graphviz_layout(G, prog="fdp") #calculate position (x,y) coordinates
nx.draw_networkx_nodes(G,pos,node_size=1200,node_shape='o',node_color='0.75')
nx.draw_networkx_edges(G,pos, width=2,edge_color='b')
nx.draw_networkx_labels(G,pos,fontsize=2, labelloc='c')
nx.draw_networkx_edge_labels(G,pos, {('aa', 'aa'):'lllllabel', ('aa', 'bb'):'aaaaaabbbbbb'}, label_pos=0.3, ax=None, rotate=False)
plt.show()