What is the best machine learning algorithm for clustering dots based on coordinates $(x,y)$ with consideration of weight of the points?

I'm looking for a machine learning algorithm for clustering points based on their coordinates. Furthermore, I want to take into consideration the weights of each point. Suppose there is a weight in each point. Then we take the sum of the weight of all the points in a cluster. I want the sum in different clusters to be close and balanced. What algorithm is best for this? Any suggestion?

• Maybe try to use weights as 'z' coordinate and perform k-means clustering. I don't know if that's the best approach though. Dec 16 '21 at 7:25
• if z is weight, then all the points with greater weight will be packed together isn't it? Then the sum of them will be the biggest? Am I right? Dec 17 '21 at 2:04
• Oh, I misunderstood Your question. You just have (x, y) coordinates and want to perform basic clustering? Just google clustering algorithms like k-means, DBSCAN, BIRCH or mean-shift. You don't need to add any weight to Your data. Dec 17 '21 at 9:34
• ok, this solves my first problem. But what if each point has a weight. So how I make the total weight in a cluster is similar to others? Using kmeans,.... will only consider their locations and cluster them together and not considering the weight of the points. Dec 20 '21 at 3:07
• just assume the weight as a third parameter. However, I cannot simply put it as 'z' coordinates and do clustering. Because this will pack those 'heavier' points together and making clusters not balanced Dec 20 '21 at 4:26