Sample specific nodes from the neighbourhood, given a node in the graph


I want to sample a neighbourhood like NeighborSampler, but for a specific node N and a specific set of neighbours (node_ids). (So not randomly sampled).

frontier = dgl.node_subgraph(g, [N] + node_ids)
eid = frontier.edata[dgl.EID]
block = dgl.to_block(frontier, [N])
block.edata[dgl.EID] = eid

However, I get the following error:

/opt/dgl/src/graph/transform/ Check failed: new_dst.Ptr()[i] != -1 (-1 vs. -1) : Node 39 does not exist in rhs_nodes. Argument rhs_nodes must contain all the edge destination nodes.

It seems that node_subgraph, relabels the nodes, but when I set it to false I get:

relabel_nodes: Node subgraph only supports relabel_nodes=True

I’m using dgl version 0.9.1.

My main question is how to sample a set of neighbours for a node and make it passable to dgl.to_block

You could try dgl.sampling.sample_neighbors() function.

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