Package: bigtree
Big Tree Python PackageTree 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:DocumentationGitHubCommunityIssues/Discussions/Changelog/ContributingPackagePyPI/CondaArticlesPython Tree Implementation with BigTreeThe Reingold Tilford Algorithm Explained, with WalkthroughIf you want to support bigtree,ComponentsThere are 3 segments to Big Tree consisting of Tree, Binary Tree, and Directed Acyclic Graph (DAG) implementation.ForTreeimplementation, there are 9 main components.🌺 NodeBaseNode, extendable classNode, BaseNode with node name attribute✨ Constructing TreeFromNode, using parent and children constructorsFromstr, using tree display or Newick string notationFromlist, using paths or parent-child tuplesFromnested dictionary, using path-attribute key-value pairs or recursive structureFrompandas DataFrame, using paths or parent-child columnsAdd nodes to existing tree using path stringAdd nodes and attributes to existing tree usingdictionaryorpandas DataFrame, using pathAdd only attributes to existing tree usingdictionaryorpandas DataFrame, using node name➰ Traversing TreePre-Order TraversalPost-Order TraversalLevel-Order TraversalLevel-Order-Group TraversalZigZag TraversalZigZag-Group Traversal📝 Modifying TreeCopy nodes from location to destinationShift nodes from location to destinationShift and replace nodes from location to destinationCopy nodes from one tree to anotherCopy and replace nodes from one tree to another🔍 Tree SearchFind multiple nodes based on name, partial path, relative path, attribute value, user-defined conditionFind single nodes based on name, partial path, relative path, full path, attribute value, user-defined conditionFind multiple child nodes based on user-defined conditionFind single child node based on name, user-defined condition🔧 Helper FunctionCloning tree to anotherNodetypeGet subtree (smaller tree with different root)Prune tree (smaller tree with same root)Get difference between two trees📊 Plotting TreeEnhanced Reingold Tilford Algorithm to retrieve (x, y) coordinates for a tree structure🔨 Exporting TreePrint to console, in vertical or horizontal orientationExport toNewick string notation,dictionary,nested dictionary, orpandas DataFrameExport tree todot(can save to .dot, .png, .svg, .jpeg files)Export tree toPillow(can save to .png, .jpg)Export tree toMermaid Flowchart(can display on .md)✔️ WorkflowsSample workflows for tree demonstration!ForBinary Treeimplementation, there are 3 main components.
Binary Node inherits from Node, so the components in Tree implementation are also available in Binary Tree.🌿 NodeBinaryNode, Node with binary tree rules✨ Constructing Binary TreeFromlist, using flattened list structure➰ Traversing Binary TreeIn-Order TraversalForDirected Acyclic Graph (DAG)implementation, there are 4 main components.🌼 NodeDAGNode, extendable class for constructing Directed Acyclic Graph (DAG)✨ Constructing DAGFromlist, containing parent-child tuplesFromnested dictionaryFrompandas DataFrame➰ Traversing DAGGeneric traversal method🔨 Exporting DAGExport tolist,dictionary, orpandas DataFrameExport DAG todot(can save to .dot, .png, .svg, .jpeg files)InstallationThere are two ways to installbigtree, with pip (recommended) or conda.a) Installation with pipTo installbigtree, run the following line in command prompt:$pipinstallbigtreeIf tree needs to use pandas methods, it requires additional dependencies.
Run the following line in command prompt:$pipinstall'bigtree[pandas]'If tree needs to be exported to image, it requires additional dependencies.
Run the following lines in command prompt:$pipinstall'bigtree[image]'$brewinstallgprof2dot# for MacOS$condainstallgraphviz# for WindowsAlternatively, install all optional dependencies with the following line in command prompt:$pipinstall'bigtree[all]'b) Installation with condaTo installbigtreewith conda, run the following line in command prompt:$condainstall-cconda-forgebigtree