Skip to content

Dendrogram

Mojo struct 🡭

Dendrogram

@memory_only
struct Dendrogram

A finished merge tree: the joins in increasing height, and the leaf order they imply.

merges is sorted by height and renumbered so a node’s children always come before it, which is what lets anything walk the tree in one forward pass.

Fields

  • merges (List[Merge])
  • leaf_order (List[Int]): The original row indices, left to right, as the tree lays them out: every cluster’s rows are contiguous, which is the whole point.

Implemented traits

AnyType, Deinitable, Movable

Methods

__init__

fn def __init__(out self, var merges: List[Merge], var leaf_order: List[Int])

Construct from already-computed merges and order.

Args:

  • merges (List[Merge]): The joins, sorted by height.
  • leaf_order (List[Int]): The row indices in tree order.
  • self (Self)

Returns:

Self

height_of

fn def height_of(self, index: Int) -> Float64

The index-th merge’s height.

Args:

  • self (Self)
  • index (Int): Which merge.

Returns:

Float64: Its height, or 0.0 when out of range.