title: Point Clustering algorithm
body: <p>I need help to solve a geometry problem .
  Consider a set of points.
  We note the number of points N.</p>
  <p>We note d the euclidienne distance and dmax a value.</p>
  <p>Two points p1 and p2 are connected if and only if the distance d(p1,p2)&lt;dmax.</p>
  <p>The problem is to create an algorithm that returns a list of the size of connected components.</p>
  <p>For example in the figure below the algorithm should return</p>
  <p>[3, 2, 4, 1]</p>
  <p>I drawed the connections in red but initially we only have the points (here in black). If needed the program should calculate all the connections.
  <a href="https://i.stack.imgur.com/nTTRc.jpg" rel="nofollow noreferrer">figure below </a></p>
  <p>I have two algorithm one iterative and the other recursive. I used a DBScan. But it is not fast enough. Yhe complexity is O(N^2)</p>
  <p>I need it to be faster with if possible an O(N) or O(N*log(N)).</p>
  <p>I read about DFS but i am not really sure...</p>
  <p>Thanks for help</p>