4.4. Matrix query operations

4.4.1. igraph_spmatrix_size — The number of elements in a sparse matrix.
4.4.2. igraph_spmatrix_nrow — The number of rows in a sparse matrix.
4.4.3. igraph_spmatrix_ncol — The number of columns in a sparse matrix.
4.4.4. igraph_spmatrix_count_nonzero — The number of non-zero elements in a sparse matrix.
4.4.5. igraph_spmatrix_max — Returns the maximum element of a matrix.

4.4.1. igraph_spmatrix_size — The number of elements in a sparse matrix.

long int igraph_spmatrix_size(const igraph_spmatrix_t *m);

Arguments: 

m:

Pointer to an initialized sparse matrix object.

Returns: 

The size of the matrix.

Time complexity: O(1).

4.4.2. igraph_spmatrix_nrow — The number of rows in a sparse matrix.

long int igraph_spmatrix_nrow(const igraph_spmatrix_t *m);

Arguments: 

m:

Pointer to an initialized sparse matrix object.

Returns: 

The number of rows in the matrix.

Time complexity: O(1).

4.4.3. igraph_spmatrix_ncol — The number of columns in a sparse matrix.

long int igraph_spmatrix_ncol(const igraph_spmatrix_t *m);

Arguments: 

m:

Pointer to an initialized sparse matrix object.

Returns: 

The number of columns in the sparse matrix.

Time complexity: O(1).

4.4.4. igraph_spmatrix_count_nonzero — The number of non-zero elements in a sparse matrix.

long int igraph_spmatrix_count_nonzero(const igraph_spmatrix_t *m);

Arguments: 

m:

Pointer to an initialized sparse matrix object.

Returns: 

The size of the matrix.

Time complexity: O(1).

4.4.5. igraph_spmatrix_max — Returns the maximum element of a matrix.

igraph_real_t igraph_spmatrix_max(const igraph_spmatrix_t *m,
    igraph_real_t *ridx, igraph_real_t *cidx);

If the matrix is empty, zero is returned.

Arguments: 

m:

the matrix object.

ridx:

the row index of the maximum element if not NULL.

cidx:

the column index of the maximum element if not NULL.

Time complexity: O(n), the number of nonzero elements in the matrix.