简体   繁体   English

python-igraph从文件创建图

[英]python-igraph create graph from file

I am trying to create a graph from a network stored in a file using the Graph.Read_Edgelist method. 我正在尝试使用Graph.Read_Edgelist方法从存储在文件中的网络创建图形。 I have the following code: 我有以下代码:

netFile = open("trades-train.txt",'r')
graph = Graph.Read_Edgelist(netFile, directed=True)

And I receive the following error: 而且我收到以下错误:

igraph._igraph.InternalError: Error at src\foreign.c:105: parsing edgelist file failed, Parse error

And this is a sample of what I have in the file: 这是我文件中的示例:

7047,1481
1163,1309
6279,2975
2975,6279

Which is basically a list of edges of my network. 这基本上是我网络的边缘列表。 Any idea why I get this error? 知道为什么我会收到此错误吗?

I can not find any extra character of things like that. 我找不到像这样的东西的任何其他特征。

Thanks 谢谢

You need to replace "," with white space. 您需要用空格替换“,”。 Apparently Graph.Read_Edgelist only understands " " as delimiter for the file. 显然Graph.Read_Edgelist仅将“”理解为文件的分隔符。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM