diplomat.utils.clustering.nn_chain

diplomat.utils.clustering.nn_chain(dists: ndarray, linkage_mode: int) Tuple[ndarray, ndarray][source]

Use the nearest neighbor chain algorithm to perform hierarchical clustering of a graph.

Parameters:
  • dists – A NxN 2d numpy array of floats, the pairwise distances between each node in the graph.

  • linkage_mode – The distance merging rule to use, see ClusteringMethod for available options. Impacts the results hierarchical clustering returns.

Returns:

Two numpy arrays. The first is an array of shape Nx2 of ints, being which nodes to merge in order to produce the clustering. The second array is an length N array of floats, being the distances of the edges merged at each step.