aditya-grover / node2vec

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

Graph with weight #55

Open Sean0719 opened 5 years ago

Sean0719 commented 5 years ago

Hi,

How can I use this work to embed the graph with weight (such as the distance between tow nodes), could you please give some suggestions? Thanks in advance.

DozenCoder commented 5 years ago

@Sean0719 If you use python version, just with --weighted.
Such as python node2vec/src/main.py --input xx.edgelist --output xx.embeddings --dimensions 100 --walk-length 100 --num-walks 50 --window-size 30 --p 0.25 --q 4 --iter 5 --weighted
and your edgelist file should like:

780 725 1
266 351 2
285 132 1
328 748 7
275 487 1
259 938 2
.....
Sean0719 commented 5 years ago

Okay, thank you very much.

Sean0719 commented 5 years ago

Hi, One more question, for the weighted node, the weight is used to compute the probability between two node? Thank you very much.

DozenCoder commented 5 years ago

Hi, One more question, for the weighted node, the weight is used to compute the probability between two node? Thank you very much.

By reading the source code:https://github.com/aditya-grover/node2vec/blob/master/src/node2vec.py#L66, https://github.com/aditya-grover/node2vec/blob/master/src/node2vec.py#L85 , the weight should be used to compute the probability between two node.

sonia0028 commented 4 years ago

@Sean0719 If you use python version, just with --weighted. Such as python node2vec/src/main.py --input xx.edgelist --output xx.embeddings --dimensions 100 --walk-length 100 --num-walks 50 --window-size 30 --p 0.25 --q 4 --iter 5 --weighted and your edgelist file should like:

780 725 1
266 351 2
285 132 1
328 748 7
275 487 1
259 938 2
.....

Hello I am trying to run node2 vec how can I use this weight