4.2.  Sparse matrix constructors and destructors.

4.2.1. igraph_spmatrix_init — Initializes a sparse matrix.
4.2.2. igraph_spmatrix_copy — Copies a sparse matrix.
4.2.3. igraph_spmatrix_destroy — Destroys a sparse matrix object.

4.2.1. igraph_spmatrix_init — Initializes a sparse matrix.

int igraph_spmatrix_init(igraph_spmatrix_t *m, long int nrow, long int ncol);

Every sparse matrix needs to be initialized before using it, this is done by calling this function. A matrix has to be destroyed if it is not needed any more, see igraph_spmatrix_destroy().

Arguments: 

m:

Pointer to a not yet initialized sparse matrix object to be initialized.

nrow:

The number of rows in the matrix.

ncol:

The number of columns in the matrix.

Returns: 

Error code.

Time complexity: operating system dependent.

4.2.2. igraph_spmatrix_copy — Copies a sparse matrix.

int igraph_spmatrix_copy(igraph_spmatrix_t *to, const igraph_spmatrix_t *from);

Creates a sparse matrix object by copying another one.

Arguments: 

to:

Pointer to an uninitialized sparse matrix object.

from:

The initialized sparse matrix object to copy.

Returns: 

Error code, IGRAPH_ENOMEM if there isn't enough memory to allocate the new sparse matrix.

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

4.2.3. igraph_spmatrix_destroy — Destroys a sparse matrix object.

void igraph_spmatrix_destroy(igraph_spmatrix_t *m);

This function frees all the memory allocated for a sparse matrix object. The destroyed object needs to be reinitialized before using it again.

Arguments: 

m:

The matrix to destroy.

Time complexity: operating system dependent.