icommunity             package:inetwork             R Documentation

_I_d_e_n_t_i_f_i_c_a_t_i_o_n _o_f _C_o_m_m_u_n_i_t_i_e_s _o_r _M_o_d_u_l_e_s _i_n _a _N_e_t_w_o_r_k

_D_e_s_c_r_i_p_t_i_o_n:

     Given a network represented by an adjacency matrix, the function
     returns the communities or modules in the network. Community
     detection is an optimization problem which is achieved by the
     leading eigenvector of the so-called modularity matrix.

_U_s_a_g_e:

     icommunity(A, nodes = NULL, partite = FALSE)

_A_r_g_u_m_e_n_t_s:

       A: a symmetric adjacency matrix with elements 0's or 1's
          representing the network 

   nodes: a vector of character strings for the labels of the vertices 

 partite: a logical variable indicating whether within- or
          between-community edge densities are maximized in network
          partitioning for community identification 

_D_e_t_a_i_l_s:

     Networks or graphs are represented by the so-called adjacency
     matrices whose elements are either zeros or ones. A one (zero) at
     element ij indicates that vertices i and j in the network are
     (not) connected by an edge. The edges are undirected. The input
     adjacency matrix should therefore be symmetric. If the character
     strings for the vertex labels are not provided, i.e. 'nodes=NULL',
     then "1", "2", "3", ..., etc will be used as labels for the
     vertices. Highly interacting vertices form a community or module.
     The algorithm in the implementation seeks to partition the network
     such that the densities of the edges within the sought communities
     are larger than the average density. This mode of community
     detection is the default 'partite=FALSE'. When 'partite' is set to
     'TRUE', the returned communities have larger between- than
     within-community edge densities.

_V_a_l_u_e:

      A : a copy of the input adjacency matrix. It is stored here for
          subsequent plotting of the network by 'inetplot' in the
          package

      Q : a measure of modularity. In the network partitioning
          algorithm, the original network is divided into two
          subnetworks. The modularity of the network gains as a result
          of the division. Each of the subnetworks is recursively
          subject to division until the modularity of the network gains
          no more. The gains in the modularity in each division are
          stored here and used in the hierarchical plotting of the
          network by 'ihierarchy' in the package 

  sizes : an integer array holding the sizes of the identified
          communities 

indivisibles : vertex labels of the identified communities 

ringleaders : the ringleadership of the vertices in their communities;
          the larger the ringleadership, the larger drop in the
          modularity if the vertex is moved out of her designated
          community to any other community 

 arrows : the horizontal and vertical bars used for the hierarchical
          plotting by 'ihierarchy' 

xcoordinates: the x-coordinates of the vertex labels for 'ihierarchy' 

ycoordinates: the y-coordinates of the vertex labels for 'ihierarchy' 

indices : matrix indices of the singlets and identified community
          members 

singlets : the vertices that are not connected to others in the network 

_N_o_t_e:

     Computing time/resource depends on the size and complexity of the
     network, and scales as O(n^2log(n)).

_A_u_t_h_o_r(_s):

     Sun-Chong Wang

_R_e_f_e_r_e_n_c_e_s:

 M.E.J. Newman, Modularity and community structure in networks, _Proc.
     Natl. Acad. Sci. U.S.A._ 103 (2006) 8577-8582

 M.E.J. Newman, Finding community structure in networks using the
     eigenvectors of matrices, _Phys. Rev. E_ 74 (2006) 036104-1-19

_S_e_e _A_l_s_o:

     'ihierarchy', 'inetplot'

_E_x_a_m_p_l_e_s:

     ## load example networks 
     data(icashflow)

     ## community identification
     cluster3 <- icommunity(cf3,labelcf3,partite=FALSE)
     ## network plotting
     inetplot(cluster3,shaft=2,circle=FALSE,theta=33,points=FALSE)

     ## poly-partite partition
     partite3 <- icommunity(cf3,labelcf3,partite=TRUE)
     ## plot the multi-partite graph
     inetplot(partite3,shaft=10,circle=FALSE,theta=33,points=FALSE)

     ## to extract the community members:
     partite3_community <- numeric()
     for (i in 1:length(partite3$sizes)) { # loop over no. of communities
         partite3_community <- c(partite3_community,rep(i,partite3$sizes[i]))
     }
     for (i in 1:length(partite3$sizes)) { 
         print(c(paste("community",as.character(i),"="),partite3$indivisibles[which(partite3_community == i)]))
     }
     ## the ringleadership scores of the nodes are extracted in the same fashion

