How can we effectively sample a subgraph with K neighbors?

How can we effectively sample the subgraph of K neighbors without changing the original node number? (If the number of neighbors is less than k, you can repeat sampling)
But for DGL graphs, the node numbers must be continuous.

You can try using edge_subgraph with preserve_nodes options. https://docs.dgl.ai/generated/dgl.DGLHeteroGraph.edge_subgraph.html

Thank you!but how to get topk nodes according to the edge weight?
(If the number of neighbors is less than k, you can repeat sampling)

How do you select nodes by edge weight?

就是把根据权重选择最大的k个邻居节点,邻居数小于k的时候可以重复选择

Question translation: Select K neighbors with the largest edge weights connecting in between. If the number of available neighbors is less than K, we repeatedly pick some of them.

回答:
我们确实有根据权重选择的函数dgl.sampling.select_topk,不过它在邻居数小于k的时候只会选择所有邻居,并不会重复选择。如果确实要重复选择,您可能需要考虑一下如何重复地选择这些邻居,并自己实现。
当然,如果您只做一次这个变换,(在DGL之外)对原图做一下预处理总是可行的。

Answer:
We do have a method dgl.sampling.select_topk that selects the neighbors by largest edge weights. However, it does not repeatedly select some of the neighbors if the number of available neighbors is less than k.
Of course, if you only do this transformation once, you can always preprocess your original graph (outside DGL).

Thank you!
Is this a new API? Not found in the documentation.
When will the 0.43 document to be updated? Looking forward to it.