dgl.sampling

The dgl.sampling package contains operators and utilities for sampling from a graph via random walks, neighbor sampling, etc. They are typically used together with the DataLoader s in the dgl.dataloading package. The user guide Chapter 6: Stochastic Training on Large Graphs gives a holistic explanation on how different components work together.

Random walk

random_walk(g, nodes, *[, metapath, length, …])

Generate random walk traces from an array of starting nodes based on the given metapath.

pack_traces(traces, types)

Pack the padded traces returned by random_walk() into a concatenated array.

Neighbor sampling

sample_neighbors(g, nodes, fanout[, …])

Sample neighboring edges of the given nodes and return the induced subgraph.

select_topk(g, k, weight[, nodes, edge_dir, …])

Select the neighboring edges with k-largest (or k-smallest) weights of the given nodes and return the induced subgraph.

PinSAGESampler(G, ntype, other_type, …[, …])

PinSAGE-like neighbor sampler.