Tree Implementation and Methods for Python, integrated with list, dictionary, pandas and polars DataFrame.
Project description
Big Tree Python Package
Tree Implementation and Methods for Python, integrated with list, dictionary, pandas and polars DataFrame.
It is pythonic, making it easy to learn and extendable to many types of workflows.
Related Links:
- Documentation
- GitHub
- Community
- Package
- Articles
Components
There are 3 segments to Big Tree consisting of Tree, Binary Tree, and Directed Acyclic Graph (DAG) implementation.
For Tree implementation, there are 9 main components.
- 🌺 Node
BaseNode
, extendable classNode
, BaseNode with node name attribute
- ✨ Constructing Tree
- From
Node
, using parent and children constructors - From str, using tree display or Newick string notation
- From list, using paths or parent-child tuples
- From nested dictionary, using path-attribute key-value pairs or recursive structure
- From pandas DataFrame, using paths or parent-child columns
- From polars DataFrame, using paths or parent-child columns
- Add nodes to existing tree using path string
- Add nodes and attributes to existing tree using dictionary, pandas DataFrame, or polars DataFrame, using path
- Add only attributes to existing tree using dictionary, pandas DataFrame, or polars DataFrame, using node name
- From
- ➰ Traversing Tree
- Pre-Order Traversal
- Post-Order Traversal
- Level-Order Traversal
- Level-Order-Group Traversal
- ZigZag Traversal
- ZigZag-Group Traversal
- 📝 Modifying Tree
- Copy nodes from location to destination
- Shift nodes from location to destination
- Shift and replace nodes from location to destination
- Copy nodes from one tree to another
- Copy and replace nodes from one tree to another
- 🔍 Tree Search
- Find multiple nodes based on name, partial path, relative path, attribute value, user-defined condition
- Find single nodes based on name, partial path, relative path, full path, attribute value, user-defined condition
- Find multiple child nodes based on user-defined condition
- Find single child node based on name, user-defined condition
- 🔧 Helper Function
- Cloning tree to another
Node
type - Get subtree (smaller tree with different root)
- Prune tree (smaller tree with same root)
- Get difference between two trees
- Cloning tree to another
- 📊 Plotting Tree
- Enhanced Reingold Tilford Algorithm to retrieve (x, y) coordinates for a tree structure
- Plot tree using matplotlib (optional dependency)
- 🔨 Exporting Tree
- Print to console, in vertical or horizontal orientation
- Export to Newick string notation, dictionary, nested dictionary, pandas DataFrame, or polars DataFrame
- Export tree to dot (can save to .dot, .png, .svg, .jpeg files)
- Export tree to Pillow (can save to .png, .jpg)
- Export tree to Mermaid Flowchart (can display on .md)
- ✔️ Workflows
- Sample workflows for tree demonstration!
For Binary Tree implementation, there are 3 main components. Binary Node inherits from Node, so the components in Tree implementation are also available in Binary Tree.
- 🌿 Node
BinaryNode
, Node with binary tree rules
- ✨ Constructing Binary Tree
- From list, using flattened list structure
- ➰ Traversing Binary Tree
- In-Order Traversal
For Directed Acyclic Graph (DAG) implementation, there are 4 main components.
- 🌼 Node
DAGNode
, extendable class for constructing Directed Acyclic Graph (DAG)
- ✨ Constructing DAG
- From list, containing parent-child tuples
- From nested dictionary
- From pandas DataFrame
- ➰ Traversing DAG
- Generic traversal method
- 🔨 Exporting DAG
- Export to list, dictionary, or pandas DataFrame
- Export DAG to dot (can save to .dot, .png, .svg, .jpeg files)
Installation
bigtree
requires Python 3.8+. There are two ways to install bigtree
, with pip (recommended) or conda.
a) Installation with pip
Basic Installation
To install bigtree
, run the following line in command prompt:
$ pip install bigtree
Installing optional dependencies
bigtree
have a number of optional dependencies, which can be installed using "extras" syntax.
$ pip install 'bigtree[extra_1, extra_2]'
Examples of extra packages include:
all
: include all optional dependenciesimage
: for exporting tree to imagematplotlib
: for plotting treespandas
: for pandas methodspolars
: for polars methods
For image
extra dependency, you may need to install more plugins.
$ brew install gprof2dot # for MacOS
$ conda install graphviz # for Windows
b) Installation with conda
To install bigtree
with conda, run the following line in command prompt:
$ conda install -c conda-forge bigtree
Star History
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
Built Distribution
File details
Details for the file bigtree-0.22.3.tar.gz
.
File metadata
- Download URL: bigtree-0.22.3.tar.gz
- Upload date:
- Size: 1.3 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.27.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 800a8acff2a790ed1def8e08dce1da1878d7bc4d42f02141d3f6ca07d5d63ab6 |
|
MD5 | a2542cda003439106ec13bc888613851 |
|
BLAKE2b-256 | 11f602e2508081efdc02ea22451f71a1ed9d2638b61abf2860de27c0315d125c |
File details
Details for the file bigtree-0.22.3-py3-none-any.whl
.
File metadata
- Download URL: bigtree-0.22.3-py3-none-any.whl
- Upload date:
- Size: 80.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.27.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0c7a8fde0cf5c1c0a75f5731ec531388c4fc491c4b20b77ba27eb13b85481f6e |
|
MD5 | 876a65408468fcbea1041d97973a48fc |
|
BLAKE2b-256 | 1a8607b617de54d5871d252c0a0f2d59558d9c01f0f651de58532a565f404ece |