2012-08-15 51 views
1

我正在創建一個multigraph來支持自我循環。在標註邊緣的同時,自行循環標籤不會打印。在下面的代碼,自我循環標籤丟失節點「AA」Networkx,自循環中的邊緣標籤未打印。

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() 

回答