**3. Methodology**

Two genetic algorithms designed to detect communities in graphs were applied in large networks modelling supergrids. These evolutionary approaches are guided by *modularity* [23], which is an applied objective function extensively used in community detection due to its simplicity and ease of calculation. Modularity provides a numerical value that represents the quality of the solution, with greater values corresponding to a more accurate community structure. Therefore, the aim was to find communities that maximise the value of *modularity* (*Q*), defined as:

$$Q = \frac{1}{2M} \sum (a\_{ij} - \frac{K\_i K\_j}{2M}) \delta(i, j), \tag{1}$$

where *M* represents the total number of edges in the network; the sub-indices *i* and *j* indicate two nodes (vertices) of the network, *Ki* and *Kj* being the degrees of the *i*-th and *j*-th nodes, respectively; the parameter *aij* is the element of the *i*-th row and the *j*-th column of the adjacency matrix; and *<sup>δ</sup>*(*<sup>i</sup>*, *j*) represents the relationship between the *i*-th node and the *j*-th node (i.e., *<sup>δ</sup>*(*<sup>i</sup>*, *j*) = 1 if node *i* and node *j* are in the same community; otherwise, *<sup>δ</sup>*(*<sup>i</sup>*, *j*) = 0).

Finding these communities by maximising the modularity [23] or another objective function is an NP-hard problem [46]. Brandes et al. [47] proved that modularity maximisation is an NP-hard problem, even for the restricted version with a bond of two clusters, and suggested further investigation of approximation algorithms and heuristics for solving this problem. More recently, other authors have demonstrated the high complexity of calculating modularity on sparse graphs and dense graphs separately [48]. Due to the high complexity of the community detection problem, researchers have applied heuristic and meta-heuristic methods to obtain high quality solutions, in a reasonable computational time.

The field of evolutionary computation [49] is closely related to computational intelligence, with a focus on designing algorithms to solve complex global optimisation problems. Evolutionary algorithms are problem-solving procedures that include evolutionary processes as the key design elements, such that a population of individuals is continually and selectively evolved until a termination criteria is fulfilled. Genetic algorithms (GAs) [50] are probably the most widely used evolutionary techniques. A genetic algorithm mimics natural selection by evolving, over time, a population of individual solutions to the problem at hand until a termination condition is fulfilled and the best individual is taken as an acceptable solution. Two important characteristics of GAs are the representation used (e.g., binary or real) and the genetic operators employed (e.g., mutation and crossover). GAs have been successfully applied to solve electrical problems [51–53].

In this study, two genetic algorithms were adapted to solve community detection problems in power grids. These algorithms (MIGA and GGA+) were recently proposed and shown to be more effective than other approaches to community detection, as assessed by benchmarks typically used to compare algorithms. Figure 1 shows the flowchart of MIGA and GGA+. The main characteristics of both methods are briefly described below.

• The modularity and improved genetic algorithm (MIGA) [54] takes the modularity (*Q*) as the objective function, and uses the number of community structures as prior information to improve stability and accuracy of community detection. MIGA also uses simulated annealing [55] as local search strategy. Note that many authors have previously considered the use of local search strategies [56] for solving hard optimisation problems.

•The generational genetic algorithm (GGA+): GGA+ [57] includes efficient and safe initialisation methods in which a maximum node size is assigned to each community. Several operators are applied to migrate or exchange nodes between communities while using the modularity function as the objective function. An important feature of GGA+ is that it is able to rapidly obtain community partitions with different degrees of abstraction.

**Figure 1.** Flowchart of (**a**) MIGA and (**b**) GGA+.
