pyg-team / pytorch_geometric

Graph Neural Network Library for PyTorch
https://pyg.org
MIT License
21.41k stars 3.67k forks source link

how to run node2vec.py on a directed weighted graph? #3465

Open 13717630148 opened 3 years ago

13717630148 commented 3 years ago

ive got edges and coresponding weights in the following form: [(x1,y1,w1),...] where x represents the departure point,y represents the destination and w represents the weight of the edge. but now i dont know how to transform my data to replace 'data.edge_index' in node2vec.py. i dont know what form is 'data.edge_index',since im not allowed to connect the server to the Internet and i cant download it also,it seems that node2vec.py runs on undirected graph? im a junior,andwaiting for your reply!thanks

rusty1s commented 3 years ago

Currently, Node2Vec cannot handle edge weights, so you will need to convert your data to the form of a regular edge_index in PyG of shape [2, num_edges] (holding only the source and destination node pair, dropping the edge weight).

13717630148 commented 3 years ago

so the first row represents the source and the second row represents the destination? and i can repeat one edge to n times,where n equals to its weight, to create a weighted graph?

rusty1s commented 3 years ago

Indeed, weighted graphs can be simulated by replicating edges, although it comes at the expense of a higher memory consumption.