【问题标题】:Multi Directed Graph in NetworkX not loadingNetworkX中的多向图未加载
【发布时间】:2020-11-01 19:29:46
【问题描述】:

我正在尝试在 NetworkX 中加载多向图,以使用给定的 txt 文件进行编程分配,但它不起作用。没有错误,但是当我绘制图表并进行快速检查以查看有多少节点/边时,两者都返回 0 - 这让我相信它只是没有将文件加载到完全图表。这是我的代码:

import networkx as nx
def answer_one():
    # Your Code Here
    G = nx.read_edgelist('email_network.txt', delimiter='\\t', data=[('time', int)], create_using=nx.MultiDiGraph())
    return G
answer_one()

这是我尝试读取的文件的一部分(email_network.txt):

#Sender Recipient   time
1   2   1262454010
1   3   1262454010
1   4   1262454010
1   5   1262454010
1   6   1262454010
1   7   1262454010
1   8   1262454010
1   9   1262454010
1   10  1262454010
1   11  1262454010
1   12  1262454010
1   13  1262454010
1   14  1262454010
1   15  1262454010

我查看了Python Reading from a file to create a weighted directed graph using networkxhttps://networkx.org/documentation/networkx-1.9/reference/generated/networkx.readwrite.edgelist.read_edgelist.html?highlight=read_edgelist 试图找出我使用错误的参数,但它们都没有那么有用。

谁能帮我弄清楚我做错了什么/如何正确加载文件?谢谢你:)

【问题讨论】:

    标签: python networking data-science networkx


    【解决方案1】:

    更新:我找到了,它是 G = nx.read_edgelist('email_network.txt', edgetype=int, data=(('weight', int),), create_using=nx.MultiDiGraph())

    【讨论】:

      猜你喜欢
      • 2019-04-01
      • 2021-05-05
      • 1970-01-01
      • 2013-03-05
      • 1970-01-01
      • 2017-06-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多