Skip to main content

Module csr

Module csr 

Source
Expand description

Compressed Sparse Row (CSR) matrix format.

CSR is an efficient format for sparse matrices/graphs that enables:

  • O(1) access to row start/end positions
  • O(degree) iteration over neighbors
  • Cache-friendly sequential access patterns

Memory layout:

  • row_ptr[i] = starting index in col_idx for row i
  • col_idx[row_ptr[i]..row_ptr[i+1]] = column indices (neighbors) of row i
  • values (optional) = edge weights

Structsยง

CsrMatrix
Compressed Sparse Row matrix for graph adjacency.
CsrMatrixBuilder
Builder for CSR matrices.