Node-aware Aggregation

Hi

Thank you for the wonderful DGL. Now I would like to implement a function that achieves node-aware aggregation. Specifically, at a specific layer, for different center nodes i, I would like to aggregate its neighbors of n_i hop along a given path (like the shortest path) in one shot, where n_i is different for different center nodes in a graph. I wonder if it is possible to implement this function with DGL. I will greatly appreciate it if anyone could help. Thank you!

Best,
Yongcheng

What do you mean by “one shot” here?

Hi @mufeili

Thank you for the response! I appreciate it. From what I know, one way to aggregate the information from n-hop neighbors is to conduct g.update for n times. However, in my case, different nodes has a different hop number to aggregate. So simply conducting g.update for n times may not be feasible.

Best,
Yongcheng

I think you can still do that. For example, you can do something as follows.

import torch

out = torch.zeros(num_nodes, out_size)
# input node features
h = ...
for i in range(num_gnn_layers):
    h = model(g, h)
    # i_hop_nodes are IDs of the nodes for which you only want to aggregate n-hop neighbors
    out[i_hop_nodes] = h[i_hop_nodes]
1 Like

Hi @mufeili

Thanks! I got it!

Best,

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.