Best way to fuse clusters smaller than a certain size in a distributed way? I have X clusters of size (n1,n2...,nX) and I want to fuse small clusters with less than T members with the nearest adjacent cluster i.e. the nearest neighboring cluster.

The problem is when I've got two small neighbor clusters, A->B and B->A which create an infinite loop.

I try to avoid that by removing one of those which have this property [(A,B),(B,A)].

But is there a better way to accomplish this task in sequential way ?

Is it possible to do the trick in distributed way ( Spark ) ?
My suggestion is just a greedy brute force approach. I am sure that more efficient solutions may exist, but it may be a first step towards your final solution.

Store in a table, for each cluster which size is lesser than T, the distance to its closest neighbouring cluster and the ID of that closest cluster. 

Now, sort the table entries in ascending distance order. Merge the cluster in the first entry with its closest neighbouring one. If the closest cluster also had an entry in the table, and its size got larger than T, remove its corresponding entry. Finally, update all the entries of the table, and sort them in ascending distance order again.

Repeat the steps above until there are not more entries in the table.