An algorithm for reconnecting Wireless Sensor Network partitions