Skip to Content.
Sympa Menu

cgal-discuss - How to get the index of the K-Nearest Neighbor points

Subject: CGAL users discussion list

List archive

How to get the index of the K-Nearest Neighbor points


Chronological Thread 
  • From: Chansophea Chuon <>
  • To:
  • Subject: How to get the index of the K-Nearest Neighbor points
  • Date: Mon, 12 Mar 2007 11:33:16 -0700 (PDT)
  • Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:MIME-Version:Content-Type:Message-ID; b=eBCAfUX16zPt0XTr07ZYFJF5osNwLEqDrQ67fTuI2tTEEV9BBNkcM/qJ/z3bDx6oTWwuB8ebHOqtHIc0fTLCkhdWR+QP1GAEae7IaXi4gaLguEZJ1/cdsqEzbgKzySr1cIC0u95TBiFjpXZt23vCy1pGb+hsdh1bKmJO/WMdyv0=;

Dear All:

Suppose that we pass a vector of points(std::vector<Point_3> points) to the (Tree tree(points.begin(), points.end()))

Then we find the K-Nearest neighbors

Neighbor_search search(tree, query, N);
// This should sort all N points by increasing distance from origin

for(Neighbor_search::iterator it = search.begin(); it != search.end(); ++it){
   
std::cout << it->first << " "<< std::sqrt(it->second) << std::endl;
}

We get the K-Nearest neighbors points and their distances. How to get the index of the K
-Nearest neighbors in the vector effeciently? Does the Neighbor_search::iterator provide the indexes?

Best regards,

Sophea


Don't get soaked. Take a quick peek at the forecast
with theYahoo! Search weather shortcut.


Archive powered by MHonArc 2.6.16.

Top of Page