Quantifying Topological Flexibility of Active Distribution Networks Based on Community Detection

: Active distribution networks (ADNs) provide a ﬂexible platform to integrate various distributed generation sources, among which the intermittent renewable sources impose high operating uncertainty. Topological ﬂexibility of ADNs should be exploited to counter the stochastic operating conditions by modifying the topologies of ADNs. Quantifying the topological ﬂexibility is a vital step to utilize it, which is lacking in previous studies. A quantiﬁcation method is proposed to measure the topological ﬂexibility of ADNs in this paper. First, the community structures of ADNs are detected to achieve spatial partitions of the networks. Second, an improved spectral clustering algorithm is employed to signiﬁcantly reduce the dimensionality of the partition space, in which the ADNs are further partitioned using the a ﬃ nity propagation algorithm. Finally, a topological ﬂexibility metric is deﬁned based on the guiding role of sectionalizing and tie switches within and between communities. The proposed topological ﬂexibility quantiﬁcation method is a superb approach to the utilization of ﬂexibility resources in distribution networks. Case study results of test ADNs demonstrate the e ﬀ ectiveness and e ﬃ ciency of the proposed quantiﬁcation method. H.G. and H.G. and


Introduction
Concern for the environment and energy security, as well as rising fuel prices, have led to significant, sustained growth of the installed capacity of variable generation (VG), such as wind or solar generation. Active distribution networks (ADNs) use flexible network topology to manage power flow, control and manage VG actively, and have become an essential part of intelligent distribution networks [1]. However, both increasing uncertainty of VG and load make it challenging to envelop the total uncertainty by increasing reserve technically or economically. Hence, ADNs must provide a certain degree of tolerance to uncertainty and variability, which is called flexibility [2], to react to a sudden change and accommodate new status within acceptable time and cost.
Flexibility evaluation is mostly based on the supply and demand of node-injection type flexibility resources, as is the research on enhancing power system flexibility. The concept of the operational flexibility domain is presented in Ref. [3,4], which is a three-dimensional space composed of power ramp-rate, power, and energy. The insufficient ramping resource expectation (IRRE) metric is proposed in Ref. [5] by obtaining the empirical discrete cumulative distribution of the flexibility available and the net load ramp time series. A unified framework for defining and measuring power system flexibility is established in Ref. [2]. Under the proposed framework, a flexibility metric is defined, which can judge whether the flexibility of the system is sufficient by comparing the most extensive variation 1.
The proposed topological flexibility quantification method quantifies the capability of ADNs to provide effective structural transformations based on the switch combination where the switches are not limited to fixed locations; 2.
Community detection is applied to partition the distribution network and analyze aggregation characteristics of nodes; 3.
An improved spectral clustering algorithm is employed to achieve the significant dimensionality reduction of partition space, which avoids the curse of dimensionality.
The remainder of this paper is organized as follows. Section 2 introduces the graph-based topology model of distribution network and detects the community structures of ADNs by using the improved spectral clustering. Section 3 proposes the topological flexibility quantification framework based on community structure. Section 4 conducts case studies. Conclusions are drawn in Section 5.

Structure of Active Distribution Networks
ADNs are usually composed of a vast number of distributed generations (DGs) and energy storage devices. In order to uncouple the large-scale system problems in the spatial dimension, community detection is adopted to analyze the structural characteristics of distribution networks.

Graph-Based Topology Model of Distribution Network
Complex network theory takes the actual networks in social, natural, and engineering systems as the research object, aiming to reveal the relationship between network function and structural features. With the emergence of the small-world network [19] and scale-free network [20], this theory has been widely valued in many fields of scientific research and gradually applied to the research on power systems. A large number of studies have shown that, as one of the large-scale and complex artificial networks, power systems also have the characteristics of complex networks such as the small-world network [21] or community structure [22,23].
In the actual power system, the interconnection of large power grids strengthens the connection between different regions, and the existence of some high-voltage lines makes the electrical distance between concentrated loads and centralized sources significantly reduced. When these remote connections fail, it will reduce the power supply capacity from the power supply area to the load area. This structural feature of power grids is the small world characteristic, and the theory has been applied in the vulnerability assessment and cascading failure analysis of transmission lines [24][25][26].
Community structure is a common topological property in complex networks. It has the characteristics of close connections within communities and relatively sparse relationships between communities. Clustering [27] is a standard method used in community detection, which can be divided into two modes: agglomerative algorithm and splitting algorithm. At present, the power grid partitioning [28,29] method using the agglomerative algorithm has been implemented in the voltage/reactive power hierarchical control of power systems.
Complex networks provide a new perspective for analyzing power grid structure. When studying the ADNs with the idea of the complex network, the distribution network needs to be represented by an abstract graph first. The following are some principles that simplify the analysis of the distribution network structure.

1.
All distribution lines are abstracted as unweighted edges in the distribution network topology model, ignoring the different electrical characteristics and voltage levels of distribution lines; Energies 2020, 13, 4786 4 of 21 2.
All the power nodes, load nodes, and the root nodes connected to the upper power grid in the distribution network topology model are abstracted as undifferentiated nodes in the graph, and the ground points are not considered; 3.
The directivity of the distribution network graph is ignored.
After the above simplification, the distribution network can be abstracted as an undirected and unweighted sparse connected graph with n nodes and m edges. The graph is denoted as G = (V, E), where V is the set of nodes, and E is the set of undirected edges. We denote nodes with single Roman letter subscripts i and undirected edges with Roman letter subscripts e ij .

