Skip to content
Snippets Groups Projects
Commit cb648d9b authored by Mark Winter's avatar Mark Winter
Browse files

Fixes for the Laplacian Eigenmaps problem

parent e569883b
Branches
No related tags found
No related merge requests found
% Produce k-dimensional eigenvectors of symmetric Laplacian of A
function v_pts = LaplacianEigenmaps(A,k)
D = zeros(size(A));
for i=1:size(A,1)
D(i,i)=sum(A(i,:));
end
d = sum(A,2);
bValid = d > 0;
dInvSqrt = zeros(size(d));
dInvSqrt(bValid) = 1 ./ sqrt(d(bValid));
D = diag(d);
Disqrt = diag(dInvSqrt);
L = D - A;
L = D^(-.5) * L * D^(-.5);
L = Disqrt * L * Disqrt;
% Regularize the affinity matrix
for i=1:size(L,1)
for j= 1:size(L,2)
L(i,j)= max(L(i,j),L(j,i));
end
L(i,i)=0;
end
% % Regularize the affinity matrix
% for i=1:size(L,1)
% for j= 1:size(L,2)
% L(i,j)= min(L(i,j),L(j,i));
% end
% % L(i,i)=1;
% end
[eVec,eVal] = eig(L);
evals = diag(eVal);
[evals,srtIdx] = sort(evals);
v_pts = eVec(:,srtIdx(2:k+1));
v_pts = eVec(:,srtIdx(2:(k+1)));
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment