liveBook · Manning

COO format

As explained in Build AI Drug Discovery Pipelines

COO format is a sparse matrix representation that stores the coordinates of nonzero entries.

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

How Build AI Drug Discovery Pipelines covers it

How deep it goes
Defines the 2×num_edges layout, explains sparse-memory advantages, and stops short of lower-level kernel implementation.
Examples
Uses a 20-atom molecule with 78 features per atom and 25 bidirectional bonds plus self-loops.
What you can do after
Apply it via PyTorch Geometric by constructing edge_index tensors inside Data objects.
How it connects
Connects sparse matrices, adjacency matrices, graph neural networks, PyTorch Geometric, node features, and edge indices.

Also explained in

Compare how 2 books explain COO format →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build AI Drug Discovery Pipelines. The section links point to the parts of the book it draws on.