dise#

nvmolkit.clustering.dise(
distance_matrix: AsyncGpuResult | Tensor | ndarray,
cutoff: float,
*,
assignment: Literal['first', 'nearest'] = 'nearest',
stream: Stream | None = None,
output: OutputMode = OutputMode.DEVICE,
) → ClusterDeviceResult | tuple[tuple[int, ...], ...]#

Cluster a distance matrix by directed sphere exclusion (DISE).

Centroids are the leaders selected by leader(). With assignment="first", each item joins the first centroid that excluded it; with "nearest", each non-centroid joins its nearest centroid, with ties going to the earlier centroid. Clusters are ordered by descending size, then by centroid selection order.

Distances are compared in float32, so a distance within float32 rounding of the cutoff can be classified differently than in double precision, and distances within float32 rounding of each other tie in "nearest" assignment.

Parameters:
  • distance_matrix – Square float32 or float64 matrix of shape (N, N). Element [i, j] is the distance from item i to item j. Values are converted to float32 for comparisons. Values that overflow float32 during conversion become infinity.

  • cutoff – Inclusive exclusion distance, rounded to float32. Must be between zero and the largest finite float32 value.

  • assignment – "first" or "nearest".

  • stream – CUDA stream to use. If None, uses the current stream.

  • output – Result representation.

Returns:

A ClusterDeviceResult for OutputMode.DEVICE, or centroid-first tuples of input indices for OutputMode.RDKIT.