Bigtree

1.4.0 · active · verified Tue Apr 14

Bigtree is a Python library that provides a performant, flexible, and intuitive implementation for tree data structures. It supports various tree types (Tree, Binary Tree, Directed Acyclic Graph) and offers a rich API for traversal, search, modification, and export. It integrates seamlessly with Python lists, dictionaries, pandas, and polars DataFrames, making it suitable for a wide range of hierarchical data workflows. The library is actively maintained with frequent releases, currently at version 1.4.0.

Warnings

Install

Imports

Quickstart

This example demonstrates how to create a basic tree using `Node` objects and print its structure to the console using `print_tree`. It also shows how to access built-in node attributes like `is_leaf` and `node_name`.

from bigtree import Node, print_tree

# Create nodes
root = Node("a")
b = Node("b", parent=root)
c = Node("c", parent=root)
d = Node("d", parent=b)
e = Node("e", parent=b)
f = Node("f", parent=c)

# Print the tree
print_tree(root)

# Access node attributes
print(f"Node 'd' is a leaf: {d.is_leaf}")
print(f"Root node name: {root.node_name}")

view raw JSON →