3.12. Resizing operations

3.12.1. igraph_matrix_resize — Resizes a matrix.
3.12.2. igraph_matrix_add_rows — Adds rows to a matrix.
3.12.3. igraph_matrix_add_cols — Adds columns to a matrix.
3.12.4. igraph_matrix_remove_row — Remove a row
3.12.5. igraph_matrix_remove_col — Removes a column from a matrix.

3.12.1. igraph_matrix_resize — Resizes a matrix.

int igraph_matrix_resize(igraph_matrix_t *m, long int nrow, long int ncol);

This function resizes a matrix by adding more elements to it. The matrix contains arbitrary data after resizing it. Ie. after calling this function you cannot expect that element (i,j) in the matrix remains the same as before.

Arguments: 

m:

Pointer to an already initialized matrix object.

nrow:

The number of rows in the resized matrix.

ncol:

The number of columns in the resized matrix.

Returns: 

Error code.

Time complexity: O(1) if the matrix gets smaller, usually O(n) if it gets larger, n is the number of elements in the resized matrix.

3.12.2. igraph_matrix_add_rows — Adds rows to a matrix.

int igraph_matrix_add_rows(igraph_matrix_t *m, long int n);

Arguments: 

m:

The matrix object.

n:

The number of rows to add.

Returns: 

Error code, IGRAPH_ENOMEM if there isn't enough memory for the operation.

Time complexity: linear with the number of elements of the new, resized, matrix.

3.12.3. igraph_matrix_add_cols — Adds columns to a matrix.

int igraph_matrix_add_cols(igraph_matrix_t *m, long int n);

Arguments: 

m:

The matrix object.

n:

The number of columns to add.

Returns: 

Error code, IGRAPH_ENOMEM if there is not enough memory to perform the operation.

Time complexity: linear with the number of elements of the new, resized matrix.

3.12.4. igraph_matrix_remove_row — Remove a row

int igraph_matrix_remove_row(igraph_matrix_t *m, long int row);

A row is removed from the matrix.

Arguments: 

m:

The input matrix.

row:

The index of the row to remove.

Returns: 

Error code.

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

3.12.5. igraph_matrix_remove_col — Removes a column from a matrix.

int igraph_matrix_remove_col(igraph_matrix_t *m, long int col);

Arguments: 

m:

The matrix object.

col:

The column to remove.

Returns: 

Error code, always returns with success.

Time complexity: linear with the number of elements of the new, resized matrix.