MCPcopy Create free account
hub / github.com/SuprDewd/CompetitiveProgramming / nearest_neighbour

Method nearest_neighbour

code/data-structures/kd_tree.cpp:68–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

66 void _clr(node *n) {
67 if (n) _clr(n->l), _clr(n->r), delete n; }
68 pair<pt, bool> nearest_neighbour(const pt &p,
69 bool allow_same=true) {
70 double mn = INFINITY, cs[K];
71 rep(i,0,K) cs[i] = -INFINITY;
72 pt from(cs);
73 rep(i,0,K) cs[i] = INFINITY;
74 pt to(cs), resp;
75 _nn(p, root, bb(from, to), mn, resp, 0, allow_same);
76 return make_pair(resp, !std::isinf(mn)); }
77 void _nn(const pt &p, node *n, bb b,
78 double &mn, pt &resp, int c, bool same) {
79 if (!n || b.dist(p) > mn) return;

Callers

nothing calls this directly

Calls 1

bbClass · 0.85

Tested by

no test coverage detected