Skip to main content

Tree library

Project description

LittleTree is a library that provides trees. The package is purely written in python and tries to be easy to use, but operations are generally implemented in an efficient way. It was created because all other tree implementations were either too basic, slow or complicated.

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_string())
tree.to_image('world.png')  # Works if dot(graphviz) is on path

The resulting tree looks like this:

World
├─ Asia
├─ Africa
├─ America
└─ Europe

world

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 libraries. Each had some things I liked and disliked. None of them was exactly how I wanted it, so I decided to create something new.

  • anytree - Very hackable, but implementation uses lists, which makes lookups slow.
  • bigtree - Similar to anytree, but has more features.
  • itertree - Has many features and is fast, but its design is complex.
  • treelib - Puts all nodes of a tree into a single flat dict.
  • networkx - A tree is a special kind of graph

Project details


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.1.3-py3-none-any.whl (17.5 kB view details)

Uploaded Python 3

File details

Details for the file littletree-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: littletree-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 17.5 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

Hashes for littletree-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4060fd2e4d0b8dd9b047e3894648e8efbeb2342943413588a63646c284d1546d
MD5 d82a1a42e7a386d20db0235fdde999f1
BLAKE2b-256 cdbfefefb0aeb95c1d54b079db5abf8468efdfa9382c88fa50ecf90c9ab674d0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page