Struct kodama::Dendrogram

source ·
pub struct Dendrogram<T> { /* private fields */ }
Expand description

A step-wise dendrogram that represents a hierarchical clustering as a binary tree.

A dendrogram consists of a series of N - 1 steps, where N is the number of observations that were clustered. Each step corresponds to a merge between two other clusters (where a cluster might consist of one or more observations). Each step includes the labels for the pair of clusters that were merged, the number of total observations in the new merged cluster and the dissimilarity between the two merged clusters.

The labels of clusters are assigned as follows:

  1. A cluster that corresponds to a single observation is assigned a label that corresponds to the given observation’s index in the pairwise dissimilarity matrix.
  2. A cluster with more than one observation has the label N + i, where N is the total number of observations and i corresponds to the the ith step in which the cluster was created. So for example, the very first step in a dendrogram creates a cluster with the label N and the last step in a dendrogram creates a cluster with the label (N + N - 1) - 1 (since there are always N - 1 steps in a dendrogram).

This labeling scheme corresponds to the same labeling scheme used by SciPy.

The type parameter T refers to the type of dissimilarity used in the steps. In practice, T is a floating point type.

Implementations§

Return a new dendrogram with space for the given number of observations.

Clear this dendrogram and ensure there is space for the given number of observations.

This method is useful for reusing a dendrogram’s allocation.

Note that this method does not need to be called before passing it to one of the clustering functions. The clustering functions will reset the dendrogram for you.

Push a new step on to this dendrogram.

Panics

This method panics if the dendrogram has N - 1 steps, where N is the number of observations supported by this dendrogram.

Returns the steps in the dendrogram.

Return a mutable slice of the steps in this dendrogram.

Return the number of steps in this dendrogram.

Return true if and only if this dendrogram has no steps.

Return the number of observations that this dendrogram supports.

Returns the total number of observations in the cluster identified by the following label.

The label may be any value in the half-open interval [0, N + N - 1), where N is the total number of observations.

Compare two dendrograms for approximate equality.

Approximate equality in this case refers to the dissimilarities in each step. In particular, two dissimilarities are considered equal if and only if the absolute value of their difference is less than or equal to the given epsilon value.

Trait Implementations§

Formats the value using the given formatter. Read more
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
The returned type after indexing.
Performs the indexing (container[index]) operation. Read more
Performs the mutable indexing (container[index]) operation. Read more
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.