This is the next question about my other posts.
Size Limit Clustering Algorithm
I am working on a clustering algorithm. After some unfolding, I now have this set of points at which none of them are in their optimal cluster, but cannot be reassigned individually, since it will violate the restriction.
I am trying to use the graph structure to solve a problem, but have encountered several implementation problems.
I'm a newbie, please let me know if I'm wrong.
In response to @Kittsil
construct a directed graph with clusters as nodes, so that the edge (A, B) exists if the global solution is minimized by some point in A moving towards B. The search for cycles in this graph will allow you to find the potential (where the movement consists of the movement each vertex in the loop).
I revised the graph, adding weight as the sum of the number of points moving from A to B.
Here are some scenarios where I'm not sure how to decide at which point to reassign.
Scenario 1 . For the loop as shown below. There are two points that can be moved from A to B, and three from B to C. In this situation, which item should be selected for reassignment?

Scenario 2 . For the loop as shown below. Let all the weights of the edges be equal to 1. For a point in cluster A, it can be reassigned to either cluster B or D. In this case. How do I reassign?

Scenario 3 As in scenario 2. Let all the weights of the edges be equal to 1. In a larger cycle, there are two small cycles. A point in cluster A can be reassigned for both B and E, how can I decide, in this case reassignment?

Ideas for any scenario are welcome!
Also there are suggestions for the implementation of the algorithm, taking into account the above cases? Better yet with pseudo code. Thanks!