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")

这是库中显示的示例

(https://pyvis.readthedocs.io/en/latest/tutorial.html#example-visualizing-a-game-of-thrones-character-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,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 (将#修改为@)