2.4 Apply Edge Weight In Message Passing¶
Save the weight as edge feature.
Multiply the edge feature by src node feature in message function.
import dgl.function as fn # Suppose eweight is a tensor of shape (E, *), where E is the number of edges. graph.edata['a'] = eweight graph.update_all(fn.u_mul_e('ft', 'a', 'm'), fn.sum('m', 'ft'))
The example above uses eweight as the edge weight. The edge weight should usually be a scalar.