【问题标题】:How to import/read a graph, written as edges list and saved as a txt file, into Networkit?如何将图形导入/读取,写入边列表并保存为 txt 文件到 Networkit?
【发布时间】:2021-07-29 15:21:55
【问题描述】:

嗨,我如何读取/导入图形,存储在文本文件 mygraph.txt 中,并以边列表的形式写入(第 1 列:节点 u,第 2 列:节点 @987654323 @)

1 2  
1 3  
1 4 
2 5 
3 4 
3 5 

进入 Networkit?

我猜是这样的?

G = readGraph("/home/JohnRambo/Documents/myFolder/mygraph.txt")

P.S.:经过几次尝试,我仍然无法使其工作......我在 networkit 指南中没有找到明确的说明!

【问题讨论】:

    标签: python graph networkit


    【解决方案1】:

    我找到了这个解决方案:

    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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-05
      • 1970-01-01
      相关资源
      最近更新 更多