title: How can I get the index of the Nearest Point when I use CGAL::K_neighbor_search to do the Nearest Neighbor Search?
body: <p>I am using CGAL's K_neighbor_search module to do the nearest neighbor search problem. It's nice and easily to use. The example code shows that given a query point, it can find the nearest neighbor point from a set of points as well as the distance. However, I can only get the nearest neighbor point itself. I don't know how to get the index of the point found by the algorithm.
  For example, I use the following code,</p>
  <pre><code>std::list&lt;Point_d&gt; points;
  Tree tree(points.begin(), points.end());
  Neighbor_search search(tree, query, N);
  for(Neighbor_search::iterator it = search.begin(); it != search.end(); ++it)
  {
      std::cout &lt;&lt; &quot;Point: &quot; &lt;&lt; it-&gt;first &lt;&lt; &quot;\n&quot;;
      std::cout &lt;&lt; &quot;Distance: &quot; &lt;&lt; std::sqrt(it-&gt;second) &lt;&lt; &quot;\n&quot;;
  }
  </code></pre>
  <p>the result is as follows:</p>
  <blockquote>
  <p>Point: 222 129 161</p>
  <p>Distance: 189.307</p>
  </blockquote>
  <p>But how can I get the index of the result point? As for the reason of this question, I want to get the normal of the nearest neighbor point, so I need to reference the point.
  Could anybody help me?</p>