benhoyt / pybktree

Python BK-tree data structure to allow fast querying of "close" matches
MIT License
169 stars 22 forks source link

Request: Remove item #6

Closed Jwink3101 closed 2 years ago

Jwink3101 commented 2 years ago

Is it possible to remove an item from the tree? I think that would add to the utility for larger projects.

Honestly, I may try to figure it out myself this weekend if I find the time.

Thanks!

benhoyt commented 2 years ago

I'm not opposed to a remove method being added, particularly if you want to submit a good PR (with doctests). Thanks!

Jwink3101 commented 2 years ago

A little digging says it is harder than expected. See for example https://stackoverflow.com/questions/42230648/deleting-a-node-in-a-bk-tree.

A way to kind of hack it is to keep track of removed items and exclude them from the results. However, I think that is probably not something that the base data structure should offer and should instead be done externally.

I am going to close this. If inspiration strikes and I try and figure it out, I'll update but I am not hopeful.

Thanks!