This paper presents a cooperative, distance-based, distributed control law for multiple Autonomous Underwater Vehicles (AUVs) executing a mission while meeting mutual communications constraints. The classic graph theory provides the essential tools to model the whole network of interacting robots, which is then handled within the energy-based, port - Hamiltonian framework. The virtual interaction forces generated over each link are represented by visco-elastic couplings. The passivity theory allows the construction of a Lyapunov function for the closed loop system to demonstrate the stability in large of the whole network with the synthesized control law. Moreover, always using passivity-based techniques, the behaviour of the group is made as flexible as possible with arbitrary split and join events. Several software simulations, involving a team or sub-teams of agents that perform typical missions in marine environment, show the effectiveness of the proposed approach.