Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
嗨,我如何读取/导入图形,存储在文本文件中mygraph.txt,并以边列表的形式写入(第 1 列:节点u,第 2 列:节点v)
mygraph.txt
u
v
1 2 1 3 1 4 2 5 3 4 3 5
进入Networkit?
我猜是这样的?
G = readGraph("/home/JohnRambo/Documents/myFolder/mygraph.txt")
PS:经过几次尝试,我还不能让它工作......我在networkit指南中没有找到明确的说明!
我找到了这个解决方案:
from networkit import * import networkit as nk G = nk.readGraph("/home/JohnRambo/Documents/myFolder/mygraph.txt",nk.Format.SNAP) print(G.numberOfNodes(), G.numberOfEdges())
输出:
5 6