📄 udisomapgeodistancek.m
字号:
function [GeoD,D]=udIsomapGeoDistanceK(X, NeighborsNum);
% 计算Isomap算法的测地线距离
% Input:
% X = D x N matrix of input points (where D is the dimensionality of points, N is the number of data points)
% NeighborsNum = neighborhood size
%
% Output:
% GeoD = Geodesic Distance
%%%%% Step 0: Initialization and Parameters %%%%%
D = L2_distance(X, X, 1);
N = size(D,1);
if ~(N==size(D,2))
error('D must be a square matrix');
end;
K = NeighborsNum;
INF = 1000*max(max(D))*N; %% effectively infinite distance
%%%%% Step 1: Construct neighborhood graph %%%%%
%disp('Constructing neighborhood graph...');
[tmp, ind] = sort(D);
tic;
for i=1:N
D(i,ind((2+K):end,i)) = INF;
end
D = sparse(D);
D = min(D,D'); %% Make sure distance matrix is symmetric
%%%% Step 2: Compute shortest paths %%%%%
landmarks = 1:N;
GeoD = dijkstra(sparse(D), landmarks);
return;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -