Skip to content

Merge

Mojo struct 🡭

Merge

@memory_only
struct Merge

One join in a Dendrogram: two nodes and the distance they were joined at.

left and right are node ids: 0 .. n-1 are the original rows and n + k is the node the k-th merge created, so a tree of n rows has n - 1 merges and a root of 2n - 2.

Fields

  • left (Int)
  • right (Int)
  • height (Float64): The linkage distance between the two nodes when they joined; the height a dendrogram draws the bracket at.
  • size (Int): How many original rows are under this node.

Implemented traits

AnyType, Copyable, Deinitable, ImplicitlyCopyable, Movable

Methods

__init__

fn def __init__(out self, left: Int, right: Int, height: Float64, size: Int)

Record one merge.

Args:

  • left (Int): The first node’s id.
  • right (Int): The second node’s id.
  • height (Float64): The distance they joined at.
  • size (Int): How many rows are under the result.
  • self (Self)

Returns:

Self