我最近看到了这个答案:Matplotlib and Networkx - drawing a self loop node
并尝试了用于绘制无向多图的代码:
from networkx.drawing.nx_agraph import to_agraph
G = nx.MultiGraph()
G.add_edges_from([('A','C'),('A','C'),('A','C'), ('C', 'C'), ('B', 'C'), ('A', 'B')])
G.graph['edge'] = {'splines': 'curved'}
G.graph['graph'] = {'scale': '3'}
A = to_agraph(G)
A.layout('dot')
A.draw('images/multigraph_example.png')
但是,代码的结果是这样的:
它仅显示从A
到C
的一条边。如何使它显示三个边缘?