COO (Coordinate) format stores sparse graph connectivity as pairs of node coordinates instead of a mostly empty adjacency matrix. In PyTorch Geometric, edge_index is a 2×num_edges tensor: its first row contains source nodes and its second row contains destination nodes. This representation keeps molecular graph data compact and lets graph neural networks exploit sparse computation. section 11.5.5
For a molecular graph, COO connectivity works as follows:
- Represent each bond as a source–destination pair. section 11.5.5
- Store reverse pairs when bonds are bidirectional, and add self-loops when required. section 11.5.5
- Keep node features separately in x and prediction targets in y within a Data object. section 11.5.5
from torch_geometric.data import Data
GCNData_mol = Data(
x=torch.Tensor(features),
edge_index=torch.LongTensor(edge_index).transpose(1, 0),
y=torch.FloatTensor([affinity_value])
)Constructs a PyTorch Geometric Data object with node features, COO edge indices, and an affinity target. section 11.5.5

