This June, Alex Rodriguez and Alessandro Laio published an article in science entitled Clustering by Fast search and find density peaks, for the clustering algorithm Design provides a new way of thinking. Although the article came out after many readers questioned, but overall, the basic idea of the new clustering algorithm is very novel, and simple and lively, it is worth learning. The core idea of this new clustering algorithm lies in the characterization of the clustering center, the principle of the algorithm is introduced in detail, and some details are discussed.
Finally, attach the Matlab sample program (with appropriate code comments) provided by the author in the supplemental material.
[Plain] View Plain copy clear all close all disp (' the only Input needed is a distance matrix file ') disp (' the format of this file should be: ') disp (' column 1: id of Element i ') disp (' column 2: id of element j ') disp (' Column 3: dist (i,j) %% reading data from a file mdist=input (' name of the distance matrix file (with single quotes) \ n '); disp (' Reading input distance matrix ') xx=load (mdist); Nd=max (XX (:, 2)); NL= Max (XX (:, 1)); if (nl>nd) ND=NL; %% ensure DN Taken as the largest of the 12th column and as the total number of data points end n=size (xx,1); %% xx the length of the first dimension, Equivalent to FileNumber of rows (that is, the total number of distances) %% initialized to 0 for i=1:nd for j =1:nd dist (i,j) =0; end end %% use xx to assign a value to the dist array, note that the input only has  0.5*DN (DN-1) values, which is filled with the full matrix %% here does not consider diagonal elements for i=1:n ii=xx (i,1); Jj=xx (i,2); dist (II,JJ) =xx (i,3); dist (jj,ii) =xx (i,3); end %% OK dc percent=2.0; fprintf (' average percentage of neighbours (hard coded): %5.6f\n ', percent); Position=round (n*percent/100); %% round is a rounding function Sda=sort (XX (:, 3) ); %% all distance values in ascending order DC=SDA (position); %% compute local density rho (using Gaussian Core) fprintf (' computing rho with gaussian Kernel of radius: %12.6f\n ',  DC); %% The rho of each data point Values are initialized to 0 for i=1:nd rho (i) =0.; end % gaussian kernel for i=1:nd-1 for j=i+1:ND rho (i) =rho (i) +exp (-(Dist (I,J)/dc) * (Dist (I,J)/dc)); rho (j) =rho (j) +exp (-(Dist (I,J)/dc) * (Dist (I,J)/dc)); end end