> I have read the reference guide and if I understand correctly I need to > call a third method between the two, igraph_community_to_membership, to > map the dendrogram matrix populated by igraph_community_edge_betweenness > into a vector of cluster assignments for the nodes.
Yes, you are right. igraph_community_edge_betweenness produces a dendrogram (encoded in an igraph_matrix_t), and you need a "flat" community assignment in order to use the modularity function, so you have to cut the dendrogram somewhere to map the vertices into a membership vector. > long int rows = igraph_matrix_nrow(&merges);//leaves of the dendrogram Nope; the number of rows in the merges matrix is in fact really the number of _merges_ performed during the algorithm. Considering the fact that your graph has N vertices, and in the end the dendrogram ends up with a single community, the algorithm must have had performed N-1 merges (since each merge joins two groups). Therefore, igraph_matrix_nrow(&merges) will be N-1, and the proper number of leaves in the dendrogram is simply given by igraph_vcount(&graph). > Firstly is my way of > getting the rows parameter from the matrix correct? See above; you simply need igraph_vcount(&graph). > Secondly, how to > obtain the steps argument? Any help would be greatly appreciated. Well, that's up to you ;) The dendrogram starts with N communities (each vertex in its own community). If you take 1 step, then two communities will be merged, yielding N-1 communities. If you take another step, you get N-2 communities, and so on. If you need, say, 4 communities in the end, you must perform N-4 merges. I guess that you would like to select the "optimal" number of communities with the modularity function, i.e. you want to take the division which yields the highest modularity. In this case, you can simply try steps=1, steps=2, steps=3, …, steps=N-1, calculate the modularity score for each, and keep the best one. -- T. _______________________________________________ igraph-help mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/igraph-help
