Overview
Compressed Sparse Row represents each row as a contiguous slice of nonzero values. A row-pointer array marks where each row begins and ends in the value and column-index arrays.
Stores a sparse matrix by keeping nonzero values, column indices, and row offsets.
Compact metadata for implementation and discovery.
Compressed Sparse Row represents each row as a contiguous slice of nonzero values. A row-pointer array marks where each row begins and ends in the value and column-index arrays.
Quick facts
Runtime and memory behavior at a glance.
Best
O(1)
Average
O(V + E)
Worst
O(V + E)
Space
O(V + E)
Show packing row offsets and column indices into contiguous arrays on a small sparse matrix and graph storage example.
CSR is compact and fast for row traversal, but awkward for structural mutation.
What each reference supports for this entry.
Reference for compressed sparse row storage and sparse matrix access patterns.
Open sourceGood next jumps from the relationship graph, ranked for useful discovery.
Data Structures · Foundation
CSR stores sparse adjacency more compactly for indexed traversal and numerical-style graph processing.
Compare with thisData Structures · Core
CSR avoids storing zero entries, unlike dense matrix-style layouts.
Compare with thisNumerical Methods · Extended
Cuthill-McKee orderings are often used before sparse matrix work stored or processed with compressed sparse formats.
Compare with thisCSR can store static sparse graph adjacency lists in compact arrays.
CSR avoids storing zero entries, unlike dense matrix-style layouts.