A Distributed Approach to Connectivity Maintenance in Dynamic Sensor Networks