Represents a node (cluster) in the hierarchical clustering tree (dendrogram). Each cluster can be a leaf node (containing a single data point) or an internal node (containing child clusters formed by merging). Implements the tree node data structure required for hierarchical clustering and provides named identification via INamedValue .
Cluster
01 Syntax
02 Methods
| Name | Overloads | Summary |
|---|---|---|
| .ctor | 1 | Initializes a new instance of the Cluster class with the specified name. |
| AddLeafName | 1 | Adds a single leaf name to this cluster's list of leaf names. |
| AppendLeafNames | 1 | Adds a collection of leaf names to this cluster's list of leaf names. |
| AddChild | 1 | Adds a child cluster to this node's children collection. |
| contains | 1 | Determines whether the specified cluster is a direct child of this cluster. |
| OrderLeafs | 1 | Returns the ordered sequence of leaf node names for plotting a dendrogram or heatmap. |
| ToString | 1 | Returns a string representation of this cluster. |
| Equals | 1 | Determines whether the specified object is equal to the current cluster. |
| GetHashCode | 1 | Returns a hash code for this cluster based on its Cluster.Name . |
| CountLeafs | 1 | Recursively counts the total number of leaf nodes in the subtree rooted at the specified node. |
03 Properties
| Name | Overloads | Summary |
|---|---|---|
| Distance | 1 | Gets or sets the Cluster.Distance object associated with this cluster, representing the distance at which this cluster was formed (for internal nodes) or the initial distance fo… |
| WeightValue | 1 | Gets the weight of this cluster from the underlying Cluster.Distance object. |
| DistanceValue | 1 | Gets the distance value of this cluster from the underlying Cluster.Distance object. |
| Parent | 1 | Gets or sets the parent cluster of this node in the dendrogram. |
| Name | 1 | Gets or sets the unique name identifier for this cluster. |
| Id | 1 | 进程内唯一、单调递增的簇标识(非负、小于 2^31)。作为链接表(DistanceMap)的哈希键, 避免每次链接查找都对簇名执行字符串哈希与 String 比较, 同时保证不同的簇对象不会因为重名而共享同一个链接键。 |
| Children | 1 | Gets the read-only collection of child clusters directly under this node. |
| LeafNames | 1 | Gets the list of leaf names contained within this cluster's subtree. |
| IsRoot | 1 | Gets a value indicating whether this cluster is the root node of the dendrogram. |
| isLeaf | 1 | Gets a value indicating whether this cluster is a leaf node. |
| Leafs | 1 | Gets the total number of leaf nodes in the subtree rooted at this cluster. |
| LeafCount | 1 | 供 HierarchyTreeNode.Agglomerate()) 在合并时 O(1) 写入新簇的叶节点数量, 避免 Cluster.Leafs 在树切分(cutTree)、Cluster.OrderLeafs() 以及树图绘制过程中被反复递归重算。 |
| TotalDistance | 1 | Gets the total distance value accumulated along the left-most path from this node to its deepest descendant. |
04 Members
String)Initializes a new instance of the Cluster class with the specified name. The cluster is created as a leaf node with an empty child list, an empty leaf name list, and a default Cluster.Distance object.
| Name | Type | Description |
|---|---|---|
name | String | The unique name identifier for this cluster. |
String)Adds a single leaf name to this cluster's list of leaf names. This is used to track which original data points are contained within a cluster.
| Name | Type | Description |
|---|---|---|
lname | String | The leaf name to add. |
IEnumerable(Of String))Adds a collection of leaf names to this cluster's list of leaf names. This is used when merging clusters to aggregate all descendant leaf names.
| Name | Type | Description |
|---|---|---|
lnames | IEnumerable(Of String) | An enumerable collection of leaf names to append. |
Adds a child cluster to this node's children collection. This method is called during the agglomerative clustering process when two clusters are merged.
Determines whether the specified cluster is a direct child of this cluster.
True if the specified cluster is a direct child; otherwise, False.
Returns the ordered sequence of leaf node names for plotting a dendrogram or heatmap. Leaf clusters are returned in order of increasing leaf count (smallest subtrees first), which produces a visually balanced dendrogram layout.
This function is used to obtain the re-ordered labels for data rows when plotting a clustered heatmap, ensuring that the dendrogram branches are displayed without crossing.
An array of String values representing the leaf names in plot order. For leaf clusters, returns an array containing only the cluster's own name.
Returns a string representation of this cluster. Leaf nodes are prefixed with "Leaf" and internal nodes with "Cluster", followed by the cluster's name.
A String in the format "Leaf {Name}" or "Cluster {Name}".
Object)Determines whether the specified object is equal to the current cluster. Equality is determined solely by the Cluster.Name property.
| Name | Type | Description |
|---|---|---|
obj | Object | The object to compare with the current cluster. |
True if the specified object is a Cluster with the same Cluster.Name ; otherwise, False.
Returns a hash code for this cluster based on its Cluster.Name .
A32-bit signed integer hash code derived from the cluster's name, or0 if the name is Nothing.
Int32)Recursively counts the total number of leaf nodes in the subtree rooted at the specified node. This is a helper method used by the Cluster.Leafs property.
| Name | Type | Description |
|---|---|---|
node | Cluster | The root node of the subtree to count leaves for. |
count | Int32 | The current accumulated count (used for recursive accumulation). |
An Int32 representing the total number of leaf nodes in the subtree.
Gets or sets the Cluster.Distance object associated with this cluster, representing the distance at which this cluster was formed (for internal nodes) or the initial distance for leaf nodes.
A Cluster.Distance instance containing the distance value and optional weight.
Gets the weight of this cluster from the underlying Cluster.Distance object. The weight is used in weighted linkage strategies such as WPGMA.
A Double value representing the weight of this cluster.
Gets the distance value of this cluster from the underlying Cluster.Distance object. For internal nodes, this represents the cophenetic distance at which child clusters were merged. For leaf nodes, this is typically zero or the initial distance.
A Double value representing the distance associated with this cluster.
Gets or sets the parent cluster of this node in the dendrogram. A Nothing value indicates this cluster is the root of the tree. Implements ITreeNodeData.Parent .
The parent Cluster object, or Nothing if this is the root node.
Gets or sets the unique name identifier for this cluster. The name should be unique among all leaf clusters to ensure correct equality comparisons. Implements IKeyedEntity.Key and ITreeNodeData.FullyQualifiedName .
A String representing the name of this cluster.
进程内唯一、单调递增的簇标识(非负、小于 2^31)。作为链接表(DistanceMap)的哈希键, 避免每次链接查找都对簇名执行字符串哈希与 String 比较, 同时保证不同的簇对象不会因为重名而共享同一个链接键。
Gets the read-only collection of child clusters directly under this node. An empty collection indicates that this node is a leaf cluster. Implements ITreeNodeData.ChildNodes .
An IReadOnlyCollection containing the direct children of this cluster.
Gets the list of leaf names contained within this cluster's subtree. For leaf clusters, this list contains the cluster's own name. For internal clusters, it accumulates the names of all descendant leaf nodes.
A List containing the names of all leaf nodes in this subtree.
Gets a value indicating whether this cluster is the root node of the dendrogram. A cluster is considered the root if it has no parent or if its parent is itself. Implements ITreeNodeData.IsRoot .
True if this cluster is the root; otherwise, False.
Gets a value indicating whether this cluster is a leaf node. A cluster is a leaf if it has no children. Implements ITreeNodeData.IsLeaf .
True if this cluster has no children (i.e., it is a leaf node); otherwise, False.
Gets the total number of leaf nodes in the subtree rooted at this cluster. Recursively counts all descendant leaf nodes, including direct children and their children.
An Int32 representing the total count of leaf nodes in this subtree.
供 HierarchyTreeNode.Agglomerate() 在合并时 O(1) 写入新簇的叶节点数量, 避免 Cluster.Leafs 在树切分(cutTree)、Cluster.OrderLeafs() 以及树图绘制过程中被反复递归重算。
Gets the total distance value accumulated along the left-most path from this node to its deepest descendant. This is the sum of distances from this node down through the first child at each level.
A Double value representing the accumulated distance along the left-most branch of this subtree.