# A Constrained Louvain Algorithm with a Novel Modularity
## 3 Materials and Methods  
### A Novel Objective Function  
The objective function of Louvain algorithm is very important. Here, we propose a novel modularity \(F2\) as an objective function. The \(F2\) of a community \(C_{i}\) is defined as  
\[F2(C_{i})=\frac{[d_{in}(C_{i})]^{2}}{[d_{in}(C_{i})+d_{out}(C_{i})]^{2}}, \tag{4}\]  
where \(d_{in}(C_{i})\) is the internal degree, i.e., the twice number of edges in a community. \(d_{out}(C_{i})\) indicates the external degree, which is the number of edges connecting the nodes in a community with the nodes out of the community. The modularity \(F2\) for the whole network is  
\[F2=\sum_{i=1}^{m}F2(C_{i}),\]where \(m\) denotes the number of communities. For the existed objective functions and proposed \(F2\), the correct partition corresponds with the big value of an objective function. Based on this, we compare different objective functions on different example networks and prove the advantages of \(F2\) theoretically on some example networks. (i) Unlike \(Q\) and \(M\), which both have a resolution limit problem [36; 37; 38; 39], the \(F2\) has not had this problem. That is to say, \(Q\) and \(M\) tend to merge some small communities together. However, \(F2\) can identify each small community as an individual community. In Figure 1a, we construct a network with a series of \(q\)-cliques connected to a ring with single edges. Here, each \(q\)-clique is a complete graph containing \(q\) nodes and \(q(q-1)/2\) edges. Obviously, such a network has a clear community structure that each clique corresponds to a community. Supposing the ring network is constructed by \(l\)\(q\)-cliques, we can prove that any \(h\)\(q\)-cliques cannot be merged to one community by \(F2\). If each community corresponds a single clique, we have  
\[F2_{single}=l\times\left[\frac{q(q-1)}{q(q-1)+2}\right]^{2}, \tag{6}\]  
If we merge \(h\)\(q\)-cliques into one community, the \(F2\) is  
\[ \begin{array}{l}F2_{merge}=\frac{l}{h}\left[\frac{q(q-1)h+2(h-1)}{q(q-1)h+2 (h-1)+2}\right]^{2}\\ =\frac{l}{h}\left[\frac{q(q-1)h+2(h-1)}{q(q-1)h+2h}\right]^{2}\\ =l\left[\frac{q(q-1)h+2(h-1)}{q(q-1)+2}\right]^{2}\\ <F2_{single}\end{array}  \tag{7}\]  
In the table of Figure 1a, we provide the values of \(Q\), \(M\) and \(F2\) when \(l=10,q=3\). In this case, \(F2\) identifies each \(q\)-clique as an individual community. However, \(Q\) and \(M\) tend to merge adjacent communities as a bigger community, as shown in Figure 1a. (ii) When the network is constructed by cliques of different sizes, \(Q\) and \(M\) still have a resolution limit problem on smaller cliques. As in Figure 1b, the network is constructed by two \(p\)-cliques and two \(q\)-cliques. We prove \(F2\) can identify communities correctly. When two \(q\)-cliques are considered as two separated communities, the value of \(F2\) is  
\[ \begin{array}{l}F2_{single}=[\frac{p(p-1)}{p(p-1)+1}]^{2}+[\frac{p(p-1)}{p( p-1)+3}]^{2}+2\times[\frac{q(q-1)}{q(q-1)+2}]^{2}\\ =[\frac{p(p-1)}{p(p-1)+1}]^{2}+[\frac{p(p-1)}{p(p-1)+3}]^{2}+\frac{[q(q-1)]^{2 }+[q(q-1)]\times[q(q-1)]}{[q(q-1)+2]^{2}}\end{array}  \tag{8}\]  
However, if two \(q\)-cliques are merged into one community, we have  
\[\begin{array}{l}F2_{merge}=[\frac{p(p-1)}{p(p-1)+1}]^{2}+[\frac{p(p-1)}{p(p- 1)+3}]^{2}+[\frac{2(q-1)+2}{2q(q-1)+4}]^{2}\\ =\left[\frac{p(p-1)}{p(p-1)+1}\right]^{2}+\left[\frac{p(p-1)}{p(p-1)+3}\right] ^{2}+\left[\frac{q(q-1)+1}{q(q  
(iii) When two 4-cliques are connected by multiple edges, as in Figure 1c. Such a network has been recognized as a well-connected network [40]. In this case, \(F2\) can avoid splitting a well-connected community into smaller ones. However, \(Q\) and \(F\) still tend to split the whole network into two communities. (iv) It can be theoretically proven that a random network or a complete graph cannot be divided into any two parts. When a random network is considered as one community, \(F2_{single}=1\). When it is divided into any two parts, which contain \(n_{1}\) and \(n_{2}\) nodes, respectively, we have  
\[