scipy.sparse
lil_matrix.
diagonal
Returns the main diagonal of the matrix
scipy.sparse.lil_matrix.count_nonzero
scipy.sparse.lil_matrix.dot