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 Distribution

weighted_kdtree-0.1.3.tar.gz (4.2 MB view details)

Uploaded Source

Built Distribution

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

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

Uploaded Python 3

File details

Details for the file weighted_kdtree-0.1.3.tar.gz.

File metadata

  • Download URL: weighted_kdtree-0.1.3.tar.gz
  • Upload date:
  • Size: 4.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.7

File hashes

Hashes for weighted_kdtree-0.1.3.tar.gz
Algorithm Hash digest
SHA256 290ff736ab33120f16d4b14624bc5e56346b492724fe1a70d459ffc1e4c825ef
MD5 8961af626109be8fba74013ba74ae8de
BLAKE2b-256 44ead030922b79328d65a3e0ce7e5be6ddb388f06bc3a2867d132692bb556632

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for weighted_kdtree-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 35ab006211589900291644e77c8bf4815b22025f4353ac0b25a7f0a7db3ecc7f
MD5 5a84b8bb8455b2a2100b3c370089bb8e
BLAKE2b-256 ae6ad4d26fa52d4447c17f50572a803bc53fcff6c34aed693c270eefc94b6d6c

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