0
点赞
收藏
分享

微信扫一扫

python-字符串

凌得涂 2022-02-02 阅读 54
python

networkx与igraph之间转换

import networkx as nx
import igraph as ig
# networkx转igraph 
g = nx.karate_club_graph()
d = nx.to_pandas_edgelist(g).values
g = ig.Graph(d)
#igraph转networkx
t = [str(e[0])+" "+str(e[1]) for e in g.get_edgelist()]
f = nx.parse_adjlist(t)
print(f.nodes)
举报

相关推荐

0 条评论