Spectral Clustering
To further analyze the structural features of distribution networks, we study its community structure characteristics based on the graph theory model. Community detection can be regarded as a graph partitioning problem [30], so this section will outline the basic theory of graph partitioning and its solution methodology.
For an undirected graph, G = (V, E), the standard graph partitioning criteria include minimum cut, normalized cut, and ratio cut. The normalized cut is adopted to avoid isolated nodes in partitioning, which can be described by the following equation [31].
where Ncut (G 1 , G 2 , · · · , G K ) denotes the normalized cut criterion for dividing G into k independent subgraphs, G i is the complement of the subgraph G i with respect to G, cut(G i , G i ) is the cut of G i and G i , and V g (G i ) is the graph scale of G i . Then, the graph partitioning can be described as the minimum problem of Ncut. However, this is an NP-complete problem, and the computation time increases exponentially with the complexity of the problem. Spectral clustering [32] can transform the NP-hard graph partitioning problem into the solution of eigenvectors so that some practical algorithms for solving the eigenvector can be used to solve the graph partitioning problem, which significantly improves the solving efficiency. By solving and screening the partial eigenvectors of the Laplacian matrix, the original graph data is projected to the new sample space generated by the selected eigenvector. After clustering the data in the new sample space, the partitioning result of the original graph can be obtained.
In order to get the minimum value of Ncut (G 1 , G 2 , ···, G K ) represented by Formula (1), an indicator matrix H of order n × k is defined, and its matrix elements are as follows.
where i = 1, 2, · · · , n; n is the number of nodes in G; and j = 1, 2, · · · , k. Through relevant mathematical derivation, the minimum problem of Formula (1) can be equivalent to the constrained optimization problem described in Formula (3) [33].
where Tr (•) is the trace function; L is the unnormalized Laplacian matrix, which is obtained by subtracting the adjacency matrix from the degree matrix D; T = D 1/2 H; I is the identity matrix; D −1/2 LD −1/2 is the symmetric normalized Laplacian matrix Lsym. According to the Rayleigh-Ritz theorem, it is proved that T consists of eigenvectors corresponding to the first k minimum eigenvalues of Lsym. To avoid the too-small value of eigenvector component due to the small vertex degree, it is usually necessary to standardize the T matrix according to the row and then use a specific clustering algorithm to cluster the row vector.

Community Detection by Using Improved Spectral Clustering
The community structure is detected to study the structural feature of ADNs. Within each community, the connections between nodes are very close, but the connections between communities are relatively sparse [34,35]. By spectral clustering, community detection is transformed into the solution of eigenvectors, in the last step of spectral clustering, the row vectors of matrix T need to be clustered, and the k-means algorithm is traditionally used for clustering. However, the k-means algorithm is sensitive to the initial center point. We need to use the cluster information of nodes to express the metric in the topological flexibility research. However, the k-means clustering lacks the output of sample data. In this paper, affinity propagation (AP) is used to replace the k-means algorithm, which is more suitable for the induction of a topological flexibility metric.
AP is a clustering algorithm based on "information transfer" between data points, and it alternates two message-passing steps to update the following two information variables called "responsibility (R)" and "availability (A)" [36,37].
First, the responsibility r t+1 (i, k) is updated according to the following formula.
Then, the availability a t+1 (i, k) and self-availability a t+1 (k, k) is updated according to the following rules.
Responsibility r(i, k) reflects the accumulated evidence of how well-suited data object k is to serve as the exemplar for data object i, taking into consideration other potential exemplars for data object i, and represents the messages from i to k. Availability a(i, k) reflects the accumulated evidence for how appropriate it would be for data object i to choose data object k as its exemplar. It represents the message from k to i. In this way, the AP algorithm saves the similarity information between the sample points and the cluster centers.
Modularity Q [34] is used to evaluate the quality of community detection, as shown below.
where m is the number of edges in the network, n is the number of nodes, A ij is the adjacent matrix corresponding to the system, and k i is the degree of node i. C i is the community label of node i, and if node i and node j are in the same community, then δ c i , c j = 1; otherwise, δ c i , c j = 0. The upper limit of Q is 1, and the closer Q is to 1, the more obvious the community structure is. We take the Institute of Electrical and Electronics Engineers (IEEE) 33-node test feeder as an example to introduce the community structure of distribution networks. Based on the improved Energies 2020, 13, 4786 6 of 21 spectral clustering, the community structure of the IEEE 33-node test feeder is detected, as shown in Figure 1.
where m is the number of edges in the network, n is the number of nodes, Aij is the adjacent matrix corresponding to the system, and ki is the degree of node i. Ci is the community label of node i, and if node i and node j are in the same community, then   , =1 ij cc  ; otherwise,   , =0 ij cc  . The upper limit of Q is 1, and the closer Q is to 1, the more obvious the community structure is.
We take the Institute of Electrical and Electronics Engineers (IEEE) 33-node test feeder as an example to introduce the community structure of distribution networks. Based on the improved spectral clustering, the community structure of the IEEE 33-node test feeder is detected, as shown in Figure 1. The IEEE 33-node test feeder is adaptively divided into five communities by community detecting. The calculation result shows that the partitioned network has high modularity that equals to 0.6689, indicating that the community structure of the IEEE 33-node test feeder is of high quality.
The dashed lines in the figure denote the candidate positions of tie switch allocation determined by experience in most pieces of literature. The community structure has a particular corresponding relationship with the candidate positions. The positions of tie switches are all between communities, indicating that tie switches establish the interconnections between communities in pairs.
To verify the universality of the above findings, we have carried out experiments in another three examples and found that the corresponding relationship between switches and community structure is universally consistent. The simulation results are shown in Section 4. This discovery provides a new perspective for us to study the role of switches in the distribution network topology.

Topological Flexibility
In the face of the increasing demand for flexibility, in addition to ensuring the supply of flexibility resources, we should improve the network structure to provide support for the transfer of flexible resources. Topological flexibility is used to describe the structural change capacity of ADNs, focusing on the topological transformation that the network can provide initiatively.
We define topological flexibility as the ability of ADNs to provide effective topological change through switch combination within acceptable cost threshold, which reflects the discrete structure features of distribution networks. Topological flexibility is an inherent property of a system, which contains three determinants: effective change, switch combination, and acceptable cost.
Effective change means that topological flexibility not only depends on the number of structural changes that can be provided by ADNs but also depends on the effectiveness of different structural patterns. Therefore, we analyze the community structures of distribution networks and get effective topological transformations needed. Switches are the means to provide structural changes, and the combination of different switches directly affects the connection patterns of ADNs. The larger the diversity of switch combinations, the more options operators have to respond to flexibility demands. However, due to the restriction of cost, switches cannot be installed without limit. In the case of a certain number of switches, the switches should be installed in positions where they can maximize the topological flexibility. In this paper, the limiting factors of switch costs are reflected by the number of switches. The more the number of switches required, the higher the total cost of switches when the unit cost of each switch is fixed.

Definition of Topological Flexibility Metric
Community detection not only realizes spatial uncoupling but also provides a criterion for evaluating the effectiveness of switches: if a switch is installed within the community, its effectiveness Energies 2020, 13, 4786 7 of 21 will be weakened. On the contrary, if the switch is an inter-community switch, its efficiency will be higher. That is because the switch plays the role of regional isolation and contact. The more switches are located between communities, the more frequently they are switched on-off, which means they are more needed. The nodes within the community are more closely connected and can be regarded as a whole; hence, frequent exchange of isolation and contact is less.
Based on the different switch functions and switch locations, the switches are divided into four types: sectionalizing switches between communities, tie switches between communities, sectionalizing switches within the community, and tie switches within the community. Generally, in switch allocation, there is no one-to-one correspondence between the sectionalizing switch and tie switch. The number of sectionalizing switches is often more than that of tie switches. Therefore, the ratio of saturation number of four types of switches is used to determine their respective weights in the definition of topological flexibility metric. The entire topological flexibility metric is based on the hierarchy from intra-community to inter-community as follows.

Topological Flexibility within Community
Suppose that the node number of a community is n, the number of branches corresponding to the tree structure is m, the number of sectionalizing switches in the community is k, the number of tie switches in the community is p, and the number of the actual connecting lines in the community (that is, the edges of the graph model) is h.
In the community, the switch guides the communication between nodes. Candidate positions of sectionalizing switches are limited to the power lines that are laid already, and the isolation of nodes is achieved by switching off sectionalizing switches. The weaker the connection between the two ends of the line, the easier the line is to be disconnected, and the more effective the sectionalizing switch is installed here. We weigh the status of the node in the community by responsibility (R) + availability (A) obtained by the improved spectral clustering. Nodes with considerable status in the same community also have similar R + A values. The larger ∆(R + A) is, the more differences between the two nodes, and the weaker the connection of two nodes. We use k jj=1 ∆(R + A) jj / h ii=1 ∆(R + A) ii to evaluate the useful degree of sectionalizing switches, which represents the proportion of the ∆(R + A) of nodes connected by sectionalizing switch jj in the sum of the differences of R + A when sectionalizing switches are installed on all edges. The more significant the contrast of nodes connected by sectionalizing switches, the stronger the isolation requirement.
For a tie switch, its candidate installation position can be between any two nodes. According to heuristic experience, it is often installed between different branches to achieve communication between different regions. The larger the information flow that a switch can transmit (that is, the denser the nodes connected by the switch), the broader the scope of communication through the switch. The node's topology potential [38] is an important metric to measure the connection density of a node. We use the average value of the topology potential of the nodes at both ends of tie switches 1 2 ϕ(v i ) + ϕ v j to assess the useful degree of the tie switch, where ϕ(v i ) denotes the topology potential of node v i . The nodes in the area with high density have higher topology potential. The higher the topology potentials of the nodes connected by a tie switch are, the larger the scope of influence through the communication between the nodes, realizing more effective contact effect.
In addition to the influence of different switches, the topological flexibility of a community is also related to its connectivity. The existence of connecting lines determines whether the community structure is complete. Connectivity is defined as the ratio of the actual number of attaching edges to the full set of connecting lines in the community, which is h/(n − 1). Thus, the topological flexibility within the community (tf ) is obtained as follows: Energies 2020, 13, 4786 where n − 1 denotes the complete set of sectionalizing switches in the community and C 2 m denotes the saturation number of tie switches. tf sec , tf tie , and tf con are the sectionalizing topological flexibility, the tie topological flexibility, and the connectivity within the community, which all belong to [0, 1]. When we combine these three components, we use the proportion of their respective saturation numbers in the total saturated numbers as their weights.

Topological Flexibility of ADNs
The switches between communities play the role of communication between communities. As a normally closed switch, the sectionalizing switch mainly plays the role of isolation between communities when it is switched off, while the tie switch, as a normally open switch, mainly provides the power supply path between communities when it is switched on. In the switch allocation, if the switch installation position is laid with power lines, then it will be installed with a sectionalizing switch. Otherwise, it will be installed with a tie switch. We use the topological flexibility within the community to describe the importance of each community. The mean value of community importance of the two communities that connected by an inter-community switch is taken as the weight of the switch.
Suppose that the number of nodes in the distribution network is N, the number of communities is M, the number of sectionalizing switches installed between communities is K, and the number of tie switches installed between communities is P. Then the overall topological flexibility of the network (TF) is defined as follows.
where M − 1 denotes the complete set of sectionalizing switches between communities; C 2 M denotes the complete set of tie switches between communities; d ij denotes the shortest distance between node i and node j; D is the diameter of the network, representing the network size; ω I is the weight of sectionalizing switch I, which is the mean value of the importance of two communities connected; ω J is the weight of the tie switch J, which takes into account the influence of the communication range; and two kinds of topological flexibility are combined, to highlight the importance of inter-community sectionalizing switch in achieving inter-regional isolation, we use the proportion of their respective complete sets in the total switch complete sets as the weight of each other. That is because although the complete set of sectionalizing switches among communities is small, in order to ensure the radiation operation of distribution networks, the timely breakability of sectionalizing switches is the prerequisite for the tie switch to reconnect.
The system topological flexibility metric reflects the performance and number of structures that the power grid can actively provide, and it also effectively handles the problem of discrete combination and reduces the solving scale of the problem. The proposed topological flexibility metric is deterministic, which ∈[0, 1). In particular, when the parameters K and P in Formula (12) are zero at the same time, that is, there is neither a sectionalizing switch nor a tie switch between the communities, the value of the topological flexibility of ADNs is zero. Under such scenarios, the topological flexibility within the community can be used to distinguish different situations when there are no switches between the communities.

