Created
August 11, 2009 22:02
-
-
Save mjbommar/166149 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Calculate merge matrix | |
igraph_community_edge_betweenness(&graph, &result, NULL, &M, NULL, IGRAPH_DIRECTED); | |
// Initialize max modularity | |
maxmod = 0.0; | |
// Determine max number of steps to merge | |
maxsteps = igraph_matrix_nrow(&M) < igraph_vcount(&graph) - 1) ? igraph_matrix_nrow(&M) : igraph_vcount(&graph) - 1; | |
// Compare merge modularities and keep only the best | |
for (steps=1; steps < maxsteps; steps++) { | |
igraph_community_to_membership(&M, igraph_vcount(&graph), steps, &membership, 0); | |
igraph_modularity(&graph, &membership, &modularity, 0); | |
if (modularity > maxmod) { | |
igraph_vector_update(&maxmembership, &membership); | |
maxmod = modularity; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment