An Energy Optimal Clustering Algorithm