Clarification on understanding the node and edge index

Viewed 804

By accessing the data object's properties, how would I know which node feature belongs to what node? If I understand it correctly data.x holds the node features. By running for loop below I can access the features but how would I know that if it belongs to node 0 or node 9 for an example? ​

from torch_geometric.data import Data
edge_index = torch.tensor([[0, 1, 1, 2, 1, 9],
                           [1, 0, 2, 1, 8, 1]
                           ], dtype=torch.long)
x = torch.tensor([[-5,7], [0,5], [0,9], [10,9]], dtype=torch.float)
​
data = Data(x=x, edge_index=edge_index)
​
for item in range(0, data.x.shape[0]):
    print(item, data.x[item], data.edge_index.t()[item])
1 Answers

This example has layman's way of understanding pyG dataformat:

https://medium.com/stanford-cs224w/fraud-detection-with-gat-edac49bda1a0
Related