`dst_inputs` when g.is_blcok==True

Thank the DGL team for creating such a great tool.

I have a question about the way to get dis_inputs, specifically this line:

v[:g.number_of_dst_nodes(k)] is subseting the first n entries of the input feature matrix, where n=g.number_of_dst_nodes(k) being the number of dst nodes. Unless the input feature matrix is ordered in a way that the first n entries corresponding to dst nodes, I don’t really understand why we could simply subset. Are we need to do something like v[dst_nids]?

Similar logics also applies to specific layers like https://github.com/dmlc/dgl/blob/8bbc84e04fe33a5459b85ad09e92b5a78325f214/python/dgl/nn/pytorch/conv/sageconv.py#L181

I read through the code but could not figure out how. Looking forward to your answer.

Indeed they are, if the graph is a block (i.e. g.is_block is True). This property is ensured by the to_block function, which converts a graph into a bipartite graph, with destination nodes on the “output” side and the union of source and destination nodes on the “input” side.

The implementation is in C++ function ToBlock in src/graph/transform/to_bipartite.cc.