3.11. Searching for elements

3.11.1. igraph_matrix_contains — Search for an element.
3.11.2. igraph_matrix_search — Search from a given position.

3.11.1. igraph_matrix_contains — Search for an element.

igraph_bool_t igraph_matrix_contains(const igraph_matrix_t *m,
					       igraph_real_t e);

Search for the given element in the matrix.

Arguments: 

m:

The input matrix.

e:

The element to search for.

Returns: 

Boolean, TRUE if the matrix contains e, FALSE otherwise.

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

3.11.2. igraph_matrix_search — Search from a given position.

igraph_bool_t igraph_matrix_search(const igraph_matrix_t *m,
					     long int from, igraph_real_t what, 
					     long int *pos, 
					     long int *row, long int *col);

Search for an element in a matrix and start the search from the given position. The search is performed columnwise.

Arguments: 

m:

The input matrix.

from:

The position to search from, the positions are enumerated columnwise.

what:

The element to search for.

pos:

Pointer to a long int. If the element is found, then this is set to the position of its first appearance.

row:

Pointer to a long int. If the element is found, then this is set to its row index.

col:

Pointer to a long int. If the element is found, then this is set to its column index.

Returns: 

Boolean, TRUE if the element is found, FALSE otherwise.

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