简体   繁体   中英

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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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