# Automatic Detection of Multilevel Communities: Scalable, Selective and Resolution-Limit-Free +
## 2 Method
### Community Fitness Function  
The so-called community fitness function was firstly proposed by [PERSON] and [PERSON] [30]. Its original form is as following [30]:  
\[f^{\mathcal{G}}=\frac{k_{in}^{\mathcal{G}}}{\left(k_{in}^{\mathcal{G}}+k_{out }^{\mathcal{G}}\right)^{\alpha}} \tag{1}\]  
Here, \(\mathcal{G}\) denotes a community given by a certain network division, \(f^{\mathcal{G}}\) quantifies the fitness (i.e., quality) of community \(\mathcal{G}\): larger values of \(f^{\mathcal{G}}\) indicate more reliable communities. \(k_{in}^{\mathcal{G}}\) and \(k_{out}^{\mathcal{G}}\) in the formula stand for the in-degree and out-degree of community \(\mathcal{G}\), defined in the same way as those in previous literature, such as [8]. \(\alpha\) (\(\alpha\) > 0) is a resolution parameter that tunes the resolution: large values of \(\alpha\) yield small communities, while small values of \(\alpha\) deliver large communities [30].  
Instead of the widely-used modularity function \(Q\) proposed by [PERSON] [13; 48], we choose to use the community fitness function because it is, by design, scalable and is promising to avoid the resolution limit problem. Its original form, as in Formula (1), can be directly used in our method; actually, we do use it in many of our calculations in the following part of this paper. Yet, for networks that have multilevel or hierarchical structures,it would be helpful to introduce an additional parameter \(\beta\) to rescale the varying range of the resolution parameter \(\alpha\). In this paper, we suggest a modified form of \(f^{\mathcal{G}}\) as  
\[\left(f_{\alpha}^{\beta}\right)^{\mathcal{G}}=\frac{\left(k_{in}^{\mathcal{G}} \right)^{\beta}}{\left(k_{in}^{\mathcal{G}}+k_{out}^{\mathcal{G}}\right)^{ \alpha}}. \tag{2}\]  
Here, the power exponent \(\beta\) (\(\beta\geq 1\)) is our newly introduced \"scaling factor;\" when \(\beta=1\), Formula (2) degrades to Formula (1). When detecting communities with \(\left(f_{\alpha}^{\beta}\right)^{\mathcal{G}}\), we search for an optimized division of the network that maximizes the summative fitness of all detected communities:  
\[F_{\alpha}^{\beta}=\sum_{\mathcal{G}}\left(f_{\alpha}^{\beta}\right)^{ \mathcal{G}}=\sum_{\mathcal{G}}\frac{\left(k_{in}^{\mathcal{G}}\right)^{\beta }}{\left(k_{in}^{\mathcal{G}}+k_{out}^{\mathcal{G}}\right)^{\alpha}} \tag{3}\]  
Alternatively, maximizing the average fitness (i.e., \(F_{\alpha}^{\beta}\) divided by the total number of communities), as in [30], also yields essentially equivalent results.  
The scaling factor \(\beta\) amplifies the varying range of the resolution parameter \(\alpha\). For each fixed \(\beta\), we estimate in Appendix A that the varying range of \(\alpha\) should be between \(\beta-1\) and \(2\beta-1\): \(\alpha<2\beta-1\) prevents unexpected splitting of large communities, while \(\alpha>\beta-1\) avoids inappropriate merging of small communities. For example, random graphs exhibit no community structure within this resolution scale, and dense clusters that are sparsely connected will not merge into one large community. Obviously, when \(\beta=1\), \(\alpha\) should vary between \(0\) and \(1\); when \(\beta>1\), the varying range of \(\alpha\) has been amplified \(\beta\) times.  
In practice, for networks having only one single community level, varying \(\alpha\) within (\(\beta-1\), \(2\beta-1\)) is already sufficient for the expected communities being detected. However, for networks with multiple community levels, within range (\(\beta-1\), \(2\beta-1\)), only communities of the lowest level (i.e., communities of smallest sizes that cannot split further) can be detected. This is because higher levels of communities come from combinations of lower-level communities; to allow such combinations, the lower bound \(\beta-1\) must be relaxed. Therefore, in our calculation we run our algorithm with the resolution parameter \(\alpha\) varying between \(0\) and \(2\beta-1\), which enables us to detect multiple levels of communities within different resolution scales.