I've got some issues in creating a graph from a dataset where the nodes are labeled with a random numbering. So, a short example of my dataset could be:
In this case a graph of 26 vertices and 11 edges is created. How may I load a 'correct' graph? Here the code I'm using on Python in order to load the graph from a .txt file:
######start#### import string
from igraph import *
edgelist, 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,' ') edgelist.append((int(split_line[0][0:]), int(split_line[1][0:])))
SP_data.close() A=len(edgelist) g = Graph(A,edgelist) # directed=False is the default
######end######
I would also like that each vertex will get the same label that it has got on the .txt file. Is that possible through the Igraph Python version?