DGLHeteroGraph.prop_edges(edges_generator, message_func, reduce_func, apply_node_func=None, etype=None)[source]

Propagate messages using graph traversal by sequentially triggering send_and_recv() on edges.

The traversal order is specified by the edges_generator. It generates edge frontiers. The edge frontiers should be of valid edges type. See send() for more details.

Edges in the same frontier will be triggered together, and edges in different frontiers will be triggered according to the generating order.

  • edges_generator (generator) – The generator of edge frontiers.
  • message_func (callable) – Message function on the edges. The function should be an Edge UDF.
  • reduce_func (callable) – Reduce function on the node. The function should be a Node UDF.
  • apply_node_func (callable, optional) – Apply function on the nodes. The function should be a Node UDF. (Default: None)
  • etype (str, optional) – The edge type. Can be omitted if there is only one edge type in the graph. (Default: None)


>>> import torch
>>> import dgl
>>> import dgl.function as fn

Instantiate a heterogrph and perform multiple rounds of message passing.

>>> g = dgl.graph(([0, 1, 2, 3], [2, 3, 4, 4]), 'user', 'follows')
>>> g.nodes['user'].data['h'] = torch.tensor([[1.], [2.], [3.], [4.], [5.]])
>>> g['follows'].prop_edges([[0, 1], [2, 3]], fn.copy_src('h', 'm'),
>>>                         fn.sum('m', 'h'), etype='follows')
>>> g.nodes['user'].data['h']

See also