Computing Topological Flexibility Metric
Procedures to calculate the topological flexibility metric can be illustrated by the flowchart in Figure 2. First, the community structure of the distribution network is detected based on improved spectral clustering. Next, the division of switch types is given in consideration of the different functions and different locations of switches. Then, the topological flexibility within each community is calculated after sectionalizing topological flexibility, tie topological flexibility, and connectivity within the community are obtained. Finally, the overall topological flexibility metric is calculated based on the switches between communities.
Energies 2020, 13, x FOR PEER REVIEW 9 of 21 and reduces the solving scale of the problem. The proposed topological flexibility metric is deterministic, which [0, 1). In particular, when the parameters K and P in Formula (12) are zero at the same time, that is, there is neither a sectionalizing switch nor a tie switch between the communities, the value of the topological flexibility of ADNs is zero. Under such scenarios, the topological flexibility within the community can be used to distinguish different situations when there are no switches between the communities.

Computing Topological Flexibility Metric
Procedures to calculate the topological flexibility metric can be illustrated by the flowchart in Figure 2. First, the community structure of the distribution network is detected based on improved spectral clustering. Next, the division of switch types is given in consideration of the different functions and different locations of switches. Then, the topological flexibility within each community is calculated after sectionalizing topological flexibility, tie topological flexibility, and connectivity within the community are obtained. Finally, the overall topological flexibility metric is calculated based on the switches between communities.  This metric fulfills the role of a topological flexibility quantification method outlined in Section 2. Separate analyses are required to determine the acceptable value of the topological flexibility for an active distribution network and the appropriate switch combinations to be taken, should the distribution network possess insufficient topological flexibility.

Comparisons with the State of the Art Methods
The contributions of the proposed quantification method are summarized, and the comparisons with the state of the art methods are listed, as shown in Table 1. This metric fulfills the role of a topological flexibility quantification method outlined in Section 2. Separate analyses are required to determine the acceptable value of the topological flexibility for an active distribution network and the appropriate switch combinations to be taken, should the distribution network possess insufficient topological flexibility.

Comparisons with the State of the Art Methods
The contributions of the proposed quantification method are summarized, and the comparisons with the state of the art methods are listed, as shown in Table 1.

Contributions Comparisons
Topological flexibility quantification of active distribution networks (ADNs).
(1) This method quantifies the capability of ADNs to provide effective structural transformations based on the switch combination.
(2) Community detection is applied to partition the distribution network. (3) An improved spectral clustering algorithm is employed to achieve the significant dimensionality reduction of partition space.
The reconfiguration and the optimal allocation of distributed generation (DG) units are simultaneously achieved by using the meta heuristic harmony search algorithm, which is effective in reducing power loss and improving the voltage profile.
The topological reconfiguration is based on the fixed switch placement in the distribution network, hence it provides limited connectivity modes of the distribution network. However, the topological flexibility quantification method in this paper can measure the topological modification capability of ADNs without limiting the switch placement.
The approach minimizes the energy not supplied (ENS) by using sectionalizing and tie switches of different capacities with manual or automatic operation schemes.
The method uses switch combinations to minimize the ENS. Our approach gives a general description of the capability of switch combinations to bring structural changes to the distribution network.
The mixed-integer conic programming formulation is proposed to ensure the globally optimal solution of the distribution network reconfiguration problem.
The method uses the mixed-integer programming to solve the combination optimization problem. The method proposed in this paper can reduce the dimensionality of the combination optimization problem spatially after community detection.
Using reachability analysis approach to detect cyber-attack in a two-area power system [18].
The reachability framework is proposed to identify the impact that an intrusion might have in the automatic generation control loop.
This method obtains the reachable set of the continuous state of the power system under cyber-attacks. The topological flexibility quantification method proposed in this paper is to study the reachable set of the discrete structure space of ADNs.
Reliability evaluation of distribution networks based on accessibility analysis [41].
The method partitions the distribution networks and judges the failure consequence mode by using the accessibility matrix.
This method analyzes the connectivity of the power system by establishing an accessibility matrix, which is inherently different from the network structure reachable set that can be obtained through switch combinations in our method.

Case Study
In order to test and demonstrate the performance of the proposed topological flexibility method, four distribution systems from small to large scale are selected as the test grids. Table 2 summarizes the test systems by the number of nodes, number of feeders, and the number of tie-switches so that all test cases are converted to a new simple-to-parse format. They are all radial feeders. We default that their root node is the node that connected to the upstream grid, and the root node is also counted in the total number of nodes. Notably, the hypothetical test case "NDSU 881" is created by the North Dakota State University (NDSU) Power Group using data from test cases in [42].

Community Structure in ADNs
By improved spectral clustering, we get the results of community detection of these distribution networks, as shown in Table 2. It can be seen that the modularity values are all large, indicating that the community structure of these four networks is distinct, and the improved spectral clustering has a high quality of community detection. For the first three test cases mentioned in Table 2, the tie switches are all located between the communities, which indicates that the result of the community division corresponds to the switch installation locations. The community structure of "IEEE 33" is shown in Figure 1, and the community structure of "NDSU 881" is shown in Figure 3.

Case Study
In order to test and demonstrate the performance of the proposed topological flexibility method, four distribution systems from small to large scale are selected as the test grids. Table 2 summarizes the test systems by the number of nodes, number of feeders, and the number of tie-switches so that all test cases are converted to a new simple-to-parse format. They are all radial feeders. We default that their root node is the node that connected to the upstream grid, and the root node is also counted in the total number of nodes. Notably, the hypothetical test case "NDSU 881" is created by the North Dakota State University (NDSU) Power Group using data from test cases in [42].

