In this paper, a method of 3D concrete printing is used to find the optimal path of the nozzle running path. We propose a path optimization algorithm based on graph theory to solve two key problems in 3D concrete printing. The partitioning algorithm based on graph theory was adopted to improve the forming quality of concrete components, and ant colony algorithm was used to reduce printing time. The method was evaluated with 3D concrete printing experiments after introducing the process of implementing the partition algorithm and ant colony algorithm. The experiment results show a significant reduction in the idle strokes and the nozzle head-up times of the running path planned by the method in this paper. This has a direct impact on shortening the printing time and improving the forming quality. Compared with the other three conventional algorithms, the idle strokes of the nozzle planned by the method in this paper are reduced by 18.94%, 37.88%, and 66.67%, and the nozzle head-up times are reduced by 1.59%, 2.15%, and 8.69%. It provides a practical reference for the path optimization of 3D concrete printing.