# dgl.DGLGraph.group_apply_edges¶

DGLGraph.group_apply_edges(group_by, func, edges='__ALL__', inplace=False)[source]
Group the edges by nodes and apply the function on the grouped edges to
update their features.
Parameters: group_by (str) – Specify how to group edges. Expected to be either ‘src’ or ‘dst’ func (callable) – Apply function on the edge. The function should be an Edge UDF. The input of Edge UDF should be (bucket_size, degrees, *feature_shape), and return the dict with values of the same shapes. edges (valid edges type, optional) – Edges on which to group and 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()

>>> # Softmax over the out edges of each node