Neighbor Sampling in Heterogeneous Graphs


I was trying to sample neighbors of nodes in a heterogeneous graph using the dgl.sampling.sample_neighbors and dgl.to_block APIs in accordance with the “sample_blocks” method of the “NeighborSampler” class defined in this example. However, I run into the following error whenever I try to proceed with extracting seeds for the next block using seeds = block.srcdata[dgl.NID]:
AssertionError: srcdata is only allowed when there is only one SRC type.

Could you please help me understand how I can possibly use these APIs to sample nodes from a heterogeneous graph?

Please let me know if there are any other methods which I could make use of for the same without converting the graph to a homogeneous graph.


Hi, we have a minibatch training example for RGCN that directly work by neighbor sampling on heterogeneous graphs in

Note that this require the nightly build to work.

Please feel free to follow up. Thanks.