# DMFO-CD: A Discrete Meth-Flame Optimization Algorithm for Community Detection
## 1 Introduction
In addition, the objective function has a critical role in CD which is a measurement for metaheuristic algorithms to determine the optimality of the detected communities. Modularity [6], community score [58], modularity density [59], and partition entropy [9] are some objective functions that are introduced into the CD problem. The community detection problem is solved by using metaheuristic algorithms that imitate the natural phenomenon such as [60; 61; 62]. The moth-flame optimization (MFO) [63] algorithm is designed to solve continuous optimization problems inspired by the moths' navigation mechanism to fly at night. The moths fly toward the moon in a straight line by maintaining a fixed angle, which is an effective mechanism for navigating long distances. Therefore, when the moth flies toward the nearby artificial lights, this mechanism leads to flight in a spiral line. This behavior is mathematically modeled in the MFO algorithm to solve global optimization problems. The MFO algorithm is used in different applications such as feature selection [64], software defect prediction (SDP) [65], economic dispatch problem [66], optimal power flow [67], gene selection [68], classification [69], image segmentation [70], and photovoltaic energy generation system [71]. Although MFO is used to solve many problems, it still has insufficiencies, such as lack of population diversity [72], imbalance between exploitation and exploration [73], and premature convergence [74]. To improve the performance of the canonical MFO, enhanced or hybrid variants are proposed, such as in [74; 75]. The main purpose of this paper is to adapt a continuous metaheuristic algorithm that can be used to solve community detection and provide competitive results. Therefore, in this paper, a discrete moth-flame optimization algorithm for community detection (DMFO-CD) is proposed. To implement the proposed DMFO-CD algorithm, first, the representation of the canonical MFO is altered such that can be applied on a discrete problem community detection by using locus-based adjacency representation (LAR). The initial population of solution vectors is created using LAR, which detects the communities without any prior knowledge. Then, the modularity function is used as the evaluation criterion to calculate the fitness of the solution vectors and evaluate them. Next, the DMPCO-CD's movement strategy is proposed by altering the canonical MFO's movement strategy such that the main concept of MFO is maintained and suitable for solving community detection. Finally, after iterating the movement, evaluating, and updating the solution vectors, the detected communities are obtained. To adapt MFO using community detection, the position of moths and flames are modeled as solution vectors, which is represented using locus-based adjacency representation (LAR). The initialization process is performed by considering the network structure and the relation between the nodes. Then, the movement strategy is performed to move the moth's solution vectors around flames and update their position. This movement is accomplished by an adapted strategy consisting of a single-point crossover between the moth's solution vector and corresponding flame to imitate the distance calculated, the two-point crossover between the calculated distance and corresponding flame for movement strategy, and the single-point neighbor-based mutation to increase the exploration ability. To validate the proposed DMPCO-CD algorithm, a set of experiments were conducted on eleven real-world networks. The results were compared with five well-known algorithms in community detection, including a discrete particle swarm optimization with particle diversity and mutation that (DPSO-PDM) [13], a genetic algorithm for community detection (GA-Net) [58], a genetic algorithm for detecting communities in large-scale complex networks (GACD) [14], an enhanced genetic algorithm for community detection (EGACD) [60], and a multi-objective evolutionary clustering algorithm (DECS) [76].