NodeShuffle

class dgl.transforms.NodeShuffle[source]

Bases: dgl.transforms.module.BaseTransform

Randomly shuffle the nodes.

Example

>>> import dgl
>>> import torch
>>> from dgl import NodeShuffle
>>> transform = NodeShuffle()
>>> g = dgl.graph(([0, 1], [1, 2]))
>>> g.ndata['h1'] = torch.tensor([[1., 2.], [3., 4.], [5., 6.]])
>>> g.ndata['h2'] = torch.tensor([[7., 8.], [9., 10.], [11., 12.]])
>>> g = transform(g)
>>> print(g.ndata['h1'])
tensor([[5., 6.],
        [3., 4.],
        [1., 2.]])
>>> print(g.ndata['h2'])
tensor([[11., 12.],
        [ 9., 10.],
        [ 7.,  8.]])