Node2Vec Random Walk Generation with Edge Weights

Hello,
I want to use the method dgl.sampling.node2vec_random_walk and I wonder how the edge weights given by the variable prob are used in the random walk generation. The source code shows that a function _CAPI_DGLSamplingNode2vec is used to generate the random walks, but I couldn’t find this function. I would assume that the edge weights should be multiplied by either 1, 1/p or 1/q as done to calculate the unnormalized transition probabilities in the Node2vec paper ([1607.00653] node2vec: Scalable Feature Learning for Networks). But I would like to know if dgl.sampling.node2vec_random_walk indeed does that.

Thank you :slight_smile:

If you are familiar with C/C++, you can find the function definition here.

Thank you for the link! (:
Unfortunately, I am not familiar with C/C++.
In _CAPI_DGLSamplingNode2vec, another method sampling::Node2vec() is called to generate the walks.
Do you know where the random walks are finally generated and what happens with the edge weights?

The implementatinos are in dgl/node2vec_randomwalk.h at master · dmlc/dgl · GitHub.

The edge weights are only used in determining the next neighbor. Rejection sampling (i.e. p and q) is not impacted by the edge weights.

1 Like

Thank you a lot, this answered my question! :slight_smile:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.