我已经阅读了文档,并且确实添加了带有属性的边,weight但是边的权重未显示在绘图上,并且当我将诅咒悬停在两个节点之间的链接上时,它也未显示。可以显示重量吗?
代码片段(来源:https ://pyvis.readthedocs.io/en/latest/tutorial.html#networkx-integration ):
from pyvis.network import Network
import networkx as nx
nx_graph = nx.cycle_graph(10)
nx_graph.nodes[1]['title'] = 'Number 1'
nx_graph.nodes[1]['group'] = 1
nx_graph.nodes[3]['title'] = 'I belong to a different group!'
nx_graph.nodes[3]['group'] = 10
nx_graph.add_node(20, size=20, title='couple', group=2)
nx_graph.add_node(21, size=15, title='couple', group=2)
nx_graph.add_edge(20, 21, weight=5)
nx_graph.add_node(25, size=25, label='lonely', title='lonely node', group=3)
nt = Network('500px', '500px')
# populates the nodes and edges data structures
nt.from_nx(nx_graph)
nt.show('nx.html')
结果: 片段的结果
如何显示边缘的重量?在这个例子中,节点 20 和 21 的边的权重。
