Algorithm Search⌘K

Proofs: Multi-vantage-point tree

These are the human proofs of Multi-vantage-point tree, at full length.

The MVP-tree range search reports exactly the objects within the radius, and the tree has logarithmic height full

This proof shows: correctness.

We use the names of the pseudocode on the page. (U,d)(U, d) is a metric space, PP a finite set of nn objects, m≥2m \ge 2, k≥1k \ge 1 and p≥0p \ge 0. For a node NN, obj(N)\mathrm{obj}(N) is the set of objects stored in its subtree, as vantage points or as entries.

Lemma 1 (partition). BUILD(S)(S) stores every object of SS exactly once in its subtree.

Proof. By induction on ∣S∣|S|. A leaf stores v1v_1, v2v_2 and the others as entries (with v2v_2 absent when ∣S∣=1|S| = 1 and nothing when SS is empty). At an internal node, ∣S∣≥k+3≥4|S| \ge k + 3 \ge 4; v1v_1 and v2v_2 are stored at the node, and the subrings partition the remaining objects, each of size less than ∣S∣|S|. □\square

Lemma 2 (intervals and paths). (a) At an internal node, every x∈obj(child (i,j))x \in \mathrm{obj}(\text{child } (i, j)) has d(x,v1)∈Iid(x, v_1) \in I_i and d(x,v2)∈Ji,jd(x, v_2) \in J_{i,j}. (b) For every entry xx of a leaf at depth δ\delta (the root at depth 0), with internal ancestors N0,…,Nδ−1N_0, \ldots, N_{\delta - 1} from the root, PATH(x)\mathrm{PATH}(x) is the first min⁡(p,2δ)\min(p, 2\delta) elements of the list d(x,N0.v1),d(x,N0.v2),…,d(x,Nδ−1.v2)d(x, N_0.v_1), d(x, N_0.v_2), \ldots, d(x, N_{\delta-1}.v_2). (c) When RANGE is called on that leaf, QQ is the first min⁡(p,2δ)\min(p, 2\delta) elements of the list d(q,N0.v1),d(q,N0.v2),…,d(q,Nδ−1.v2)d(q, N_0.v_1), d(q, N_0.v_2), \ldots, d(q, N_{\delta-1}.v_2).

Proof. (a) Line L4 takes IiI_i as the least and greatest value of d(⋅,v1)d(\cdot, v_1) over ring ii, and v2v_2 is removed from a ring after that, so the remaining objects of ring ii still lie in IiI_i; line L6 does the same for Ji,jJ_{i,j}, and the objects of child (i,j)(i, j) are exactly subring (i,j)(i, j). (b) xx passes through each internal ancestor once, where line L3 appends d(x,v1)d(x, v_1) and line L6 appends d(x,v2)d(x, v_2), each only while the list is shorter than pp; nothing else appends to it, and the leaf stores the list unchanged. (c) RANGE starts with QQ empty, and line L15 appends t1=d(q,v1)t_1 = d(q, v_1) and t2=d(q,v2)t_2 = d(q, v_2) at each internal node on the way down, and cuts after pp; the descent to the leaf passes through the same ancestors. □\square

Theorem 1 (range). RANGE(root,q,r,())(\text{root}, q, r, ()) reports exactly the objects x∈Px \in P with d(q,x)≤rd(q, x) \le r, each once.

Proof. By Lemma 1 every object is a vantage point or an entry of one node, so it is reported at most once. A reported object passed an exact test d(q,⋅)≤rd(q, \cdot) \le r in line L9, L13 or L14, so it is an answer. Let xx be an answer, and suppose it is not reported. Then one of three things happened.

  • RANGE skipped a child (i,j)(i, j) of an internal ancestor NN of the node of xx. If the reason was IiI_i, then Ii=[a,b]I_i = [a, b] with t1+r<at_1 + r < a or t1−r>bt_1 - r > b. By Lemma 2(a), d(x,v1)∈[a,b]d(x, v_1) \in [a, b]. In the first case d(q,x)≥d(x,v1)−d(q,v1)≥a−t1>rd(q, x) \ge d(x, v_1) - d(q, v_1) \ge a - t_1 > r; in the second, d(q,x)≥d(q,v1)−d(x,v1)≥t1−b>rd(q, x) \ge d(q, v_1) - d(x, v_1) \ge t_1 - b > r. The case of Ji,jJ_{i,j} and v2v_2 is the same. (An empty ring has an empty interval and no object.)
  • Line L11 skipped the entry xx: then ∣d(q,u)−d(x,u)∣>r|d(q, u) - d(x, u)| > r for u=v1u = v_1 or u=v2u = v_2 of the leaf.
  • Line L12 skipped it: then by Lemma 2(b) and 2(c), Q[i]Q[i] and PATH(x)[i]\mathrm{PATH}(x)[i] are the distances from qq and from xx to the same vantage point uu, and ∣d(q,u)−d(x,u)∣>r|d(q, u) - d(x, u)| > r.

In the last two cases the triangle inequality gives d(q,x)≥∣d(q,u)−d(x,u)∣>rd(q, x) \ge |d(q, u) - d(x, u)| > r. Each case contradicts d(q,x)≤rd(q, x) \le r. □\square

Lemma 3 (height and build cost). Every node at depth δ\delta holds at most ⌈n/m2δ⌉\lceil n / m^{2\delta} \rceil objects. Internal nodes exist only at depths δ<log⁡m2n\delta < \log_{m^2} n, so the tree has at most ⌈log⁡m2n⌉+1\lceil \log_{m^2} n \rceil + 1 levels, and BUILD makes at most 2n2n evaluations per level.

Proof. A split by rank of ss objects into mm parts gives parts of size at most ⌈s/m⌉\lceil s/m \rceil. A child of a node with ss objects gets at most ⌈⌈s/m⌉/m⌉=⌈s/m2⌉\lceil \lceil s/m \rceil / m \rceil = \lceil s/m^2 \rceil objects, and the nested ceilings give ⌈n/m2δ⌉\lceil n/m^{2\delta} \rceil at depth δ\delta. An internal node has at least 4 objects, so n/m2δ>3≥1n/m^{2\delta} > 3 \ge 1 and δ<log⁡m2n\delta < \log_{m^2} n. Each object at a node costs at most two evaluations there (lines L3 and L6, or the two of line L2), and the nodes at one depth hold disjoint sets. ■\blacksquare

Back to Multi-vantage-point tree