Skip to content

midpointRoot

function midpointRoot(tree): Pick<TreeSelection, "rerootedAt" | "rerootPosition">;

Defined in: packages/components/src/components/PhyloTree/utils/midpoint.ts:18

The rerootedAt/rerootPosition pair that roots tree at its midpoint: the point halfway along the longest leaf-to-leaf path. Independent of the tree’s current rooting, so it can be spread straight into a selection. Returns {} (no reroot) for a tree with fewer than two leaves.

Parameter Type
tree Tree

Pick<TreeSelection, "rerootedAt" | "rerootPosition">

setSelection((prev) => ({ ...prev, ...midpointRoot(tree) }));