Project 9: Routes Matrix Converter
Scientific Computing
Builds on these lessons
Current Task
Objective
CSR (row-optimized) and CSC (column-optimized) are two sparse formats suited to different access patterns — .tocsc() converts between them.
Task: build a sparse routes matrix and convert it to CSC format, then print it.
index.py
from scipy.sparse import csr_matrix
import numpy as np
routes = csr_matrix(np.array([[0, 5, 0], [3, 0, 0], [0, 0, 8]]))
routes_csc = routes.tocsc()
print(routes_csc)
* Hint: Correct characters turn green, incorrect ones turn red.
Live Preview
🖼️
Verify your code to see the preview