With the help of several people in this community I have been wetting my feet in clustering some social network data using igraph's implementation of modularity-based clustering.

I am having some trouble interpreting the output of this routine and how to use it to generate lists of members of each community detected.

This routine outputs a two-column matrix and a list of modularity values. From the docs:

merges: A matrix with two column, this

represents a dendogram and contains

all the merges the algorithm

performed. Each line is one merge and

it is given by the ids of the two

communities merged. The community ids

are integer numbers starting from zero

and the communities between zero and

the number of vertices (N) minus one

belong to individual vertices. The

first line of the matrix gives the

first merge, this merge creates

community N, the number of vertices,

the second merge creates community

N+1, etc.modularity: A numeric vector

containing the modularity value of the

community structure after performing

every merge.

Working with this explanation and looking at the example at the bottom of the man page, I think the communities in this graph are

`1st community: 0 1 2 3 4 2nd community: 10 11 12 13 14 3rd community: 5 6 7 8 9 `

Can someone who has used this method before confirm whether the right approach produces this result? I have basically (i) ignored the last two merges and (ii) gone over each row in the 'merges' matrix, combining each pair of vertices into a set while watching out for vertex values that are larger than the number of vertices (and therefore refer to another row in the 'merges' matrix).

**Contents**hide

#### Best Answer

The function which is used for this purpose: community.to.membership(graph, merges, steps, membership=TRUE, csize=TRUE) this can be used to extract membership based on the fastgreedy.community function results. You have to provide number of steps – how many merges should be performed. The optimal number of steps(merges) is the one which produce the maximal modularity.