phanein / deepwalk

DeepWalk - Deep Learning for Graphs
http://www.perozzi.net/projects/deepwalk/
Other
2.67k stars 828 forks source link

A question about generating random walks #110

Open mkhoshdeli opened 4 years ago

mkhoshdeli commented 4 years ago

Thank you for the great code. I have a question about the way you generate the random walks. It seems that the weights of the edges do not have any effect (i.e., the nodes are selected based on a random uniform distribution). However, shouldn't random walk take into account the weights of edges when selecting the nodes?

Best, Mina

GTmac commented 4 years ago

Hi Mina,

I am sorry for the late reply! But for posterity, yeah this implementation is for unweighted graphs. It is easy to adapt DeepWalk to weighted graphs though -- as you said, you can sample the next node based on the weights of edges.

The most efficient way to achieve this is via alias sampling. See section 3.2.3 of the node2vec paper as an example: https://cs.stanford.edu/~jure/pubs/node2vec-kdd16.pdf

Best, Haochen

PuneethaPai commented 4 years ago

Hello @GTmac ,

I would like to work on this. Any help would be appreciated.

I am confused by what @mkhoshdeli and you are referring by weight. In my understanding:

Looking at the examples I see users can give edgelist, .mat, or .adjlist. Not sure if there is a way for user to pass weighted graph i.e weight for each edge.

PS: Also I was planning to use pytest for testing. Any thoughts on this?