Simple tree struct with search and traversal utilities
Project description
SearchableTree
Simple list intended for simplifying traversal & node search Does not support deletion
Example:
tree = SearchableTree(SearchableNode, "root")
root = tree.getRoot()
l1 = root.appendChild('l1')
l11 = root.appendChild('l11')
l12 = root.appendChild('l12')
l2 = root.appendChild('l2')
l21 = root.appendChild('l21')
l22 = root.appendChild('l22')
tree.upsert("l1.l11.l111")
tree.upsert("l1.l11.l112")
for el in root.traverse(): #Traverse all nodes
print(el)
print(tree) #Pretty print tree
print(tree.find("l112")) #Get node by name
print(tree.find("root.l1.l11")) #Get node by path
for el in l2.ancestors(): #Get node ancestors
print(el)
Extend SearchableNode to add custom funcionality
Author
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
SearchableTree-1.0.2.tar.gz
(3.0 kB
view hashes)
Built Distribution
Close
Hashes for SearchableTree-1.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6c20295f84b6fb06cc201e15d3ca66a4427c5a11d25f28ae33ddca5892b8aa1d |
|
MD5 | dbba5583395bb39848f76de6cf2f5fcf |
|
BLAKE2b-256 | ce1975a429a377fe302674507fc09df968ead3b7653fdb5ffa767b9a2aac98fe |