NeighborSampler cannot sample all the neighbors


Thanks for the sharing of the library. I am puzzled when I use the NeighborSampler on huge graph.

If I set the batch size as 1, and set the expand_factor as 30, and neighbor_type as ‘in’, I expect that all the neighbors should be extracted if the node’s in-degree is less than 30. However, I get the following results:
Id , Sample size, predecessors generated by function predecessors(), in-degree

We can get that for some nodes, the number of sampled neighbors is smaller than the in-degree although the expand_factor is set as 30 (larger than the number of neighbors).

Can you check this or give an explanation about this phenomenon?

Thanks for your time and help.

This is weird. Just to be sure, can I take a look at all the arguments you use for NeighborSampler?

Thanks for your time. By the way, how to set the random seed to guide the sampling process in DGL, I set the random seeds for (pytorch, numpy and python) as follows.
** torch.manual_seed(1234)**
** random.seed(1234)**
However, I still cannot reproduce the same results.

Whether the sampling procedure depends on ‘non-python’ environment? How to guarantee the reproductivity?

The sampling implementation is in C++ and currently we cannot fix it with a random seed.

The ability to set seed for C++ random sampler is implemented in this PR.

If you could provide your testing script, we can test it locally. Thanks