AbstractAt present, unmanned aerial vehicles (UAVs) have been widely used in communication systems, and the fifth-generation wireless system (5G) has further promoted the vigorous development of them. The trajectory planning of UAV is an important factor that affects the timeliness and completion of missions, especially in scenarios such as emergency communications and post-disaster rescue. In this paper, we consider an emergency communication network where a UAV aims to achieve complete coverage of potential underlaying device-to-device (D2D) users. Trajectory planning issues are grouped into clustering and supplementary phases for optimization. Aiming at trajectory length and sum throughput, two trajectory planning algorithms based on K-means are proposed, respectively. In addition, in order to balance sum throughput with trajectory length, we present a joint evaluation index. Then relying on this index, a third trajectory optimization algorithm is further proposed. Simulation results show the validity of the proposed algorithms which have advantages over the well-known benchmark scheme in terms of trajectory length and sum throughput.