This method tries to maximize the modularity of a partition by exploiting the spectral properties of the modularity matrix. This method is implemented in igraph in the function cluster_leading_eigen. Recall that modularity is defined as:
Notice that the modularity matrix is symmetric and all rows and all columns of sum to . Indeed:
Let us consider the division of a network into just two parts, namely group 1 and group 2. The more general case can be treated with repeated bisection, as described below. We represent the assignment of node to a group with the variable such that if belongs to group 1 and if belongs to group 2. It follows that:
Unfortunately, this optimization problem is a hard one, but it can be tackled approximately by a relaxation method. We relax the constraint that must point to a corner of the hypercube and allow it to point in any direction, though keeping its length the same, meaning that it can take any real value subject only to the constraint that:
We maximize the modularity equation by differentiating, imposing the constraint with a single Lagrange multiplier :
We typically cannot in fact choose , since the elements of are subject to the constraint . But we do the best we can and choose it as close to as possible, hence if and if (either value of is good if ).
And so we are led the following very simple algorithm. We calculate the eigenvector of the modularity matrix corresponding to the largest (most positive) eigenvalue and then assign vertices to communities according to the signs of the vector elements, positive signs in one group and negative signs in the other. If all elements in the eigenvector are of the same sign that means that the network has no underlying community structure.
What about the division in more than two communities? Instead of maximizing modularity over divisions of a network into two groups, we can just maximize it over divisions into any number of groups. Modularity is supposed to be largest for the best division of the network, no matter how many groups that division possesses. A simpler approach is repeated bisection of a network. We start by dividing the network first into two parts and then we further subdivide those parts in to smaller ones, and so on. Given that our goal is to maximize the modularity for the entire network, we should only go on subdividing groups so long as doing so results in an increase in the overall modularity. If we are unable to find any division of a community that results in a positive change in the modularity, then we should simply leave that community undivided. When we have subdivided our network to the point where all communities are in this indivisible state, the algorithm is finished and we stop. This repeated bisection method works well in many situations, but it is by no means perfect. A particular problem is that there is no guarantee that the best division of a network into, say, three parts, can be found by first finding the best division into two parts and then subdividing one of the two.
One potential problem with the algorithm is that the matrix is not sparse, and indeed usually has all elements non-zero. Finding the leading eigenvector of a matrix takes time , which is equivalent to in a dense matrix, as opposed to in a sparse one.