How to aggregate message on different edge types?

Dear all,

I wonder how to aggregate message from neighbor nodes of different node types. For example, ‘developer develops game’ and ‘user plays game’. I want to update node ‘game’ by sum of message from its neighbor nodes ‘developer’ and ‘user’.

I am using"g[‘develops’].update_all( fn.copy_src(‘h’, ‘m’), fn.sum(‘m’, ‘x’), etype=‘develops’ ); g[‘plays’].update_all( fn.copy_src(‘h’, ‘m’), fn.sum(‘m’, ‘x’), etype=‘plays’ ) ". This code will first aggregate node 'developer’s information to ‘game’ and save the information in ‘x’, then aggregate node 'user’s information to ‘game’ and OVERWRITE the ‘x’ generated in previous stage. So my question is how to avoid the overwriting but sum up the two types of neighbor nodes?

The graph looks like below
g = dgl.heterograph({
(‘user’, ‘follows’, ‘user’): ([0, 1, 2], [1, 2, 2]),
(‘developer’, ‘develops’, ‘game’): ([0, 1], [0, 1]),
(‘user’, ‘plays’, ‘game’): ([0, 1], [0, 1])

Many thanks!!

You can do one of the following:

  1. Separately replace 'x' by 'x1' and 'x2'for ‘develops’ and ‘plays’ , and then add them up.
  2. Use multi_update_all
1 Like

Thanks Mufei. The multi_update_all works like a gem.