I have a massive distance matrix of clusters. The distance matrix is the distance between each cluster. I now need to recluster each entity based on two constraints. Each cluster has an associated volume.  The constraints are a max volume and min distance. I want to scan for the minimum distance and if neighbor cluster falls within this minimum distance AND if the summation of the volume does not exceed max volume, then that forms a new cluster. I want it to do this for all clusters. Ive been struggling with creating an algorithm for this. Is there any algorithm that can help?
Update existing clusters to satisfy distance and volume constraints
clustering;optimization;algorithms