In order to obtain the optimal wiring layout of substation, the general model of power system is introduced. Based on this, the force-directed algorithm, genetic algorithm, graph community clustering algorithm and depth first search algorithm are analyzed. The above four algorithms are used to automatically generate the primary electric wiring diagram of a 35 kV distribution network, and the calculation time and other performance are compared. The results show that the calculation time of the force-directed algorithm is shorter, but there are too many crossing points. The genetic algorithm requires too many iterations and has poor real-time performance. However, as long as the parameters are selected properly and the number of iterations is enough, the algorithm will tend to the optimal solution. Both the graph community clustering algorithm and depth first search algorithm have shorter calculation time, but the former is not easy to obtain the optimal solution, while the latter can maintain the speed and obtain the optimal solution at the same time.