π³ DocumentationΒΆ
Big Tree Python PackageΒΆ
Tree Implementation and Methods for Python, integrated with Python list, dictionary, and pandas DataFrame.
It is pythonic, making it easy to learn and extendable to many types of workflows.
Related Links:
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.
-
BaseNode, extendable classNode, BaseNode with node name attribute
-
From
Node, using parent and children constructorsFrom 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
Add nodes to existing tree using path string
Add nodes and attributes to existing tree using dictionary or pandas DataFrame, using path
Add only attributes to existing tree using dictionary or pandas DataFrame, using node name
-
Pre-Order Traversal
Post-Order Traversal
Level-Order Traversal
Level-Order-Group Traversal
ZigZag Traversal
ZigZag-Group Traversal
-
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
-
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
-
Cloning tree to another
NodetypeGet subtree (smaller tree with different root)
Prune tree (smaller tree with same root)
Get difference between two trees
-
Enhanced Reingold Tilford Algorithm to retrieve (x, y) coordinates for a tree structure
-
Print to console, in vertical or horizontal orientation
Export to Newick string notation, dictionary, nested dictionary, or pandas 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)
-
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.
-
BinaryNode, Node with binary tree rules
-
From list, using flattened list structure
-
In-Order Traversal
For Directed Acyclic Graph (DAG) implementation, there are 4 main components.
-
DAGNode, extendable class for constructing Directed Acyclic Graph (DAG)
-
From list, containing parent-child tuples
From nested dictionary
From pandas DataFrame
-
Generic traversal method
-
Export to list, dictionary, or pandas DataFrame
Export DAG to dot (can save to .dot, .png, .svg, .jpeg files)
InstallationΒΆ
There are two ways to install bigtree, with pip (from PyPI) or conda (from conda-forge).
a) Installation with pip (recommended)ΒΆ
To install bigtree, run the following line in command prompt:
$ pip install bigtree
If tree needs to use pandas methods, it requires additional dependencies. Run the following line in command prompt:
$ pip install 'bigtree[pandas]'
If tree needs to be exported to image, it requires additional dependencies. Run the following lines in command prompt:
$ pip install 'bigtree[image]'
$ brew install gprof2dot # for MacOS
$ conda install graphviz # for Windows
Alternatively, install all optional dependencies with the following line in command prompt:
$ pip install 'bigtree[all]'
b) Installation with condaΒΆ
To install bigtree with conda, run the following line in command prompt:
$ conda install -c conda-forge bigtree