%lX=randn(10000,3);

%for lk =  1:10000
  %  lX(lk,:)=lX(lk,:)/norm(lX(lk,:));
  %end

%[vGraph,vNNInfo,vOpts]= FastGraphFromData( lX, struct('Type','nn','Delta',0.1,'kNN',64), [] );
 

%cX = (rdata(:,ceil(10000*rand(1000,1))))';

%sz1 = size(data,1);
%rind = randperm(sz1);
cX=data(1:2000,:);
cLabels = ones(2000,1);
cOpts.Type='gauss';cOpts.NormalizationType='graph';cOpts.Delta=0.1;cOpts.Precision=1e-2;cOpts.MaxEigenVals=30;cOpts.WhichEigenVals='small';
cXNorm=zeros(size(cX));for lk = 1:size(cX,1);cXNorm(lk,:)=cX(lk,:)/norm(cX(lk,:));end;
%cXNorm = cX;
lW=pdist(cXNorm);
%lW=1-cXNorm*cXNorm';

lDelta=0.4;lWW=exp(-(lW/lDelta).^2);

lDD=sum(squareform(lWW),2);
%cOpts.NormalizationType='graph';cOpts.WhichEigenVals='small';

[vEigenVectors,vEigenValues,vLaplacian,vDiffusion] = FastLaplacianEigs( cOpts, lDD, squareform(lWW), 10, 1e-8 );

%lDelta=0.2;lWW=exp(-(lW/lDelta).^2);lDD=sum(lWW,2);[vEigenVectors,vEigenValues,vLaplacian,vDiffusion] = FastLaplacianEigs( cOpts, lDD, lWW, 30, 1e-8 );


%lDelta=0.35;lWW=exp(-(lW/lDelta).^2);lDD=sum(lWW,2);[vEigenVectors,vEigenValues,vLaplacian,vDiffusion] = FastLaplacianEigs( cOpts, lDD, lWW, 30, 1e-8 );
figure;scatter3(vEigenVectors(2,:),vEigenVectors(3,:),vEigenVectors(4,:),10,cLabels,'filled');