Ask Your Question
2

K means question

asked Aug 14 '15

mrzl gravatar image

updated Dec 21 '15

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

Preview: (hide)

1 answer

Sort by » oldest newest most voted
6

answered Aug 15 '15

berak gravatar image

updated Aug 15 '15

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());
Preview: (hide)

Question Tools

1 follower

Stats

Asked: Aug 14 '15

Seen: 1,306 times

Last updated: Aug 14 '15