# dgl.DGLGraph.apply_edges¶

DGLGraph.apply_edges(func='default', edges='__ALL__', inplace=False)[source]

Apply the function on the edges to update their features.

If None is provided for func, nothing will happen.

Parameters: func (callable, optional) – Apply function on the edge. The function should be an Edge UDF. edges (valid edges type, optional) – Edges on which to apply func. See send() for valid edges type. Default is all the edges. inplace (bool, optional) – If True, update will be done in place, but autograd will break.

Notes

On multigraphs, if $$u$$ and $$v$$ are specified, then all the edges between $$u$$ and $$v$$ will be updated.

Examples

Note

Here we use pytorch syntax for demo. The general idea applies to other frameworks with minor syntax change (e.g. replace torch.tensor with mxnet.ndarray).

>>> import torch as th

>>> g = dgl.DGLGraph()

>>> # Doubles the edge feature.