0

Hello all,

I am trying to write a clustering algorithm where, given location of certain points (I.e, latitude and longitude) I need to choose 50 of these to be cluster centers such that the diameter of each cluster is minimized. To that end, I believe that the program should choose the next center to be the point that is farthest away from all the previous centers. This is the algorithm I am working on, however, I believe it is not working properly because it chooses points that are very close to each other to be centers:

```
while number of centers <= 50 {
max_dist = -9999
for each point not a center {
min_dist = 9999
for each center {
distance = (distance between current non center and current center)
if distance < min_dist {
min_dist = distance
}
}
if min_dist > max_dist {
max_dist = min_dist
next_center = current non center
}
}
numer of centers++
add next center to list of centers
erase next center from list of non centers
}
```

If anyone can offer any insight on this, I would greatly appreciate it. The algorithm seems to only be selecting points far away from the first center (which is chosen randomly outside of the above loop.)