PyTorch Geometric -- behaviour when dealing with node labels no in range (0, ..., N-1)

Suppose we have a graph with N nodes, but our node labels are not 0, 1, 2, …, N-1. What is the behaviour of PyTorch methods here?

Suppose I create a graph using graph = Data(edge_index=torch.LongTensor([[0, 1, 1, 2, 5, 6], [1, 0, 2, 1, 6, 5]])), and I want to pass this information to a GCN layer, does the node feature matrix I define have to have node features for 7 nodes or 5?

If it is the former, then I suppose I can just just pad these with 0’s. If it is the latter, would the output of a GCN layer still be a 5xF tensor? (assuming it is a standard GCN layer where the first dimension of the output tensor is the same as the input). If so, then would the rows still be in numerical order, i.e. the output array would be in order (0, 1, 2, 5, 6) in terms of which node the row relates to?

Finally, for whichever behaviour it is, then is the behaviour consistent across the convolutional and dense convolution layers?

1 Like