Community Structure in ADNs
By improved spectral clustering, we get the results of community detection of these distribution networks, as shown in Table 2. It can be seen that the modularity values are all large, indicating that the community structure of these four networks is distinct, and the improved spectral clustering has a high quality of community detection. For the first three test cases mentioned in Table 2, the tie switches are all located between the communities, which indicates that the result of the community division corresponds to the switch installation locations. The community structure of "IEEE 33" is shown in Figure 1, and the community structure of "NDSU 881" is shown in Figure 3.    Energies 2020, 13,4786 For the community structure of "NDSU 881," we simplified it to obtain the relationship between the installation locations of tie switches and the communities, as shown in Figure 4, where the red numbers denote the labels of communities, the black dashed lines denote the installation locations of tie switches, and the black number "2" denotes that there are two tie switches between the communities. After community detection, the NDSU 881-node network is divided into 15 communities. The total number of tie switches installed in the NDSU 881-node network is 27, of which 26 are inter-community switches. For communities with higher average node topology potential, there will be repeated interconnections by the tie switches between communities in pairs. Energies 2020, 13, x FOR PEER REVIEW 12 of 21 For the community structure of "NDSU 881," we simplified it to obtain the relationship between the installation locations of tie switches and the communities, as shown in Figure 4, where the red numbers denote the labels of communities, the black dashed lines denote the installation locations of tie switches, and the black number "2" denotes that there are two tie switches between the communities. After community detection, the NDSU 881-node network is divided into 15 communities. The total number of tie switches installed in the NDSU 881-node network is 27, of which 26 are intercommunity switches. For communities with higher average node topology potential, there will be repeated interconnections by the tie switches between communities in pairs. In order to verify the adaptability of topological flexibility studies, a set of numerical experiments was performed. On the one hand, the universality of distribution networks' community structure is verified by the high modularity. Even a large-scale distribution network has a limited number of communities. On the other hand, using the switch locations determined by experience in most pieces of literature as the verification criterion, the corresponding relationship between the switches and the communities in the distribution network is found, which provides a realistic basis for the definition of topological flexibility metric based on the community structure.

Efficiency of Topological Flexibility Quantification Method
In order to analyze the characteristics of distribution network structure reflected by the topological flexibility, that is, the specific changes brought about by the change of topological flexibility to the distribution network structure, the shortest path, node closeness, degree centrality, and betweenness centrality in graph theory [45] are introduced to compare with the topological flexibility metric.
Sectionalizing switch and tie switch have different guiding roles in the distribution network structure. Therefore, through the analysis of the "IEEE 33" test case, the influence of sectionalizing switch and tie switch on the topological flexibility metric and the related graph theory metrics are studied separately.
For tie switches, the two metrics of average shortest path and average node closeness in graph theory are used for comparison and verification, and the two situations of increasing the number of switches and the different locations when the number of switches is fixed are considered respectively. It should be noted that when the number of switches is fixed, the switch allocation scheme is set randomly, and the five switch allocation schemes are not arranged according to increasing topological flexibility.
In Figure 5a, it can be seen that as the number of tie switches gradually increases, the topological flexibility metric gradually increases, while the average shortest path decay with the number of tie switches, showing a negative correlation between the two metrics. That is because, with the increase of tie switches, the number of connected paths that the distribution network can provide increases. The useful topological patterns increase, hence the topological flexibility increases. At the same time, as the provided paths between nodes increase, the shortest paths between node pairs decreases. For a fixed number of switches in Figure 5c, an allocation scheme with more considerable topological flexibility has a smaller average shortest path, and the two metrics conform to the negative correlation. For average node closeness in Figure 5b,d, as the shortest paths between the node and all other nodes decreases, the proximity between the node and other nodes increases, and therefore, the average node closeness will gradually rise. No matter whether the number or location of the tie switch is changed, In order to verify the adaptability of topological flexibility studies, a set of numerical experiments was performed. On the one hand, the universality of distribution networks' community structure is verified by the high modularity. Even a large-scale distribution network has a limited number of communities. On the other hand, using the switch locations determined by experience in most pieces of literature as the verification criterion, the corresponding relationship between the switches and the communities in the distribution network is found, which provides a realistic basis for the definition of topological flexibility metric based on the community structure.

Efficiency of Topological Flexibility Quantification Method
In order to analyze the characteristics of distribution network structure reflected by the topological flexibility, that is, the specific changes brought about by the change of topological flexibility to the distribution network structure, the shortest path, node closeness, degree centrality, and betweenness centrality in graph theory [45] are introduced to compare with the topological flexibility metric.
Sectionalizing switch and tie switch have different guiding roles in the distribution network structure. Therefore, through the analysis of the "IEEE 33" test case, the influence of sectionalizing switch and tie switch on the topological flexibility metric and the related graph theory metrics are studied separately.
For tie switches, the two metrics of average shortest path and average node closeness in graph theory are used for comparison and verification, and the two situations of increasing the number of switches and the different locations when the number of switches is fixed are considered respectively. It should be noted that when the number of switches is fixed, the switch allocation scheme is set randomly, and the five switch allocation schemes are not arranged according to increasing topological flexibility.
In Figure 5a, it can be seen that as the number of tie switches gradually increases, the topological flexibility metric gradually increases, while the average shortest path decay with the number of tie switches, showing a negative correlation between the two metrics. That is because, with the increase of tie switches, the number of connected paths that the distribution network can provide increases. The useful topological patterns increase, hence the topological flexibility increases. At the same time, as the provided paths between nodes increase, the shortest paths between node pairs decreases. For a fixed number of switches in Figure 5c, an allocation scheme with more considerable topological flexibility has a smaller average shortest path, and the two metrics conform to the negative correlation. For average node closeness in Figure 5b,d, as the shortest paths between the node and all other nodes decreases, the proximity between the node and other nodes increases, and therefore, the average node closeness will gradually rise. No matter whether the number or location of the tie switch is changed, average node closeness is positively correlated with the topological flexibility. The above verifies the correctness of topological flexibility metric in the definition of tie switches' effectiveness.
Energies 2020, 13, x FOR PEER REVIEW 13 of 21 average node closeness is positively correlated with the topological flexibility. The above verifies the correctness of topological flexibility metric in the definition of tie switches' effectiveness. For sectionalizing switches, two metrics of average degree centrality and average betweenness centrality in graph theory are introduced, and the two situations where the number of switches increases and the positions are different when the number of switches is fixed are also considered respectively.
The centrality of a node reflects the importance of the node in the network. When the centrality of a node is much higher than that of other nodes, it will have a more significant impact on the system when it is attacked. If there is a corresponding sectionalizing switch to provide isolation at this time, it will significantly increase the robustness of the system. Due to the isolation effect of sectionalizing switches, the deductibility of the node-pair connection is adopted when calculating the average degree centrality and average betweenness centrality. That is, the installation of a sectionalizing switch is equivalent to the disconnection of connection line when calculating degree centrality and betweenness centrality.
In Figure 6a,b, as sectionalizing switches increase, the number of disconnectable connections increases, and the topological transformation that the distribution network can provide increases, hence the topological flexibility gradually increases. With the decrease of node-pair connections, the influence of nodes on other nodes is also reduced, and the average degree centrality is decreasing in Figure 6a. Hence, the two metrics of topological flexibility and average degree centrality are in a negative correlation. When the number of sectionalizing switches is fixed in Figure 6c, changing the allocation scheme can change the topological flexibility. Since the degree centrality is only affected by the number of connections between nodes and has nothing to do with the position, the average degree centrality remains unchanged. For sectionalizing switches, two metrics of average degree centrality and average betweenness centrality in graph theory are introduced, and the two situations where the number of switches increases and the positions are different when the number of switches is fixed are also considered respectively.
The centrality of a node reflects the importance of the node in the network. When the centrality of a node is much higher than that of other nodes, it will have a more significant impact on the system when it is attacked. If there is a corresponding sectionalizing switch to provide isolation at this time, it will significantly increase the robustness of the system. Due to the isolation effect of sectionalizing switches, the deductibility of the node-pair connection is adopted when calculating the average degree centrality and average betweenness centrality. That is, the installation of a sectionalizing switch is equivalent to the disconnection of connection line when calculating degree centrality and betweenness centrality.
In Figure 6a,b, as sectionalizing switches increase, the number of disconnectable connections increases, and the topological transformation that the distribution network can provide increases, hence the topological flexibility gradually increases. With the decrease of node-pair connections, the influence of nodes on other nodes is also reduced, and the average degree centrality is decreasing in Figure 6a. Hence, the two metrics of topological flexibility and average degree centrality are in a negative correlation. When the number of sectionalizing switches is fixed in Figure 6c, changing the allocation scheme can change the topological flexibility. Since the degree centrality is only affected by the number of connections between nodes and has nothing to do with the position, the average degree centrality remains unchanged. Similarly, with the disconnection of sectionalizing switches in Figure 6b, the average betweenness centrality of the network is decreasing, and it has a negative correlation with the topological flexibility. It can be seen that as long as there is a certain number of sectionalizing switches for isolation, it will significantly reduce the network's average betweenness centrality. After a fixed number of sectionalizing switches are installed in Figure 6d, the allocation with larger topological flexibility corresponds to smaller average betweenness centrality. The above verifies the correctness of topological flexibility metric in the definition of sectionalizing switches' effectiveness.
These numerical experiments verify the applicability of the topological flexibility metric for changing the switch type, switch number, and switch position. By comparing the topological flexibility metric with several structural feature quantities based on graph theory, the geometric properties of the distribution network topology reflected in the topological flexibility metric are analyzed, which proves the efficacy and accuracy of the proposed metric.

