modularity              package:igraph              R Documentation

_M_o_d_u_l_a_r_i_t_y _o_f _a _c_o_m_m_u_n_i_t_y _s_t_r_u_c_t_u_r_e _o_f _a _g_r_a_p_h

_D_e_s_c_r_i_p_t_i_o_n:

     This function calculates how modular is a given division of a
     graph into subgraphs.

_U_s_a_g_e:

     modularity(graph, membership, weights = NULL)

_A_r_g_u_m_e_n_t_s:

   graph: The input graph.

membership: Numeric vector, for each vertex it gives its community. The
          communities are numbered from zero. 

 weights: If not 'NULL' then a numeric vector giving edge weights.

_D_e_t_a_i_l_s:

     The modularity of a graph with respect to some division (or vertex
     types) measures how good the division is, or how separated are the
      different vertex types from each other. It defined as 

           Q=1/(2m) * sum(Aij-ki*kj/(2m)delta(ci,cj),i,j),

     here m is the number of edges, Aij is the element of the A
     adjacency matrix  in row i and column j, ki is the degree of i, kj
     is the degree of j, ci is the type (or component) of i, cj that of
     j, the sum goes over all i and j pairs of vertices, and delta(x,y)
     is 1 if x=y and 0 otherwise.

     If edge weights are given, then these are considered as the
     element of the A adjacency matrix, and ki is the sum of weights of
     adjacent edges for vertex i.

_V_a_l_u_e:

     A numeric scalar, the modularity score of the given configuration.

_A_u_t_h_o_r(_s):

     Gabor Csardi csardi@rmki.kfki.hu

_R_e_f_e_r_e_n_c_e_s:

     MEJ Newman and M Girvan: Finding and evaluating community
     structure in networks. Physical Review E 69 026113, 2004.

_S_e_e _A_l_s_o:

     'walktrap.community', 'edge.betweenness.community',
     'fastgreedy.community', 'spinglass.community' for various
     community detection methods.

_E_x_a_m_p_l_e_s:

     g <- graph.full(5) %du% graph.full(5) %du% graph.full(5)
     g <- add.edges(g, c(0,5, 0,10, 5, 10))
     wtc <- walktrap.community(g)
     memb <- community.to.membership(g, wtc$merges, steps=12)
     modularity(g, memb$membership)

