我正在尝试使用 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, 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")
关于如何解决它的任何想法?