如何解决pyvis 库如何使用函数 nt.from_nx 转换我已经从 Networkx 准备好的网络图
我正在尝试使用 pyvis 库使用函数 nt.from_nx image
转换我已经准备好的来自( Networkx )的网络图我的代码:
strong_G (graph object)
from pyvis.network import Network
import networkx as nx
nx_graph = strong_G
nt = Network("500px","500px")
# populates the nodes and edges data structures
nt.from_nx(nx_graph)
nt.show("nx.html")
这是库中显示的示例
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,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")
关于如何解决它的任何想法?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。