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. nearestNeighbor
  2. Find points in a query rectangle with a weight threshold
  3. Point with minimum weight in a query rectangle
  4. 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.1-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for weighted_kdtree-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 036427019d78362d967970bd60eda2b8cdcf7c50aeccaccba4d33e753a365424
MD5 826e6db76bd99f94246e3a3c807af533
BLAKE2b-256 25381e9ef05c2c64a598eb4e9d3d3347ab749d1c4f7401a9b973ed3b1cb713fb

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