Skip to main content

No project description provided

Project description

kdtreePython

KDTree implementation with the support of weights. Each node created will be associated with a weight. Every node stores the weight associated to that package, the minimum weight in that subtree and the maximum weight.

Example:

  1. Creating kdtree
from weighted_kdtree import kdtree
points = [(12,34), (25,36), (9,10), (5, 15), (30, 20), (20, 27)]
weights = [10, 20, 12, 20, 30, 28]
kd_tree = kdtree.KDTree(points, weights)
  1. Preorder Traversal
kdtree.KDTree.preorderTraversal(kd_tree.root)
[[(9, 10)], [(12, 34)], [(5, 15)], [(30, 20)], [(25, 36)], [(20, 27)]]
  1. Weights
kd_tree.root.val, kd_tree.root.weight["weight"],  kd_tree.root.weight["minWeight"],  kd_tree.root.weight["maxWeight"]
((20, 27), 28, 30, 10)
  1. Nearest Neighbor
kdtree.KDTree.nnKDTree((10, 20), kd_tree.root, 15, 3)
[(10.04987562112089, (9, 10)),
 (12.206555615733702, (20, 27)),
 (14.142135623730951, (12, 34))]

Future work: Following weights related methods are to be added soon:

  1. Find points in a query rectangle with a weight threshold
  2. Point with minimum weight in a query rectangle
  3. Point with maximum weight in a query rectangle

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

weighted_kdtree-0.1.2-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file weighted_kdtree-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for weighted_kdtree-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f9b0ad16bf576e6978a94a8235877c7c1a79226876b470cffc62a3442c176604
MD5 b645e6705da8385711ddad8553073304
BLAKE2b-256 b3d1a3afef2efd0d0bfc47c2297ab47d22b3d7cdc51624dde6bc72b3a04bf841

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page