Community structure detecting based on the leading eigenvector of the community matrix
These functions try to find densely connected subgraphs in a graph by calculating the leading non-negative eigenvector of the modularity matrix of the graph.
leading.eigenvector.community(graph, steps = -1, options = igraph.arpack.default) leading.eigenvector.community.naive(graph, steps = -1, options = igraph.arpack.default) leading.eigenvector.community.step (graph, fromhere = NULL, membership = rep(0, vcount(graph)), community = 0, options=igraph.arpack.default) community.le.to.membership(merges, steps, membership)
- The input graph. Should be undirected as the method needs a symmetric matrix.
- The number of steps to take, this is actually the number
of tries to make a step. It is not a particularly useful parameter.
community.le.to.membershipthe number of merges to produce from the supplied
- Logical constant, it defines how the algorithm tries to
find more divisions after the first division was made. If
TRUEthen it simply considers both communities as separate graphs and then creates modularity matrices for both comm
- An object returned by a previous call to
leading.eigenvector.community.step. This will serve as a starting point to take another step. This argument is ignored if it is
- The starting community structure. It is a numeric vector defining the membership of every vertex in the graph with a number between 0 and the total number of communities at this level minus one. By default we start with a single community cont
- The id of the community which the algorithm will try to split.
- A named list to override some ARPACK options.
- The merge matrix, possible from the result of
The functions documented in these section implement the
B, which is
A being the adjacency matrix of
P contains the probability that certain edges are
present according to the
P[i,j] element of
P is the probability that
there is an edge between vertices
j in a random
network in which the degrees of all vertices are the same as in the
The leading eigenvector method works by calculating the eigenvector
of the modularity matrix for the largest positive eigenvalue and
then separating vertices into two community based on the sign of
the corresponding element in the eigenvector. If all elements in
the eigenvector are of the same sign that means that the network
has no underlying comuunity structure.
Check Newman's paper to understand why this is a good method for
detecting community structure.
leading.eigenvector.community is the proper implementation of
the proposed algorithm.
considered worse, in this implementation a community found after a
division is considered as a separate graph for further divisions.
leading.eigenvector.community.step is the proper
implementation, but makes only one step, by trying to split the
From igraph 0.5 these functions use ARPACK to calculate the
arpack for details.
community.le.to.memberhip creates a membership vector from the
leading.eigenvector.community.naive. It takes
steps merges, according to the supplied
leading.eigenvector.community.naivereturn a named list with the following members:
membership The membership vector at the end of the algorithm, when no more splits are possible. merges The merges matrix starting from the state described by the
membershipmember. This is a two-column matrix and each line describes a merge of two communities, the first line is the first merge and it creates community
Nis the number of initial communities in the graph, the second line creates community
options Information about the underlying ARPACK computation, see
leading.eigenvector.community.stepreturns a named list with the following members:
membership The new membership vector after the split. If no split was done then this is the same as the input membership vector. split Logical scalar, if
TRUEthat means that the community was successfully splitted.
eigenvector The eigenvector of the community matrix, or
eigenvalue The largest positive eigenvalue of the modularity matrix. options Information about the underlying ARPACK computation, see
community.le.to.membershipreturns a named list with two components:
membership A membership vector, a numerical vector indication which vertex belongs to which community. The communities are always numbered from zero. csize A numeric vector giving the sizes of the communities.
MEJ Newman: Finding community structure using the eigenvectors of matrices, arXiv:physics/0605087
g <- graph.full(5) %du% graph.full(5) %du% graph.full(5) g <- add.edges(g, c(0,5, 0,10, 5, 10)) leading.eigenvector.community(g) lec <- leading.eigenvector.community.step(g) lec$membership # Try one more split leading.eigenvector.community.step(g, fromhere=lec, community=0) leading.eigenvector.community.step(g, fromhere=lec, community=1)