4.3. igraph_clusters — Calculates the (weakly or strongly) connected components in a graph.

int igraph_clusters(const igraph_t *graph, igraph_vector_t *membership, 
		    igraph_vector_t *csize, igraph_integer_t *no,
		    igraph_connectedness_t mode);

Arguments: 

graph:

The graph object to analyze.

membership:

First half of the result will be stored here. For every vertex the id of its component is given. The vector has to be preinitialized and will be resized. Alternatively this argument can be NULL, in which case it is ignored.

csize:

The second half of the result. For every component it gives its size, the order is defined by the component ids. The vector has to be preinitialized and will be resized. Alternatively this argument can be NULL, in which case it is ignored.

no:

Pointer to an integer, if not NULL then the number of clusters will be stored here.

mode:

For directed graph this specifies whether to calculate weakly or strongly connected components. Possible values: IGRAPH_WEAK, IGRAPH_STRONG. This argument is ignored for undirected graphs.

Returns: 

Error code: IGRAPH_EINVAL: invalid mode argument.

Time complexity: O(|V|+|E|), |V| and |E| are the number of vertices and edges in the graph.