Diminishing Marginal Utility of the Topological Flexibility Metric
At the beginning of defining the topological flexibility metric, the denominators of the tie topological flexibility within and between communities in the metric were initially fixed to the saturation number of each type of switch. In the IEEE 33-node test feeder, the number of switches allocated is uniformly sampled at 10% intervals. Then the positions of switches are optimized according to the genetic algorithm to obtain the maximum system topological flexibility defined by the primary metric and its marginal utility. The marginal utility here refers to the increase in topological flexibility brought to the system after the installation of a switch. Similarly, with the disconnection of sectionalizing switches in Figure 6b, the average betweenness centrality of the network is decreasing, and it has a negative correlation with the topological flexibility. It can be seen that as long as there is a certain number of sectionalizing switches for isolation, it will significantly reduce the network's average betweenness centrality. After a fixed number of sectionalizing switches are installed in Figure 6d, the allocation with larger topological flexibility corresponds to smaller average betweenness centrality. The above verifies the correctness of topological flexibility metric in the definition of sectionalizing switches' effectiveness.
These numerical experiments verify the applicability of the topological flexibility metric for changing the switch type, switch number, and switch position. By comparing the topological flexibility metric with several structural feature quantities based on graph theory, the geometric properties of the distribution network topology reflected in the topological flexibility metric are analyzed, which proves the efficacy and accuracy of the proposed metric.

