This is documentation for an old release of SciPy (version 0.17.1). Read this page in the documentation of the latest stable release (version 1.15.1).
scipy.cluster.hierarchy.is_valid_linkage¶
- scipy.cluster.hierarchy.is_valid_linkage(Z, warning=False, throw=False, name=None)[source]¶
Checks the validity of a linkage matrix.
A linkage matrix is valid if it is a two dimensional array (type double) with n rows and 4 columns. The first two columns must contain indices between 0 and 2n−1. For a given row i, the following two expressions have to hold:
0≤Z[i,0]≤i+n−10≤Z[i,1]≤i+n−1I.e. a cluster cannot join another cluster unless the cluster being joined has been generated.
Parameters: Z : array_like
Linkage matrix.
warning : bool, optional
When True, issues a Python warning if the linkage matrix passed is invalid.
throw : bool, optional
When True, throws a Python exception if the linkage matrix passed is invalid.
name : str, optional
This string refers to the variable name of the invalid linkage matrix.
Returns: b : bool
True if the inconsistency matrix is valid.