I'm trying to start using Igraph python version. I'm getting some troubles both because i'm a newbye programmer and Ican't find a really good user guide like those written for Igraph C version.
Anyway, I have a .txt file in which there is stored my network. For each row I've got something like:
node1 node2 weight
I'm trying to build a graph using Igraph. The code I'm using is this:
[code] from igraph import * import string edges= weights= SP_data=open("test_graph.dat",'r') SP_data.readline() while 1: line=SP_data.readline() if not line:
break split_line=string.split(line,' ') edges.append((split_line[0:],split_line[0:])) weights.append(float(split_line[0:-1])) A=int(len(edges)) g=Graph(A,edges,directed=False)
g.vs["weight"]=weights print edge_attributes() SP_data.close() [/code]
but it doesn't work ... I get this message error:
"Traceback (most recent call last): File "getting_net.py", line 17, in ?
g=Graph(A,edges,directed=False) TypeError: List elements must be non-negative integer pairs"
If in the wrong line I write the exact number of edge (instead of write the variable A) I get the same error message.