Diminishing Marginal Utility of the Topological Flexibility Metric
At the beginning of defining the topological flexibility metric, the denominators of the tie topological flexibility within and between communities in the metric were initially fixed to the saturation number of each type of switch. In the IEEE 33-node test feeder, the number of switches allocated is uniformly sampled at 10% intervals. Then the positions of switches are optimized according to the genetic algorithm to obtain the maximum system topological flexibility defined by the primary Energies 2020, 13, 4786 15 of 21 metric and its marginal utility. The marginal utility here refers to the increase in topological flexibility brought to the system after the installation of a switch.
As shown in Figure 7a, the unrevised topological flexibility metric increases indefinitely with the number of switches. When the number of switches installed is large enough, the value of the topological flexibility metric may even exceed 1. It is found that there is a large number of repeated tie switches between the same communities in pairs. That is because tie switches can be installed between any two nodes, unlike the sectionalizing switches, which are limited to the laid power lines. In the topological flexibility metric, the repeated tie switches are treated the same as the general switch, and tie switches are not restricted to avoid unlimited repeated allocations. The marginal utility of the maximum system topological flexibility in Figure 7b is continuously oscillating, indicating that the output of the system's topological flexibility value is not stable. Therefore, the effectiveness of repeated tie switches should be discounted in the topological flexibility metric to avoid unlimited increases in the metric.
Energies 2020, 13, x FOR PEER REVIEW 15 of 21 As shown in Figure 7a, the unrevised topological flexibility metric increases indefinitely with the number of switches. When the number of switches installed is large enough, the value of the topological flexibility metric may even exceed 1. It is found that there is a large number of repeated tie switches between the same communities in pairs. That is because tie switches can be installed between any two nodes, unlike the sectionalizing switches, which are limited to the laid power lines. In the topological flexibility metric, the repeated tie switches are treated the same as the general switch, and tie switches are not restricted to avoid unlimited repeated allocations. The marginal utility of the maximum system topological flexibility in Figure 7b is continuously oscillating, indicating that the output of the system's topological flexibility value is not stable. Therefore, the effectiveness of repeated tie switches should be discounted in the topological flexibility metric to avoid unlimited increases in the metric. The tie switches mainly cause the situation where the optimal number of switches exceeds its saturation. In order to avoid the excessively repeated liaison between the same communities in pairs, the topological flexibility metric has been corrected, as shown in Formulas (11) and (13). For intracommunity tie switches and inter-community tie switches respectively, if the number of tie switches allocated exceeds the saturation number, the denominator is revised to the number of tie switches allocated, which weakens the topological flexibility of repeated liaisons, avoids the excessively repeated tie switches, and also allows the existence of some necessary duplicate liaisons. Simulation results are better after revising the topological flexibility metric, as shown in Figure 8. The tie switches mainly cause the situation where the optimal number of switches exceeds its saturation. In order to avoid the excessively repeated liaison between the same communities in pairs, the topological flexibility metric has been corrected, as shown in Formulas (11) and (13). For intra-community tie switches and inter-community tie switches respectively, if the number of tie switches allocated exceeds the saturation number, the denominator is revised to the number of tie switches allocated, which weakens the topological flexibility of repeated liaisons, avoids the excessively repeated tie switches, and also allows the existence of some necessary duplicate liaisons. Simulation results are better after revising the topological flexibility metric, as shown in Figure 8.
After revising the topological flexibility metric, the maximum system topological flexibility gradually increases with the number of switches. When the maximum system topological flexibility reaches the maximum value of 0.8631, the corresponding optimal switch allocation number is 38. The changing trend of topological flexibility metric can be explained by the law of diminishing marginal utility as follows.
Under the premise that other conditions remain unchanged, the marginal utility will increase with the number of switches at the beginning, that is, the maximum system topological flexibility will increase substantially. After a considerable number of switches are installed, the marginal utility will gradually decrease, and the growth rate of the corresponding maximum system topological flexibility will decrease. When the marginal utility decreases to zero, it means the total maximum system topological flexibility will no longer increase cumulatively. If the marginal utility is reduced to negative, the total maximum system topological flexibility will also gradually decrease.
As shown in Figure 8, when a certain number of switches are installed, the maximum system topological flexibility conforms to the law of diminishing marginal utility that gradually entering ideal circumstances, and the final marginal utility stabilizes at around zero, which proves that the output of the value of the maximum system topological flexibility is stable. metric is not revised. (a) Maximum system topological flexibility and its marginal utility; (b) marginal utility of the maximum system topological flexibility.
The tie switches mainly cause the situation where the optimal number of switches exceeds its saturation. In order to avoid the excessively repeated liaison between the same communities in pairs, the topological flexibility metric has been corrected, as shown in Formulas (11) and (13). For intracommunity tie switches and inter-community tie switches respectively, if the number of tie switches allocated exceeds the saturation number, the denominator is revised to the number of tie switches allocated, which weakens the topological flexibility of repeated liaisons, avoids the excessively repeated tie switches, and also allows the existence of some necessary duplicate liaisons. Simulation results are better after revising the topological flexibility metric, as shown in Figure 8.

Influence of Switch Allocation on Topological Flexibility Metric
In the IEEE 33-node test feeder, the influences of switch combinations on the topological flexibility metric are studied to provide guidance for switch allocation.
The optimal number of sectionalizing switches corresponding to the maximum system topological flexibility is studied with the total number of switches. Noticeably, the total number of switches minus the number of sectionalizing switches is the number of tie switches.
The curve in Figure 9 shows the changing trend of the optimal number of sectionalizing switches. When the total number of switches is small, the proportion of sectionalizing switches is larger than that of tie switches to achieve the optimal topological flexibility. It means that sectionalizing switches can increase more system topological flexibility than tie switches when the total number of switches is small. When the total number of switch reaches a certain level, in order to obtain the optimal topological flexibility, the number of sectionalizing switches is fixed within a specific range, and the increase of topological flexibility mainly depends on the increase of tie switches.
The variation of the maximum system topological flexibility with the number of sectionalizing switches is analyzed in Figure 10 when the total number of switches is fixed in different allocations.
It can be seen that when the total number of switches installed is fixed, the difference in switch installation positions also affects the topological flexibility of the system. This is because the proposed topological flexibility quantification method focuses on the effective structure rather than just the number of structures that the distribution network can provide, where the measure of the effective structure is based on the positions of switches. Taking the total number of switches is 14 as an example, we have obtained the optimal topological flexibility of the system when the number of installed sectionalizing switches is from 0 to 14, corresponding to 15 configuration schemes with different switch installation positions. Even when the number of sectionalizing switches is fixed at a certain value, the difference in switch positions will affect the topology flexibility of ADNs. We optimize the position of the switch by using genetic algorithm, and find the maximum value of the system topology flexibility under the corresponding switch number allocation plan.
The maximum system topological flexibility gradually increases with the number of sectionalizing switches when the total number of switches is small, and its growth rate is tremendous. When switches are allocated to a certain number, the diminishing marginal effect of the maximum system topological flexibility with the sectionalizing switch will appear. Except for the case where the total number of switches is 5, the curves almost overlap when the number of sectionalizing switches is small in other allocations, indicating that the maximum system topological flexibility at this time is greatly affected by the sectionalizing switches. When the total number of switches reaches 42, the changing trend of the maximum system topological flexibility is almost unchanged with the increase of switches. It indicates that the number of switches required to get maximum system topological flexibility of the IEEE 33-node test feeder is around 42, then no more switches are needed. That gives the optimal interval for the number of switches installed, and the best guidance based on topological flexibility for switch allocation is obtained.
ideal circumstances, and the final marginal utility stabilizes at around zero, which proves that the output of the value of the maximum system topological flexibility is stable.

Influence of Switch Allocation on Topological Flexibility Metric
In the IEEE 33-node test feeder, the influences of switch combinations on the topological flexibility metric are studied to provide guidance for switch allocation.
The optimal number of sectionalizing switches corresponding to the maximum system topological flexibility is studied with the total number of switches. Noticeably, the total number of switches minus the number of sectionalizing switches is the number of tie switches.
The curve in Figure 9 shows the changing trend of the optimal number of sectionalizing switches. When the total number of switches is small, the proportion of sectionalizing switches is larger than that of tie switches to achieve the optimal topological flexibility. It means that sectionalizing switches can increase more system topological flexibility than tie switches when the total number of switches is small. When the total number of switch reaches a certain level, in order to obtain the optimal topological flexibility, the number of sectionalizing switches is fixed within a specific range, and the increase of topological flexibility mainly depends on the increase of tie switches. The variation of the maximum system topological flexibility with the number of sectionalizing switches is analyzed in Figure 10 when the total number of switches is fixed in different allocations. It can be seen that when the total number of switches installed is fixed, the difference in switch installation positions also affects the topological flexibility of the system. This is because the proposed topological flexibility quantification method focuses on the effective structure rather than just the number of structures that the distribution network can provide, where the measure of the effective structure is based on the positions of switches. Taking the total number of switches is 14 as an example, we have obtained the optimal topological flexibility of the system when the number of installed sectionalizing switches is from 0 to 14, corresponding to 15 configuration schemes with different switch

