[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[igraph] Obtaining communities and modularity index for an undirected gr
From: |
Giuseppe G. |
Subject: |
[igraph] Obtaining communities and modularity index for an undirected graph |
Date: |
Sat, 19 May 2012 19:06:59 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux i686; rv:12.0) Gecko/20120430 Thunderbird/12.0.1 |
Hi,
I would like to partition an undirected graph into communities using the
Girvan-Newman edge betweenness method and then obtain a modularity index
for the partitioned graph. I seem to have found exactly what I need in
the following two methods:
igraph_community_edge_betweenness
igraph_modularity
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. I'm not sure if
that's correct however. So far I have
//................
igraph_vector_t result;
igraph_vector_t eb;
igraph_matrix_t merges;
igraph_vector_t bridges;
igraph_vector_t membership;
igraph_real_t modularity_index;
igraph_integer_t nodes;
igraph_integer_t steps;
igraph_vector_init(&result, 2);
igraph_vector_init(&eb, 2);
igraph_vector_init(&bridges, 2);
igraph_matrix_init(&merges, 2, 2);
igraph_community_edge_betweenness(&graph,&result,&eb,&merges,&bridges,IGRAPH_UNDIRECTED);
long int rows = igraph_matrix_nrow(&merges);//leaves of the dendrogram
igraph_community_to_membership(&merges,rows,steps,&membership,NULL);
igraph_modularity(&graph, &membership, &modularity_index, NULL);
//................
However I'm not sure about two arguments of
igraph_community_to_membership, rows, and steps. Firstly is my way of
getting the rows parameter from the matrix correct? Secondly, how to
obtain the steps argument? Any help would be greatly appreciated.
Best
Giuseppe
--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.
- [igraph] Obtaining communities and modularity index for an undirected graph,
Giuseppe G. <=