pub struct Step<T> {
pub cluster1: usize,
pub cluster2: usize,
pub dissimilarity: T,
pub size: usize,
}
Expand description
A single merge step in a dendrogram.
A step always corresponds to a merge between two clusters, where each cluster has at least one observation. Each step itself corresponds to a new cluster containing the observations of the merged clusters.
By convention, the smaller label is assigned to cluster1
.
The type parameter T
refers to the type of dissimilarity used. In
practice, T
is a floating point type.
Fields§
§cluster1: usize
The label corresponding to the first cluster.
The algorithm for labeling clusters is documented on
Dendrogram
.
cluster2: usize
The label corresponding to the second cluster.
The algorithm for labeling clusters is documented on
Dendrogram
.
dissimilarity: T
The dissimilarity between cluster1
and cluster2
.
If both cluster1
and cluster2
correspond to singleton clusters,
then this dissimilarity is equivalent to the pairwise dissimilarity
between the clusters’ corresponding observations. Otherwise, the
dissimilarity is computed according to the clustering
Method
used.
size: usize
The total number of observations in this merged cluster. This is
always equivalent to the total number of observations in cluster1
plus the total number of observations in cluster2
.
Implementations§
source§impl<T> Step<T>
impl<T> Step<T>
sourcepub fn new(
cluster1: usize,
cluster2: usize,
dissimilarity: T,
size: usize
) -> Step<T>
pub fn new(
cluster1: usize,
cluster2: usize,
dissimilarity: T,
size: usize
) -> Step<T>
Create a new a step that can be added to a dendrogram.
Note that the clustering labels given are normalized such that the
smallest label is always assigned to cluster1
.
sourcepub fn set_clusters(&mut self, cluster1: usize, cluster2: usize)
pub fn set_clusters(&mut self, cluster1: usize, cluster2: usize)
Set the cluster labels on this step.
Note that the clustering labels given are normalized such that the
smallest label is always assigned to cluster1
.
source§impl<T: Float> Step<T>
impl<T: Float> Step<T>
sourcepub fn eq_with_epsilon(&self, other: &Step<T>, epsilon: T) -> bool
pub fn eq_with_epsilon(&self, other: &Step<T>, epsilon: T) -> bool
Compare two steps for approximate equality.
Approximate equality in this case refers to the dissimilarity in each
step. In particular, two dissimilarity are considered equal if and only
if the absolute value of their difference is less than or equal to the
given epsilon
value.