diplomat.utils.clustering.get_components

diplomat.utils.clustering.get_components(merge_list: ndarray, distances: ndarray, num_components: int) Tuple[ndarray, int][source]

Get the components or clusters of set of nodes after performing hierarchical clustering, given a specific number of desired components to be returned. Returns clustering solution at that level.

Parameters:
  • merge_list – Nodes to merge at each step of the clustering, first output of nn_chain().

  • distances – Distances of each edge that was merged at each step of clustering, second output of nn_chain().

  • num_components – The number of components, or cluster, desired. Stops merging nodes once it reaches this many clusters.

Returns:

Two values, an array of integers giving the component each node belongs to, and an integer giving the total number of components in the final result.