apaClustering.CDC(Features, K, Ratio)
=apaClustering.CDC(Features, K, Ratio)Result
Clustering by measuring local direction centrality (CDC), following Peng et al. (2022). Every data point is assigned to a cluster. Returns a 1 x n row of cluster labels numbered from 1.
Syntax
Features: m x n data matrix with m features (at least 2) in rows and n data points in columns
K: number of nearest neighbors used to measure the direction centrality; integer between 2 and the number of distinct data points minus 1; with m > 2 features at least m + 1. Typical values: 10 to 30
Ratio: share of internal points; larger than 0 and at most 1. Typical values: 0.7 to 0.95
Remarks
The direction centrality metric (DCM) of a data point measures how evenly its K nearest neighbors surround it. With 2 features, it is the variance of the K angles between consecutive neighbor directions, divided by its maximum (K - 1) · 4π² / K². With m > 2 features, the neighbor directions are projected onto the unit sphere and the DCM is the sample variance of the volumes of the simplices of their convex hull; if the directions do not span all m dimensions, the DCM is 0. Low values indicate internal points, high values boundary points.
Data points with a DCM below the ceil(n · Ratio)-th smallest DCM are internal points, all others are boundary points. The reachable distance r of an internal point is its distance to the nearest boundary point. Two internal points i and j are connected if d(i, j) ≤ r_i + r_j; the clusters are the connected components. Each boundary point is then assigned to the cluster of its nearest internal point.
Duplicate data points are clustered once and receive the same label. Distances are Euclidean, so features on different scales should be standardized first. Clusters are numbered in the order in which they first appear in the data. Neighbors are ranked by distance, ties are broken by the lower column index. If no data point has a DCM below the threshold, an error is returned.
The implementation follows the authors’ MATLAB reference code: Peng, D., Gui, Z., Wang, D. et al. (2022), Clustering by measuring local direction centrality for data with heterogeneous density and weak connectivity, Nature Communications 13, 5455, https://www.nature.com/articles/s41467-022-33136-9.
Pressing Esc aborts the calculation; the function then returns "Calculation aborted by user."
