## 3 Methodology
### Reconfiguration Algorithm  
Reconfiguration in radial distribution networks is a process that modifies the network topology by opening or closing line switches in response to changes in demand and generation conditions. The main goal of reconfiguration is to improve the network's efficiency and reliability while preserving its radial structure, which simplifies the operation and control of the power system [44]. This process is essential for balancing loads, minimizing power losses, and responding to faults or maintenance needs without disrupting the overall power supply.  
Graph theory provides a robust mathematical framework to model and analyze electrical distribution networks. In this context, the network is represented as a graph, where nodes (or vertices) correspond to buses, and edges (or branches) represent the power lines connecting these buses. It provides a robust mathematical framework to model and analyze electrical distribution networks, aiding in their reconfiguration. In [45], the authors demonstrated the use of graph theory to efficiently handle network reconfiguration in DC zonal electric distribution systems. The authors utilized graph-based numerical methods to solve optimization problems, ensuring power balance while minimizing switching operations. Similarly, Ref. [46] integrated graph theory with particle swarm optimization to minimize power loss and enhance the voltage profiles in distribution systems, highlighting the method's feasibility for network reconfiguration. One of the main challenges in reconfiguring electrical distribution networks is ensuring that the network maintains a radial (tree-like) structure. Graph theory aids in this process by enabling the identification of redundant paths (cycles) and facilitating the calculation of feasible network topologies. Using techniques such as cycle identification, minimum spanning trees, and adjacency matrices, graph theory helps to simplify and streamline the reconfiguration process, making it more efficient. To develop the reconfiguration method presented in this work, various MATLAB functions were utilized to facilitate each of the necessary tasks. These functions provided robust tools for the analysis and manipulation of electrical networks, simplifying and optimizing each stage of the reconfiguration algorithm. The process is divided into five key steps:  
1. Graph Representation: The network is represented as an undirected graph \(G(V,E)\) where \(V\) is the set of buses and \(E\) is the set of branches. The adjacency matrix \(A\) describes the network connectivity, providing a foundation for further analysis. The MATLAB function _graph_ is used to construct this representation [47].
2. Identification of Fundamental Cycles: Fundamental cycles, which represent redundant paths that break the radial structure, are identified using MATLAB's _cyclebasis_ function [48]. These cycles are the primary targets for branch elimination to ensure the network maintains a radial configuration.
3. Generation of Radial Configurations: All possible radial configurations are generated by selectively eliminating branches from the identified fundamental cycles. The MATLAB _nchoosek_ function [49] is employed to calculate all possible combinations of branch elimination, ensuring that only unique configurations are considered.
4. Radiality Verification: Each generated configuration is checked for radiality using the _cyclebasis_ function again. Any configuration that still contains cycles is discarded, ensuring that only valid radial topologies are retained.
5. Bus Reorganization and Branch Orientation: Before performing load flow analysis, the buses are reorganized according to their hierarchical structure. A minimum spanning tree is generated using MATLAB's _minspantree_ function [50], ensuring correct orientation and connectivity from the root bus towards the leaves.  
This structured approach reduces computational complexity by focusing on branch elimination within detected cycles, enabling the efficient generation and evaluation of radial configurations.