Aggregation in the source node instead of destination


I have a question regarding update_all. Here from the documentation we have:

# multiply source node features with edge weights and aggregate them in destination nodes
g.update_all(fn.u_mul_e('h', 'w', 'm'), fn.max('m', 'h_max'))

how do we do if we want the aggregation to happen in the same source nodes?
so u_mul_e happens and then the ‘m’ gets aggregated and updated in the u itself (rather than v).
does it go something like this?

g.apply_nodes(fn.max('m', 'h_max'))


g.apply_nodes(fn.max('m', 'h_max'))

will not work as apply_nodes can only operate on existing node data. Assume we initially have a directed graph where some edges exist for only one direction, then there are two possibilities:

  1. Add edges for both direction and manually track the ids for reversed edges and then apply send_and_recv on them. See to_bidirected and send_and_recv.
  2. Alternatively, you can directly create a reverse of the original graph and apply update_all. See reverse and update_all.

I know your point and I think it’s nice feature to have (reduce by source node). Could you please create a RFC(Request for comment) issue at DGL github repo? We can discuss what kind of API is convenient for users there.

Thanks @mufeili and @zihao. I created the issue on the repo.