TreeLayoutKMP

A Kotlin Multiplatform library for computing tidy tree layouts using the Walker/Buchheim algorithm in O(n) time. Includes transformation utilities for adapting coordinates to any rendering target, animation support for smooth transitions between layout states, and zero-dependency JSON serialization for caching or transmitting results.

Getting Started

Create a TreeAdapter for your tree structure, then pass it to WalkerTreeLayout:

val layout = WalkerTreeLayout(adapter, WalkerLayoutConfiguration(horizontalDistance = 2f))
val result = layout.layout()
val position = result.getPosition(myNode)

Layout Algorithms

AlgorithmClassUse Case
Walker (Buchheim)WalkerTreeLayoutStandard tidy tree layout
Radial WalkerRadialWalkerTreeLayoutConcentric ring layout
Direct AngularDirectAngularPlacementLayoutProportional angular partitioning

Packages

Link copied to clipboard
common

Core interfaces and data types for tree layout computation.

common

Direct angular partitioning layout for radial trees.

common

Radial variant of the Walker algorithm placing nodes on concentric rings.

Link copied to clipboard
common

Layout result types, transformation utilities, and bounding box helpers. TreeLayoutResult is a concrete class providing chainable coordinate transforms (mapped, centered, scaledTo, normalized, translated). LayoutTransition enables animated interpolation between two layout states. Extension functions toJson and fromJson provide zero-dependency JSON serialization.

Link copied to clipboard
common

Walker/Buchheim O(n) tidy tree layout algorithm.