package tree_layout
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>
On This Page
Module Tree_layout.LayeredSource
Layered trees
A layered tree is a tree that is organized by layers: the horizontal position of a node is fixed depending on its depth in the tree, regardless of its height.
(* Given a nice tree, ... *)
let tree : Tree.t = ...
(* and a distance function. *)
let distance v1 v2 = ...
(* Get positions ! *)
let positions =
Tree_layout.Layered.layout
~children:Tree.children
~distance
treeSource
val layout :
?m:(module Hashtbl.HashedType with type t = 'a) ->
children:('a -> 'a array) ->
distance:('a -> 'a -> float) ->
'a ->
'a ->
Common.poslayout ~children ~distance g v returns the layered layout for the tree g rooted in v. Layered layout are such that vertices with the same depth have the same vertical coordinate. The layout is returned as a lookup functions from trees to positions.
This algorithm is in linear time if children is constant time. Use Make for a more flexible implementation.
distance v1 v2 should return the horizontal distance between v1 and v2 placed at the same depth.
Functorized API
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>
On This Page