Skip to content
Python implemenation of a vantage-point tree data structure for nearest neighbor searching.
Branch: master
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.
LICENSE.txt Moved vptree to git. Apr 13, 2017 Added Apr 13, 2017
README.rst Remove leaf_size mention from README. Aug 9, 2017 Remove leaf_size mention from README. Aug 9, 2017 Removed leaf_size-argument and associated tests. Aug 9, 2017 Revert "fix #4" Jul 24, 2018



This package contains an implementation of a vantage-point tree data structure.


Simply install through pip:

pip install vptree


Example usage:

import numpy as np
import vptree

# Define distance function.
def euclidean(p1, p2):
  return np.sqrt(np.sum(np.power(p2 - p1, 2)))

# Generate some random points.
points = np.random.randn(20000, 10)
query = [.5] * 10

# Build tree in O(n log n) time complexity.
tree = vptree.VPTree(points, euclidean)

# Query single point.

# Query n-points.
tree.get_n_nearest_neighbors(query, 10)

# Get all points within certain distance.
tree.get_all_in_range(query, 3.14)
You can’t perform that action at this time.