This study develops a novel distributed algorithm for task assignment (TA), coordination, and communication of multiple unmanned aerial vehicles (UAVs) engaging multiple targets and conceives an ad hoc routing algorithm for synchronization of target lists utilizing a distributed computing topology. Assuming limited communication bandwidth and range, coordination of UAV motion is achieved by implementing a simple behavioral flocking algorithm utilizing a tree topology for distributed flight coordination. Distributed TA is implemented by a relaxation process, wherein each node computes a temporary TA based on the union of the TAs of its neighbors in the tree. The computation of the temporary TAs at each node is based on weighted matching in the UAV-target distances graph. A randomized sampling mechanism is used to propagate TAs among different parts of the tree. Thus, changes in the location of the UAVs and targets do not pass through the root of the tree. Simulation experiments show that the combination of the flocking and the TA algorithms yields the best performance.