# Interpreting output of igraph's fastgreedy.community clustering method

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).

• @user1396: many thanks! I was thinking I had to do this 'by hand'. : ) I ran community.to.membership(ag, z$merges, steps=12) on the output of running fastgreedy.community() with the graph provided as an example in the docs and the output was$membership [1] 2 2 2 2 2 0 0 0 0 0 1 1 1 1 1 $csize [1] 5 5 5 I am confused by the repeated values in the$membership vector. How should I read them? I thought this would contain the vertice names. many thanks! – laramichaels Sep 23 '10 at 0:41