Compose

class dgl.transforms.Compose(transforms)[source]

Bases: BaseTransform

Create a transform composed of multiple transforms in sequence.

Parameters:

transforms (list of Callable) – A list of transform objects to apply in order. A transform object should inherit BaseTransform and implement __call__().

Example

>>> import dgl
>>> from dgl import transforms as T
>>> g = dgl.graph(([0, 0], [1, 1]))
>>> transform = T.Compose([T.ToSimple(), T.AddReverse()])
>>> new_g = transform(g)
>>> print(new_g.edges())
(tensor([0, 1]), tensor([1, 0]))