Expand description
§Cinereus
GumTree-style tree diffing with Chawathe edit script generation.
Named after Phascolarctos cinereus (the koala), which lives in gum trees.
§Algorithm Overview
Cinereus implements a tree diff algorithm based on:
- GumTree (Falleri et al., ASE 2014) for node matching
- Chawathe algorithm (1996) for edit script generation
The algorithm works in phases:
- Top-down matching: Match identical subtrees by hash (Merkle-tree style)
- Bottom-up matching: Match remaining nodes by structural similarity (Dice coefficient)
- Edit script generation: Produce INSERT, DELETE, UPDATE, MOVE operations
- Simplification: Consolidate redundant operations (e.g., subtree moves)
§Usage
ⓘ
use cinereus::{Tree, tree_diff};
// Build trees from your data structure
let tree_a = Tree::build(/* ... */);
let tree_b = Tree::build(/* ... */);
// Compute the diff
let edit_script = tree_diff(&tree_a, &tree_b);
for op in edit_script {
println!("{:?}", op);
}Re-exports§
pub use indextree;
Structs§
- Matching
- A bidirectional mapping between nodes in two trees.
- Matching
Config - Configuration for the matching algorithm.
- Node
Data - Data stored in each tree node.
- Tree
- A tree structure for diffing.
Enums§
- EditOp
- An edit operation in the diff.
Functions§
- compute_
matching - Compute the matching between two trees using the GumTree algorithm.
- diff_
trees - Compute a simplified diff between two trees.
- generate_
edit_ script - Generate an edit script from a matching between two trees.
- simplify_
edit_ script - Simplify an edit script by consolidating subtree operations.