All notable changes to AlgoTree will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
This is a complete rewrite of AlgoTree with a modern, fluent API. The old dict-based
TreeNode and FlatForest classes have been removed in favor of a cleaner design.
To use the old API, install version 0.8.x:
pip install "AlgoTree<1.0.0"-
Nodeclass: Modern OOP tree node with clean API- Properties:
parent,children,is_root,is_leaf,level,siblings - Traversal:
traverse_preorder(),traverse_postorder(),traverse_levelorder() - Search:
find(),find_all()with predicates - Conversion:
to_dict(),from_dict()for JSON compatibility
- Properties:
-
TreeBuilderfluent API: Intuitive tree constructiontree = (TreeBuilder() .root("company") .child("engineering") .child("frontend") .sibling("backend") .build())
-
FluentNodechainable operations: Functional-style tree manipulationFluentNode(tree) .descendants() .filter(lambda n: n.level > 2) .map(lambda n: {"size": n.payload.get("size", 0) * 2}) .prune(lambda n: n.is_leaf)
-
Tree DSL parser: Parse trees from text in multiple formats
- Visual format with Unicode tree characters
- Indent-based format (YAML-like)
- S-expression format
- Auto-detection of format
- Dot notation paths: Navigate trees with intuitive syntax
- Escaped dots: Use
\.for literal dots in node names - Pattern types:
- Wildcards:
*(single),**(deep) - Attributes:
[type=file],[size](existence) - Predicates:
[?(@.size > 1000)] - Regex:
~pattern - Fuzzy:
%match:threshold
- Wildcards:
- Functions:
dotmatch,dotpluck,dotexists,dotcount,dotfilter
dotmod: Modify specific nodes using dot pathsdotmap: Map transformations over matching nodesdotprune: Remove nodes based on conditionsdotmerge: Merge trees with multiple strategiesdotgraft: Graft subtrees at specific pointsdotsplit: Split tree extracting subtreesdotannotate: Add metadata annotationsdotvalidate: Validate tree constraintsdotnormalize: Normalize node namesdotreduce: Reduce tree to aggregate valuedotflatten: Flatten tree structure
dotpipe: Pipeline for chaining transformations- Conversion functions:
to_dict: Nested dictionaryto_list: Flat listto_paths: Path stringsto_table: Tabular/DataFrame formatto_adjacency_list,to_edge_list: Graph representationsto_nested_lists: S-expression style
- Data extraction:
dotextract: Extract with custom functionsdotcollect: Collect/aggregate datadotgroup: Group nodes by keysdotpartition: Split into groupsdotproject: SQL-like projection
- GraphViz: DOT format for visualization
- Mermaid: Diagram generation
- Data formats: JSON, XML, YAML
- Web: HTML with optional styling
- Text: ASCII/Unicode tree visualization
- Complete type annotations throughout codebase
- Improved IDE support and type checking
- Comprehensive fluent API guide (
source/fluent_api.rst) - Pattern matching guide (
source/pattern_matching.rst) - Transformations guide (
source/transformations.rst) - API reference (
source/api_reference.rst) - Cookbook with practical examples (
source/cookbook.rst) - Updated examples using modern API
- Migration warnings in README
- Enhanced Makefile with:
- Virtual environment management (
make venv,make venv-clean) - Documentation serving (
make docs-serve,make docs-open) - GitHub Pages deployment (
make docs-deploy-gh-pages)
- Virtual environment management (
- Full test coverage for new features
TreeNodeclass (dict-based implementation)FlatForestclass (dict-based implementation)FlatForestNodeclass (proxy pattern)- All dict inheritance in tree structures
- Complete API redesign focusing on clarity and usability
- Tree nodes are now proper objects, not dictionaries
- Simplified tree construction and manipulation
- More Pythonic and intuitive method names
The last release with the original dict-based API. This version is still available for projects requiring backward compatibility.
TreeNode: Dict-based recursive tree structureFlatForest: Dict-based flat tree with parent pointersFlatForestNode: Proxy for node-centric API- Tree conversion utilities
- Pretty printing
jtcommand-line tool
from AlgoTree import TreeNode
# Dict-based node creation
root = TreeNode(name="root", data={"value": 100})
child = TreeNode(name="child", parent=root, data={"value": 50})
# Accessing data
print(root["data"]["value"])from AlgoTree import Node, TreeBuilder
# Object-based node creation
root = Node(name="root", value=100)
child = root.add_child(name="child", value=50)
# Accessing data
print(root.payload["value"])
# Or use TreeBuilder
tree = (TreeBuilder()
.root("root", value=100)
.child("child", value=50)
.build())- No dict inheritance: Nodes are proper objects with attributes
- Cleaner API:
node.parentinstead ofnode['parent'] - Built-in methods: Traversal, search, and manipulation methods
- Fluent interfaces: Chainable operations for complex tasks
- DSL support: Parse trees from text representations