Tree library
Project description
LittleTree is a library that provides a tree data structure to python. The package is purely written in python. It should be easy to use while efficient.
Installing
- Use pip to install littletree:
$ pip install --upgrade littletree
Usage
A tree can be used in a similar way as a dict
:
from littletree import Node
tree = Node(identifier="World")
tree["Asia"] = Node()
tree["Africa"] = Node()
tree["America"] = Node()
tree["Europe"] = Node()
tree.show() # Same as print(tree.to_string())
tree.to_image().show() # Show as an image instead
The resulting tree is printed like this:
World
├─ Asia
├─ Africa
├─ America
└─ Europe
And it creates the following image:
See tutorial for more information.
Limitations
- Each node has a single parent
- A node can't have a sibling with the same identifier
Alternatives
Before creating this, I looked at some other tree libraries. I found the others to be lacking, because they were either slow or made simple things complicated. Therefore, I decided to make my own.
- anytree - Very hackable, but generally slow.
- bigtree - Similar to anytree, but has more features.
- itertree - Has many features and good performance, but has a complicated design.
- treelib - This puts all nodes of a tree into a single dict. This makes some operations difficult or slow, although it has advantages too.
- networkx - Is actually made for graphing. Doesn't have a dedicated tree type.
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 Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
File details
Details for the file littletree-0.4.1-py3-none-any.whl
.
File metadata
- Download URL: littletree-0.4.1-py3-none-any.whl
- Upload date:
- Size: 31.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.11.3 pkginfo/1.8.3 requests/2.28.1 requests-toolbelt/0.9.1 tqdm/4.64.1 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c38b262dbb324b6c6dac477c51ed8cc5684b4ed6f04c64da7d7f02ec0bfc6d12 |
|
MD5 | 6f77637655eae3e22ae22a29e28a0b0e |
|
BLAKE2b-256 | 8abb14169810116e48263f56a8b115b0887a38b54e6fb68e0c45e940074a6150 |