TreeLayoutKMP is a functional KMP library implementing the Buchheim–Jünger–Leipert (Walker) tree layout algorithm in O( n) time. It ships with:
- Pure Kotlin
commonMainimplementation (zero platform dependencies) TreeAdapter<T>interface for zero-copy integration with any tree model- Configurable horizontal/vertical spacing
- Full multiplatform target coverage (JVM, Android, iOS, Linux x64, JS, Wasm)
- CI via GitHub Actions (build + test on all targets)
- Maven Central publishing
Priority: High
Currently, all nodes are treated as dimensionless points. Real-world trees have nodes with varying widths and heights ( labels, icons, content boxes). The layout must account for node extents to prevent overlap.
- Add a
NodeExtentProvider<T>interface withwidth(node: T): Floatandheight(node: T): Float - Integrate extents into spacing calculations during the Walker passes
- Default to uniform size (1×1) for backward compatibility
Priority: High
The algorithm currently only produces top-down layouts. Developers need flexibility for different UI contexts.
- Support four orientations:
TopToBottom,BottomToTop,LeftToRight,RightToLeft - Add an
orientationproperty toWalkerLayoutConfiguration - Transform coordinates in the second walk based on orientation
Priority: Medium
Allow control over how parent nodes align relative to their children.
- Center (current default)
- Left-aligned
- Right-aligned
- Custom anchor point
Priority: Medium
- Add
getBounds(): RecttoTreeLayoutResultreturning the bounding box of the entire layout - Add a
normalize()option to shift coordinates so the top-left is at (0, 0) - Simplifies viewport/camera setup in rendering code
Priority: High
- Validate adapter consistency (e.g.,
parent(child) == nodefor all children) - Detect cycles and throw a clear exception
- Provide meaningful error messages for malformed trees
Priority: High
- KDoc on all public API members (already partially done)
- Published API docs (Dokka → GitHub Pages)
- Platform-specific rendering samples:
- Jetpack Compose (Android/Desktop)
- SwiftUI (iOS)
- Canvas (JS/Wasm)
- SVG export utility
Priority: Low
- Add benchmarks for trees of 1K, 10K, 100K nodes
- Publish results in README or docs
- Helps developers evaluate suitability for their scale
Priority: High
- Remove the "under active development" warning once the above features stabilize
- Follow semantic versioning strictly
- Annotate experimental APIs with
@ExperimentalTreeLayoutApi - Provide migration guides between breaking versions