#include #include int main(void) { FILE *fp; fp = fopen("karate.txt", "r"); igraph_t graph; igraph_real_t modularity; igraph_read_graph_edgelist(&graph, fp, 0, 0); igraph_matrix_t merges; igraph_vector_t result; igraph_vector_t membership; igraph_vector_init( &result, 0); igraph_vector_init( &membership, 0); igraph_matrix_init( &merges, 0,0); int nodes; nodes = 34; int i; // igraph_community_edge_betweenness(&graph, &result, NULL, &merges, NULL, 0); // <--- to do eb comm. detection igraph_community_fastgreedy(&graph, NULL, &merges, NULL); for (i=1 ;i< nodes;i++) { igraph_community_to_membership(&merges, nodes, i, &membership, NULL); // <-- should construct community vector igraph_modularity(&graph ,&membership, &modularity, NULL); // <-- and find modularity printf( "%f\n", modularity ) ; } igraph_destroy(&graph); return 0; }