325 © 2025 The Author(s). Published by College of Education for Pure Science (Ibn Al-Haitham), University of Baghdad. This is an open-access article distributed under the terms of the Creative Commons Attribution 4.0 International License Improving Modularity Regularization Techniques for Estimating Structures in Complex Network Samaa F. Ibraheem 1* and Basad Al-Sarray 2 1 Department of Mathematics, College of Applied Science, University of Technology, Baghdad, Iraq. 2 Department of Computer Science, College of Science, University of Baghdad, Baghdad, Iraq. *Corresponding Author. Received: 17 September 2023 Accepted: 19 February 2024 Published: 20 July 2025 doi.org/10.30526/38.3.3728 Abstract Complex systems in the real world have networks differ significantly from random graphs and have non-trivial structures. In fact, they have a community structure that needs to be recognized and recovered. The stochastic block models (SBMs) are popular models for community detection in networks, where nodes are divided into groups based on their connectivity patterns. Maximum likelihood estimation is a common method for estimating the parameters of SBMs. In this paper, a model selection for stochastic block models is presented based on the optimization of the log-likelihood function to find the best number of communities K detected by the regularized convex modularity maximization method. This work deals with many assumptions on K because it is necessary to study the behavior of the network and the best optimum K is assumed to select the best partition over the AIC, BIC metric. The proposed model selection method is presented in an algorithm that is implemented for both real and synthetic networks. This method enables the detection of networks with small communities that are more likely to provide a better fit to the observed data. Keywords: Community detection, likelihood function, model selection, Bayesian Information Criterion, Stochastic Block Models. 1. Introduction The stochastic block model (SBM) in its standard form is a popular tool for detecting communities in networks. It is based on the assumption that the nodes in a network can be divided into groups or blocks, so that the probability of an edge between two nodes depends only on which block they belong to. This enables the estimation of block membership and the detection of communities within a network (1). The SBM has been used to detect communities in social networks, biological networks and other types of networks (2) and (3). More specifically, it can be used to estimate the number of communities in a network as well as their size and connectivity patterns. In addition, it can be used to identify outliers or anomalous nodes that do not fit into any of the detected clusters (4). https://orcid.org/0000-0002-0836-5173 mailto:samaa.f.ibraheem@uotechnology.edu.iq https://orcid.org/0000-0003-2419-0710 mailto:basad.a.alsarray@gmail.com https://orcid.org/0000-0002-0836-5173 mailto:samaa.f.ibraheem@uotechnology.edu.iq https://orcid.org/0000-0003-2419-0710 mailto:basad.a.alsarray@gmail.com https://orcid.org/0000-0002-0836-5173 mailto:samaa.f.ibraheem@uotechnology.edu.iq https://orcid.org/0000-0003-2419-0710 mailto:basad.a.alsarray@gmail.com https://orcid.org/0000-0002-0836-5173 mailto:samaa.f.ibraheem@uotechnology.edu.iq https://orcid.org/0000-0003-2419-0710 mailto:basad.a.alsarray@gmail.com https://orcid.org/0000-0002-0836-5173 mailto:samaa.f.ibraheem@uotechnology.edu.iq https://orcid.org/0000-0003-2419-0710 mailto:basad.a.alsarray@gmail.com https://orcid.org/0000-0002-0836-5173 mailto:samaa.f.ibraheem@uotechnology.edu.iq https://orcid.org/0000-0003-2419-0710 mailto:basad.a.alsarray@gmail.com IHJPAS. 2025, 38(3) 326 The SBM model works by randomly assigning nodes to different blocks and then connecting nodes within each block with a certain probability, while connecting nodes between blocks with a different probability. In this way, networks can be created with different communities that are connected to different degrees (5, 6). Model selection is an important task in SBM analysis as it helps to select the most accurate model from a set of candidates (7). This includes selecting the number of groups or communities as well as the parameters that determine the edge probabilities within and between groups. There are several approaches to model selection for SBM, including likelihood-based methods (8, 9), information-theoretic methods (10), spectral clustering (11), and cross-validation (12). Likelihood-based methods are commonly used for model selection in SBM analysis. Here, the maximum likelihood estimation (MLE) method is used to estimate the parameters of the SBM to find the parameter values that maximize the likelihood function. MLE can also be used to compare different SBMs by comparing their likelihood values using different penalized likelihood information criteria, such as the Akaike’s Information Criterion (AIC), the Consistent AIC, the Bayesian Information Criterion (BIC) and the Adjusted BIC (13). Thus, AIC is an estimate of a constant plus the relative distance between the fitted likelihood function of the model and the unknown true likelihood function of the data, while BIC is an estimate of a function of the posterior probability of a model being true under a given Bayesian setup, such that a low AIC and BIC mean that the model is considered closer to the truth (14,15). However, optimization of the likelihood function can be practically performed by optimizing the profile likelihood criteria over all possible partitions for each K. Subsequently, the best model can be selected using AIC or BIC. Overall, likelihood-based methods provide a rigorous framework for model selection in SBM analysis and help researchers to select the best-fitting model based on statistical criteria. Moreover, model selection for SBM can be challenging due to the high-dimensional parameter space and non-convex optimization problem (16). Therefore, it is important to use multiple approaches and carefully evaluate their results before drawing conclusions about the underlying structure of the network. The stochastic block models (SBMs) are popular probabilistic models for community detection in networks. They provide a powerful and modern way to define and understand network structure (17). There are many types of SBMs, including symmetric SBMs and overlapping SBMs (18), but the focus is on SBMs in standard form and SBMs with corrected degree. To represent the standard SBM, an undirected and unweighted random graph G with n nodes is considered, where A = [aij]∈R n×n is the adjacency matrix of G that characterizes the relation between each pair of vertices i and j. A is symmetric. To model A by SBM, assume that aij s are independent Bernoulli variables, that is ( ) ∈ ( ) (1) and the vertices in G are partitioned into K groups (communities) such that the vertex i belongs to the community , …, K, according to the map C : {1, …, n} → {1, …, K} such that . Let Z ∈ {1, …, K} n be the vector of labels that members the vertices i′s to one of K communities, i.e., * +, where ( ) The membership label Z that defines community assignment is drawn independently from a multinomial distribution on K communities with probability ( ) ∑ , that is i i d multinomial ( ) (2) In SBM, the probability that vertices i and j are connected ( ( ) ) depends on their community membership; therefor, is identical for any i and j that belong to the same IHJPAS. 2025, 38(3) 327 community. By this way, a symmetric K × K, matrix B is formed such that where ∈ , and K ≪ n. This probability matrix is called a stochastic block matrix or connectivity matrix, so there are K (K + 1)/2 connectivity parameters to estimate in this model (19). In networks with community structures, the edge probabilities within a same block exceed the probabilities that vertices of different blocks are connected, i.e., the vertices within a same block are more likely to be connected, so in community detection, we seek for , ∀k, q, r=1, 2, · · · , K, with qr. The degree-corrected stochastic block model is a probabilistic model for network data that extends the traditional stochastic block model (SBM) by incorporating node-specific degree information. In the degree corrected SBM, each node is assigned to one of K blocks, and the probability of an edge between two nodes depends on their block assignments as well as their individual degrees. So the probability matrix B, with size K × K, is formed as where θi>0 is an additional parameter assigned to each node to control its expected degree (1). Moreover, the value aij is a Poisson-distributed random variable with mean , i.e., ( ) (3) In this paper, a model selection for stochastic block models is performed based on optimizing the log likelihood function to find the best number K of communities. The main aim is to select the model for communities that are detected using a convex optimization approach under degree corrected SBM, which is regularized convex modularity maximization method (RCMM) that is suggested in (20), and compare this result with others detected using various algorithms, which are convex modularity maximization CMM (4, 21), modularity maximization algorithm (22), Danon algorithm (23) and spectral clustering (11). The article is organized as follows: Section 2 introduces stochastic block models. Section 3 presents the objective, and some details on algorithmic settings are also given. Numerical results are presented in Section 4 that show the performance of the model selection algorithm on the RCMM method compared with other methods. Finally, concluding remarks are given in Section 5. 2.Optimizing Likelihood Function for Model Selection and Estimation In community detection, the goal of optimization methods with stochastic block models is to estimate the parameters of the model, such as the number of communities and the probability of connections between nodes within and between communities, in order to get the optimal membership label vector Z. This is done by maximizing a likelihood function that measures how well the model fits the observed network data, therefore detecting the network community. In the stochastic block model SBM, the ’s are independent Bernoulli variables with probability pij, which is the expectation of That is ( ) which performs a symmetric matrix (connectivity matrix) Given the node labels (the vector Z), the likelihood of observing A with probability B under SBM is: ( | ) ∏ ( ) ( ) (4) whereas the DCSBM, which limits the applicability of the SBM, has an expected value of the adjacency matrix element equal to: ( ) (5) IHJPAS. 2025, 38(3) 328 but a Poisson distribution with this mean is used to determine the actual number of edges between any two vertices. The likelihood function is defined as ( | ) ∏ ( ) ( ) ∏ ( ) ( ) ( ) (6) To find the optimal partition, the likelihood function is maximized over B, giving the profile likelihood criteria to be optimized over all possible partitions. Actually, the Bernoulli likelihood is replaced by the Poisson likelihood, to simplify derivations. So for these two models, a profile likelihood was driven from the log-likelihood function of each of them to give the following criteria (1): ∑ (7) ∑ (8) where ∑ * is the number of edges from community k to community l, . ∑ be the node degrees in community k. In fact gives twice the number of edgeswithin community k, and is the number of nodes of community k, also and give the maximum likelihood values ̂ of the SBM and DCSBM model parameters respectively. 3.Enhancement of CMM for Community Detection There are many methods for detecting communities, distinguishing between traditional methods and optimization- and model-based methods. The optimization algorithm tries to identify communities within the network (graph) based on the optimization of some quality functions. Depending on the representation of the network, the modularity function, denoted by Q, can be defined as follows: It is a function that measures the strength of the partition of a network into communities (subgraphs) considering the degree distribution, such that networks with a high modularity value have dense connections between nodes within a cluster but sparse connections between nodes of different clusters. The modularity function is given by: ∑ . / ( ) (9) where , .= the adjacency matrix and Kronecker delta ( ( , ) is a function that yield 0 or 1 if vertices i of degree , .and j of degree , . are in the same community or not). So, the possible existing communities are gained by balancing between the actual density of edges and the expected density that would appear in the communities if the vertices were connected regardless of community structure. Many methods for community detection are used in this work for in comparison, these methods are summarized as follows: Newman Modularity Maximization: this is an agglomerative hierarchical clustering technique in which smaller communities of vertices are gradually merged into larger ones, leading to an increase in modularity (22). The algorithm works as follows: - Step 1: Assign each of the n vertices to a single cluster. - Step 2: Reduce the number of clusters by adding an edge to the set of unconnected vertices such that the resulting partition has a modularity Equation (9) greater than the value of the previous configuration. - Step 3: Choose the optimal fusion by calculating the variation ΔQ - Step 4: Repeat steps 2 and 3 until you have added all edges and obtained one cluster. Save the modularity score for each partition. - Step 5: Select the partition with the highest modularity score. IHJPAS. 2025, 38(3) 329 3.1. Danon Method In this method, (23) proposed to normalize the modularity variation Q resulting from the union of two communities by the proportion of edges belonging to one of the two communities, since the Newman technique tends to form large communities at the expense of small ones. Thus, this approach leads to larger modularity optima, especially when the communities have very different sizes. 3.2.Convex Modularity Maximization The CMM algorithm makes use of convex optimization, where it is based on a convex programming relaxation of the modularity optimization and works under block models (21). Thus, so this algorithm tends to maximize modularity by solving the following optimization problem: ⟨ ⟩ ( ) (10) where X is the partitioning matrix for the network nodes. The CMM approach combines convex optimization techniques with modularity maximization and a weighted ℓ1-norm k- medoids as follows. After obtaining the optimal solution to Equation (10), ̂, by the alternating direction method of multipliers (ADMM), the communities is extracted from weighted ̂ by weighted ℓ1-norm k-medoids, i.e by solving the optimization: ∑ ∑ ‖ ̂ ‖ ∈ ∈ ( ̂) ∀ ∈ * + (11) where ̂ ̂, ( ) and are the centers, so the clustering is performed on the rows of ̂ instead of ̂, thus, this procedure is summarized as follows: - Step 1: Solve the optimization problem (10) for X using the alternate direction method of multipliers (22). - Step 2: Find the k-partition of n nodes by the k-medoids approach, weighted by node degrees. 3.3. Regularized Convex Modularity Maximization The RCMM algorithm is considered a regularization of the CMM algorithm. Where the common neighbor’s similarity measurement is used to weight the ℓ1-norm of k-mediod clustering (20) instead by node degrees. Where the weight was given twice, once to the rows of the partition matrix X and secondly to the terms of the ℓ1-norm of k-medoides. The number of common neighbors between two vertices i and j is defined as ∑ (12) So the weighted ℓ1-norm k-medoids clustering will be done for the matrix ̂ ̂ and the partition yields by solving the optimization problem: ∑ ∑ ‖ ̂ ‖ ∈ ∈ ( ̂) ∈ * + (13) 3.4. Spectral Clustering In general it is a method uses of information which is taken from the eigenvalues of special matrices like Affinity Matrix, Degree Matrix and Laplacian Matrix derived from the data set (graph). It takes the matrix of eigenvectors associated with the K largest eigenvalues of one of these special matrices and performs one of the distance-based clustering methods on it (25). So mathematically, it is summarized in the following steps: - Step 1: Take the leading eigenvectors , - ∈ of the adjacency A or its graph normalized Laplacian L(A) = D −1/2 AD −1/2 , where D = diag(di) is the diagonal IHJPAS. 2025, 38(3) 330 matrix of degrees and the eigenvectors are associated with the K largest eigenvalues of the chosen matrix. - Step 2: Normalize each rows of the matrix , - to find with elements (∑ ) . - Step 3: Run any distance clustering method (e.g., K-means) on the rows of the resulted vectors to partition them into desired number of clusters (K), where the output and the node i is assigned to cluster r if the i'’th row of is assigned to cluster . 4. Model Selection Model selection for SBMs involves choosing not only the marginal probabilities but also the number of communities K in order to determine the best fitting model from a set of candidate models (26). This is done in two stages: In the first, the parameters for the likelihood function are estimated for many chosen K, while in the second, the model that best fits the observed data is selected, i.e.,. the model that has the minimum AIC or BIC value (27-29). In likelihood-based methods, the likelihood of the observed network is maximized among different SBM models with different numbers of communities and parameter values. The Akaike information criterion (AIC) and Bayesian information criterion (BIC) are commonly used to compare models with different numbers of parameters and select an appropriate model. Let r be the number of estimated parameters in the model ( ) (14) and ( ) ( ) (15) The model that has the lowest AIC and BIC values from a group of possible models for the data is the one that should be selected. In other words, the AIC or BIC can be used to compare different models with different numbers of parameters and select the one that best fits the data, where the lower the AIC or BIC value, the better the model fits the data (30). Therefore, two stages are needed to estimate the parameters , .and choose the optimum model. The first is to choose the best membership label Zbest, which represents the partition of the network, using any community detection algorithm for many values K<