How can I sample random neighbors from an edge list? #6814
-
Hi, I am trying to sample some random neighbors for the target nodes. I follow the document and use Is there a way I can fix it? An example and code are provided below.
Since we want the random neighbors for |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
It is important to note that neighborhood sampling will re-map the global node indices to local indices of the sampled subgraph. If you wanna restore this mapping, you can do data.n_id = torch.arange(data.num_nodes)
loader = NeighborLoader(data, ...)
batch = next(iter(loader))
edge_index = batch.n_id[batch.edge_index] |
Beta Was this translation helpful? Give feedback.
It is important to note that neighborhood sampling will re-map the global node indices to local indices of the sampled subgraph. If you wanna restore this mapping, you can do