Application of Topological Flexibility Quantization to Multi-Scale ADNs
In the distribution networks of different scales shown in Table 2, the number of switches allocated is uniformly sampled at 10% intervals, and then switch positions are optimized based on topological flexibility according to the genetic algorithm. The variation of the maximum system topological flexibility of each distribution network with the number of switches is shown in Figure 11. In order to put the topological flexibility of different networks into a graph for comparison, the proportion of switches is used as the abscissa. The proportions are based on the total saturation number of all switches, that is, the upper limit of the recommended number of switches is taken as the base of 100%. The definition of the switch saturation number is described in Section 3.2.
Energies 2020, 13, x FOR PEER REVIEW 18 of 21 topological flexibility according to the genetic algorithm. The variation of the maximum system topological flexibility of each distribution network with the number of switches is shown in Figure  11. In order to put the topological flexibility of different networks into a graph for comparison, the proportion of switches is used as the abscissa. The proportions are based on the total saturation number of all switches, that is, the upper limit of the recommended number of switches is taken as the base of 100%. The definition of the switch saturation number is described in Section 3.2. As shown in Figure 11, the maximum topological flexibility of all systems gradually increases to their optimal topological flexibility level with the number of switches. But due to the law of diminishing marginal utility, the maximum topological flexibility decay with the number of switches after a certain number of switches are installed. Some networks reach the saturation value of the maximum topological flexibility when the number of switches reaches 70%, 80%, etc. It is reasonable because the base of 100% of the number of switches is not C 2 N (N is the total number of nodes), but the saturation number of switches specified for each system. For the "IEEE 33" test case, the total saturation number of switches is only 47, so the proportion of switches corresponding to the maximum topological flexibility will be relatively high. When the number of switches installed reaches a certain level, even a solution with a smaller number of switches will provide a higher system topological flexibility than another solution with a larger number of switches, as shown in Figure 11. This is because, in this scenario, the positions of the switches are effective enough, and the increased switches at this time will weaken the marginal utility of topological flexibility.
The topological flexibility value of the system has nothing to do with the scale of the system, and the maximum topological flexibility saturation level is limited by the system topology. Among the distribution networks, the maximum topological flexibility value of the "IEEE 123" test case is less than 0.7. That is because the topological flexibility of the system is not only affected by the switch allocation but also restricted by its laid power supply lines. The switch is to realize the adjustment of the network topology on the premise that the power supply lines are fixed and then give full play to the topological flexibility level of the distribution network. Therefore, the topological flexibility potential of the distribution network is tapped through the switches.

Conclusions
A method to quantify the topological flexibility of ADNs based on community detection is proposed in this paper. The topological flexibility is the ability of ADNs to provide effective topological changes in response to the operating uncertainty. The community structures of ADNs are detected by using As shown in Figure 11, the maximum topological flexibility of all systems gradually increases to their optimal topological flexibility level with the number of switches. But due to the law of diminishing marginal utility, the maximum topological flexibility decay with the number of switches after a certain number of switches are installed. Some networks reach the saturation value of the maximum topological flexibility when the number of switches reaches 70%, 80%, etc. It is reasonable because the base of 100% of the number of switches is not C 2 N (N is the total number of nodes), but the saturation number of switches specified for each system. For the "IEEE 33" test case, the total saturation number of switches is only 47, so the proportion of switches corresponding to the maximum topological flexibility will be relatively high. When the number of switches installed reaches a certain level, even a solution with a smaller number of switches will provide a higher system topological flexibility than another solution with a larger number of switches, as shown in Figure 11. This is because, in this scenario, the positions of the switches are effective enough, and the increased switches at this time will weaken the marginal utility of topological flexibility.
The topological flexibility value of the system has nothing to do with the scale of the system, and the maximum topological flexibility saturation level is limited by the system topology. Among the distribution networks, the maximum topological flexibility value of the "IEEE 123" test case is less than 0.7. That is because the topological flexibility of the system is not only affected by the switch allocation but also restricted by its laid power supply lines. The switch is to realize the adjustment of the network topology on the premise that the power supply lines are fixed and then give full play to the topological flexibility level of the distribution network. Therefore, the topological flexibility potential of the distribution network is tapped through the switches.

Conclusions
A method to quantify the topological flexibility of ADNs based on community detection is proposed in this paper. The topological flexibility is the ability of ADNs to provide effective topological changes in response to the operating uncertainty. The community structures of ADNs are detected by using an improved spectral clustering algorithm. A topological flexibility metric is defined as the valid number of sectionalizing and tie switches between communities. Case study results demonstrate the effectiveness and efficiency of the proposed quantification method. The practicability of the topological flexibility quantification method of ADNs is demonstrated by applying the proposed method to distribution networks of different scales. The method enables characterizing the high-dimensionality discrete structures by the improved spectral clustering algorithm, which avoids the curse of dimensionality. Then, computing topological flexibility metric can be completed in polynomial time, which is suitable for large-scale ADNs.
When the distribution network's structure is relatively uniform in every part, aggregation characteristics of nodes are not obvious, leading to similar structure of each community. At this time, the value of topological flexibility is more sensitive to the number of switches but less sensitive to the positions of the switches. The values of the topological flexibility metric conform to the law of diminishing marginal utility when the quantity of switches in ADNs reaches a certain number. It naturally provides a research perspective on the optimal placement of switches to improve the topological flexibility of ADNs, which is the further work we are concentrated on. Besides, power electronic converters such as soft normally open points can bring topological transformation to the distribution network, and considering the influence of the power electronic converters on topological flexibility is the research direction of our further work to adapt to the development of smart grids.