Ask Your Question

K means question

asked 2015-08-14 13:18:51 -0500

mrzl gravatar image

updated 2015-12-21 03:05:28 -0500

Hey everybody,

I'm currently in the process of clustering a set of points into different sections. Though, the k means algorithm requires me to explicitly set the number of clusters to divide the set of points in. Is there an alternative algorithm, where I can pass in a set of points and a maximum distance, which divides point clusters from each other? What I would like to have returned is a list of clusters of yet unknown size, containing a sub-set of points.

I would be very thankful for any directions.

Thanks, Marcel

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2015-08-14 23:24:38 -0500

berak gravatar image

updated 2015-08-14 23:40:22 -0500

yes, you can use partition with a distance functor:

struct Dist {
    bool operator()(const Point& a, const Point &b) {
           return sqrt((a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y)) < 15;

vector<Point> input = ...;
vector<int> labels;

partition(input, labels, Dist());
edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2015-08-14 13:18:51 -0500

Seen: 397 times

Last updated: Aug 14 '15