This is a pre-release version (2.0.0.dev0+git20260907.41eeb59).Go to latest (1.18.0)
{ } Raw JSON

bundles / scipy 2.0.0.dev0+git20260907.41eeb59 / scipy / cluster / hierarchy / _optimal_leaf_ordering / optimal_leaf_ordering

cython_function_or_method

scipy.cluster.hierarchy._optimal_leaf_ordering:optimal_leaf_ordering

Signature

def optimal_leaf_ordering(Z, D)

Summary

Compute the optimal leaf order for Z (according to D) and return an optimally sorted Z.

Extended Summary

We start by sorting and relabelling Z and D according to the current leaf order in Z.

This is because when everything is sorted each cluster (including singletons) can be defined by its range over (0...n_points).

This is used extensively to loop efficiently over the various arrays in the algorithm.

Aliases

  • scipy.cluster.hierarchy._optimal_leaf_ordering.optimal_leaf_ordering