Tree library
Project description
LittleTree is a library that provides a tree data structure to python, which is both fast and flexible. It can be used to represent file systems, taxonomies and much more.
Features
- Intuitive basic creation and modification of trees.
- Efficient implementation of common tree operations and traversals. Works on trees that are 10 000 layers deep.
- Extensible. Subclass
BaseNode
orNodeMixin
if you need more freedom. - Can be imported / exported to many different formats (nested dict, rows, relations, graphviz, mermaid, newick, networkx).
- Purely written in Python.
Limitations
- Each node has at most one parent. (It's a tree not a graph!)
- Nodes cannot be their own ancestor.
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()
# Print tree to console
tree.show()
# Show tree as an image
tree.to_image().show()
The resulting tree is printed like this:
World
├─ Asia
├─ Africa
├─ America
└─ Europe
If Pillow and graphviz are installed, it will also display the following image:
See tutorial for more information.
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.6.2-py3-none-any.whl
.
File metadata
- Download URL: littletree-0.6.2-py3-none-any.whl
- Upload date:
- Size: 34.0 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 | 4e718f5b01e12498534e15ea4f64570b3177809626cfd6e82c80b5367ef0853a |
|
MD5 | 8a76310adc43512dd2f83e8c07ee7991 |
|
BLAKE2b-256 | 09ed290d99367af1f336bd9fd32a0886c4758ee58e3f5d0bdb33453ff4f60656 |