In remote areas, large power stations are often installed to supply local loads due to the difficulties of power transmission. However, with the development of renewable energies and poverty alleviation programs, many renewable energy stations have been installed in such areas. This large amount of surplus and fluctuating energy causes a poor voltage quality, and this problem is difficult to solve with traditional methods. Adding transmission lines can be a feasible solution, but the related research is limited. To provide a guideline for this solution, a network optimization algorithm is proposed in this paper. In the process, a sub-grid that is far from the national grid with an imbalanced power supply and demand is connected to the national grid directly to improve the power quality. First, the linear performance index power mileage is defined to facilitate the calculation and help denote the voltage quality. Then, an iterative algorithm is formed to perform the network optimization and automatically choose the number of clusters. A case study of an actual power grid in Chongqing, China, and an IEEE 123-bus case are used to verify our algorithm. The results show there is a great improvement in the voltage profile.