我想像波纹管图像一样在python中可视化具有边缘权重和节点坐标的多向图。
我试图用networkx和pyplot进行绘制。但是箭头无法显示,因为pyplot通过重叠绘制它。
nodes = pd.DataFrame([[[1, 3]], [[0, 2]], [[3, 3]], [[5, 2]], [[2, 4]]], columns=['coords'])
nodes.index = ['A', 'B', 'C', 'D', 'E']
edges = pd.DataFrame([['A','B', 4], ['B','A', 20], ['C','B', 3], ['D','D' ,10], ['C','A', 7], ['E','A' ,2], ['D','C' ,15], ['C','E', 8], ['D','A', 2]], columns=['start', 'end', 'weight'])
G = nx.MultiDiGraph()
G.add_nodes_from(nodes.index)
for index, row in edges.iterrows():
G.add_edge(row.start, row.end, weight=row.weight)
nx.draw_networkx_labels(G, nodes.coords, font_size=16)
nx.draw_networkx_edge_labels(G, nodes.coords, weight=edges.weight)
nx.draw(G, nodes.coords)
plt.show()
请告诉我您是否有一个好的库或算法。