function [Label,times,disN]=CFSFDPK(data,dc,k)
t0=clock;
[r,c]=size(data);
dens=ones(1,r);
Label=zeros(1,r);
Cluster=zeros(1,r);
disN=0;
dmax=-1;
for i=1:r
%Neibor=[];
for j=i+1:r
dis=0;
for h=1:c
dis=dis+(data(i,h)-data(j,h))^2;
end
dis=sqrt(dis);
disN=disN+1;
if dis<dc
dens(i)=dens(i)+1;
%Neibor(dens(i))=j;
dens(j)=dens(j)+1;
end
if dmax==-1 || dmax<dis
dmax=dis;
end
end
end
[Y,IY]=sort(dens,'descend');
%最大密度
Tag=IY(1);
Cluster(Tag)=IY(Tag);
Sep(Tag)=dmax;
Res(Tag)=Sep(Tag)*dens(Tag);
for i=2:r
Ltm=IY(1:i-1);
Tag=IY(i);
dm=dmax;
for j=1:i-1
dis=0;
for h=1:c
dis=dis+(data(Tag,h)-data(Ltm(j),h))^2;
end
dis=sqrt(dis);
disN=disN+1;
if dis<dm
dm=dis;
dl=Ltm(j);
end
end
Sep(Tag)=dm;
Res(Tag)=dm*dens(Tag);
Cluster(Tag)=dl;
end
[X,IX]=sort(Res,'descend');
%centers=IX(1:k);
for j=1:k
Label(IX(j))=j;
end
for i=1:r
if Label(IY(i))==0
W=Cluster(IY(i));
Label(IY(i))=Label(W);
end
end
% l=1;
% W=find(Label==0,1);
%
% while ~isempty(W)
% Cur=W;
% if Label(Cur)==0
% Label(Cur)=l;
% if Cluster(Cur)~=Cur
% W=Cluster(Cur);
% else
% W=find(Label==0,1);
% l=l+1;
% end
% else
% s=find(Label==l);
% Label(s)=Label(Cur);
% W=find(Label==0,1);
% end
% end
times=etime(clock,t0);
% new_class=Label;
% [sums,cluster]=equation(new_class);
% l=length(sums);
% cs=unique(class);
% n=length(cs)+2;
% statistic=zeros(l,n);
% statistic(:,1)=sums;
% ms=0;
% PE=0;
% RE=0;
% true_class=zeros(1,r);
% for i=1:l
% s=class_distribution(setdiff(cluster(i,:),0),cs,class);
% for j=2:n-1
% statistic(i,j)=s(j-1);
% end
% [maxvalue,maxrow]=max(s);
% attr_class=unique(class);
% for clusteri=1:length(setdiff(cluster(i,:),0))
% if isequal(class(cluster(i,clusteri)),attr_class(maxrow))
% true_class(cluster(i,clusteri))=1;
% end
% end
% statistic(i,n)=maxvalue/sums(i);
% PE=PE+maxvalue/sums(i);
% ms=ms+max(s);
% end
% for i=1:l
% [maxvalue,maxrow]=max(statistic(i,[2:n-1]));
% if sum(statistic(:,maxrow+1))~=0
% RE=RE+maxvalue/sum(statistic(:,maxrow+1));
% %RE=RE+max(statistic(:,i+1))/sum(statistic(:,i+1));
% end
% end
% AC=ms/r;
% PE=PE/l;
% RE=RE/l;
% ARI=CorrectedRandIndex(Label,class);
% NMI=MutualInfromation(Label,class);
end