Linkage
Mojo struct 🡭
Linkage
@memory_only
struct LinkageHow far apart two clusters are, given how far apart their members are.
All four are reducible, which is what lets the nearest-neighbour chain merge a reciprocal pair without checking anything else.
Aliases
SINGLE = Linkage(Int(0)): The closest pair across the two clusters. Finds long straggling shapes, and chains through noise for the same reason.COMPLETE = Linkage(Int(1)): The furthest pair. Compact, equally sized clusters, and one outlier holds a whole cluster away.AVERAGE = Linkage(Int(2)): The mean over every cross pair. The usual choice, and the default here.WARD = Linkage(Int(3)): The merge that adds least to the total within-cluster spread. Defined in terms of squared Euclidean distance, so it is only meaningful withDistanceMetric.EUCLIDEAN;linkage()raises on any other pairing rather than returning a number that looks fine.
Implemented traits
AnyType, Copyable, Deinitable, ImplicitlyCopyable, Movable
Methods
__init__
fn def __init__(out self, value: Int)Construct from the integer tag.
Args:
- value (
Int): The tag. - self (
Self)
Returns:
Self
__eq__
fn def __eq__(self, other: Self) -> BoolWhether two linkages are the same.
Args:
- self (
Self) - other (
Self): The linkage to compare with.
Returns:
Bool: True when they match.