Given two points P,Q and a delta, I defined the equivalence relation ~=, where P ~= Q if EuclideanDistance(P,Q) <= delta. Now, given a set S of n points, in the example S = (A, B, C, D, E, F) and n = 6 (the fact points are actually endpoints of segments is negligible), is there an algorithm that has complexity better than O(n^2) in the average case to find a partition of the set (the representative element of the subsets is unimportant)?
Attempts to find theoretical definitions of this problem were unsuccessful so far: k-means clustering, nearest neighbor search and others seems to me different problems. The picture shows what I need to do in my application.
Any hint? Thanks

EDIT: while the actual problem (cluster near points given some kind of invariant) should be solvable in better better than O(n^2) in the average case, there’s a serious flaw in my problem definition: =~ is not a equivalence relation because of the simple fact it doesn’t respect the transitive property. I think this is the main reason this problem is not easy to solve and need advanced techiques. Will post very soon my actual solution: should work when near points all satisfy the =~ as defined. Can fail when poles apart points doesn’t respect the relation but they are in relation with the center of gravity of clustered points. It works well with my input data space, may not with yours. Do anyone know a full formal tratment of this problem (with solution)?
One way to restate the problem is as follows: given a set of
n2D points, for each pointpfind the set of points that are contained with the circle of diameterdeltacentred atp.A naive linear search gives the
O(n^2)algorithm you allude to.It seems to me that this is the best one can do in the worst case. When all points in the set are contained within a circle of diameter <=
delta, each ofnqueries would have to returnO(n)points, giving anO(n^2)overall complexity.However, one should be able to do better on more reasonable datasets.
Take a look at this (esp. the section on space partitioning) and KD-trees. The latter should give you a sub-
O(n^2)algorithm in reasonable cases.There might be a different way of looking at the problem, one that would give better complexity; I can’t think of anything off the top of my head.