Node order after RGCN computation on heterogeneous graph

Hi, all!
I’m trying to use RGCN on heterogeneous graph. I’m confused about the node order after RGCN computation.

Here is what I’m doing:

  1. I sample 2-hop neighbors of 2 given nodes (node1, node2 in order, and they have the same node type) with function dgl.dataloading.MultiLayerNeighborSampler([50, 50]).
  2. Then the blocks return from the neighbor sampler are fed into a 2-layer RGCN.
  3. Finally, I get the result of a dict, for example, {“ntype1” : tensor([[ 0.1973, 0.1284, -0.2143, 0.8796],[ 0.0146, -0.0139, -0.0010, 0.0028]])}.

So my question is, dose dgl guarantee that the first row of the matrix is the computation result of node1 and the second row is the computation result of node2?

If so, dose this rule still hold if I collect a group of nodes with different node types?

Code for reference:

subgraph_sampler = dgl.dataloading.MultiLayerNeighborSampler([50, 50])
graph_blocks = subgraph_sampler.sample_blocks(hetero_graph, {"ntype": [node1, node2]})
result_dict = model(graph_blocks , graph_blocks[0].srcdata['feature'])
# result_dict {'ntype': tensor([[ 0.1973,  0.1284, -0.2143,  0.8796],
#        [ 0.0146, -0.0139, -0.0010,  0.0028]], grad_fn=<SumBackward1>)}

Thanks in advance!

In your case, the first row of the matrix is the computation result of node1 and the second row is the result of node 2 and so on.
If you have multiple node types you can get it through result_dict[‘ntype1’] to get features for nodes under ntype1 and result_dict[‘ntype2’] to get features for nodes under ntype2.

Thanks for your reply!