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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
tree |
Tree |
Returns
Section titled “Returns”Pick<TreeSelection, "rerootedAt" | "rerootPosition">
Example
Section titled “Example”setSelection((prev) => ({ ...prev, ...midpointRoot(tree) }));