With the advancement of science and technology, unmanned aerial vehicles (UAVs) are playing an increasingly important role across various fields, making multi-UAV formations a cutting-edge research area. This study establishes a UAV communication topology model based on graph theory and proposes a UAV motion model based on spatial position deviations. A distributed structure is then introduced to design a UAV control system model and establish a UAV formation coordination mechanism. Based on this, a coordination formation controller using a consensus algorithm, a task allocation strategy using the Hungarian algorithm, and an obstacle avoidance strategy are designed. Simulation experiments were conducted with a five-drone formation executing reconnaissance tasks and a triangular formation. The simulation results indicate that the designed control algorithm can maintain the formation of the drone formation, the proposed collaborative control strategy can achieve precise formation maintenance, and it can quickly and accurately track the predefined flight path. During formation flight, collisions between adjacent drones can be avoided, and the formation has excellent reconstruction capabilities, achieving stable and accurate collaborative formation.