How DGL process the edges info/adjacency matrix in a forward pass

Hello, I am having a hard time understanding a little bit the notations of DGL. Initially, the edges information are in a form of (node index, node linked to). For instance, we have ‘h’ as the embeddings gotten in the model. Initial H is equal to the node features. Then in normal syntax we have a propagation step through the Adjacency matrix = > 'Z = (Ahat H \theta) with A_hat following a symmetric normalization. In general notations we first multiply H by weights and then adding features from neighboring nodes v_j \in N(i) and updating features of node v_i. So, the gcn_msg function gathers the info from features from all neighboring nodes by selecting the node index and getting all the connected nodes data. And then gcn_Reduces does the Aggregation to finally self.nodes update in the memory the new “data” for all nodes?

def message_func(edges):
return {‘m’: edges.src[‘h’]}

def forward(self, h):
if self.dropout:
h = self.dropout(h)
self.g.ndata[‘h’] =, self.weight)
self.g.update_all(gcn_msg, gcn_reduce, self.node_update)
h = self.g.ndata.pop(‘h’)
return h

Thank you in advance for all your time and willingness to help.

I think your understanding is correct. Meanwhile, this seems to be from a quite old example/tutorial. Which one are you looking at?

It is indeed an old tutorial and I do not recall where I found it but I wanted to understand what the message function and reduce function was doing. Now I have it clearer. I am trying to play with the structure of the graph (adjacency matrix) like augmenting to a k power or multiplying the features with the adjacency matrix to gain high frequency information. So far I got the process but without using the DGL structure from “norm”, “n”. what it is not clear to me is after I find the new “h” what parameters I have to update so that the “norm” aka (adjacency matrix) is updated as well. The implemenation of SGC is giving me a good overview: dgl/ at a2241faf47dcb8be09dc219e488831c097431c65 · dmlc/dgl · GitHub

If you want to get the graph corresponding to A^k, you can use dgl.khop_graph. After that you can re-compute the normalization weights as in GraphConv.

Thank you for the help! I got it

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