dgl.slice_batchΒΆ
-
dgl.
slice_batch
(g, gid, store_ids=False)[source]ΒΆ Get a particular graph from a batch of graphs.
- Parameters
- Returns
Retrieved graph.
- Return type
Examples
The following example uses PyTorch backend.
>>> import dgl >>> import torch
Create a batched graph.
>>> g1 = dgl.graph(([0, 1], [2, 3])) >>> g2 = dgl.graph(([1], [2])) >>> bg = dgl.batch([g1, g2])
Get the second component graph.
>>> g = dgl.slice_batch(bg, 1) >>> print(g) Graph(num_nodes=3, num_edges=1, ndata_schemes={} edata_schemes={})