Tree library
Project description
LittleTree is a library that provides a tree data structure to python. It can be used to represent file systems, taxonomies and much more.
Features
- Dict-like usage for basic creation and modification of trees.
- Performant implementation of common tree operations and traversals.
- Can be subclassed. It's possible to make subclasses use a different dict backend (indexed.Dict, SortedDict).
- Can handle big trees that are 10,000 layers deep.
- 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)
- Different children of the same parent must have different names. (It's not a multidict)
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
And it creates 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
littletree-0.5.0-py3-none-any.whl
(31.9 kB
view hashes)
Close
Hashes for littletree-0.5.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 274bb98690afecf2b182e0b2cd649db7ca3d8e7b9609755e4ab93857e49556c3 |
|
MD5 | 03855a4e56da87ae86b5c11f10854c0b |
|
BLAKE2b-256 | fa9ef754b731366fba9adcf953c7cea8e908e17dff72fad2e4943e76191c9617 |