aditya-grover / node2vec

http://snap.stanford.edu/node2vec/
MIT License
2.6k stars 912 forks source link

Help with creating embeddings from networkx graph edgelist #66

Closed anjalibhavan closed 5 years ago

anjalibhavan commented 5 years ago

I'm trying to create embeddings for an edge list I have using networkx and node2vec. My edge list looks as follows:

1 2
1 6
...
450 230
...
601 602 

It's an unweighted undirected graph, basically, and is stored in a text file. I'm trying to convert this to a graph using: nx_G = nx.read_edgelist(args.input, delimiter=' ', create_using=nx.DiGraph())

The read_edgelist functions reads the nodes properly, and embeddings are being created. However, in the embeddings file, the nodes aren't numbered 1 through 606 (these are the node values in my edge list): instead, they are 14 in number, with digits from 0-9 and some special characters as the node values instead for which the embeddings have been created. That is, instead of reading an entire number of more than one digit (say 29) as a single node, it is simply reading 2 and calculating embeddings for it. I do not understand why this is happening and would appreciate some insight. Is there any condition that the nodes must have single-digit or single-character names?

anjalibhavan commented 5 years ago

I solved this by commenting out the following line in main.py: walks = [map(str, walk) for walk in walks]