liveBook · Manning

COO format

As explained in Graph Neural Networks in Action

COO format represents sparse data as collections of coordinates and corresponding values for nonzero entries.

COO (coordinate) format stores sparse data by recording the coordinates and values of nonzero entries. For a graph, it represents a sparse adjacency matrix without allocating storage for every zero. section 7.5

Use COO representation when graph connectivity is sparse:

  • Store only nonzero adjacency entries, reducing memory use when few vertices are connected. section 7.5
  • Expect potentially slower computation than dense representation for particular tasks. section 7.5
  • Convert dense adjacency matrices or edge indexes with PyG's ToSparseTensor or manually through PyTorch and SciPy sparse APIs. section 7.5
torch_geometric.transforms import ToSparseTensor

dataset = YourDataset(transform=ToSparseTensor())

Apply ToSparseTensor as a dataset transform to construct a COO-based sparse adjacency representation. section 7.5

How Graph Neural Networks in Action covers it

How deep it goes
Defines stored coordinates and values, compares memory and computation, and names PyG conversion paths without detailing COO internals.
Examples
Uses dense adjacency conversion and a ToSparseTensor dataset transform as implementation examples.
What it assumes
Assumes familiarity with adjacency matrices and distinguishes sparse graphs from dense graphs through nonzero density.
What you can do after
Apply via PyTorch Geometric's ToSparseTensor or manual PyTorch and SciPy conversions.
How it connects
Connects sparse representation with adjacency matrices, dense representation, node features, PyTorch, SciPy, and PyTorch Geometric.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Graph Neural Networks in Action. The section links point to the parts of the book it draws on.