Skip to main content
`Ctrl`+`K`
scipy.cluster.hierarchy.

# ClusterNode

class scipy.cluster.hierarchy.ClusterNode(id, left=None, right=None, dist=0.0, count=1)

  A tree node class for representing a cluster.

  Leaf nodes correspond to original observations, while non-leaf nodes correspond to non-singleton clusters.

  The `to_tree` function converts a matrix returned by the linkage function into an easy-to-use tree representation.

  All parameter names are also attributes.

  Parameters:
    idint

      The node id.

    leftClusterNode instance, optional

      The left child tree node.

    rightClusterNode instance, optional

      The right child tree node.

    distfloat, optional

      Distance for this cluster in the linkage matrix.

    countint, optional

      The number of samples in this cluster.

  Methods

  `get_count`() | The number of leaf nodes (original observations) belonging to the cluster node nd.
  `get_id`() | The identifier of the target node.
  `get_left`() | Return a reference to the left child tree object.
  `get_right`() | Return a reference to the right child tree object.
  `is_leaf`() | Return True if the target node is a leaf.
  `pre_order`([func]) | Perform pre-order traversal without recursive function calls.

  See also

  `to_tree`

    for converting a linkage matrix `Z` into a tree object.