title: Cluster points stored in vector c++
body: <p>I have the following vector</p>
  
  <pre><code>{ Point(100, 200), Point(101, 202), Point(200, 200), 
    Point(201, 202), Point(203, 204), Point(100, 400), 
    Point(102, 402), Point(200, 400), Point(202, 401), Point(205, 405) };
  </code></pre>
  
  <p>The vector contains vertices of a rectangle and some neighboring points of vertices. I need to extract the rectangle vertices from these points meaning for Point <code>( 100, 200 )</code> and <code>( 101, 102 )</code> I just need one of them. Then for Points <code>( 200, 200 )</code>, <code>( 201, 202 )</code> , <code>( 203, 204 )</code> I just need one point (may be average or center of these neighbors) and so forth. It may be a triangle with similar distribution or just a line with two groups or a point with a single group. </p>
  
  <p>Kindly guide me how can I achieve this? Should I use Kmeans or if yes how? if not is there any other clustring algorithm to solve this issue.</p>