This repository has been archived on 2021-09-27. You can view files and clone it, but cannot push or open issues or pull requests.
NC/mp4/Project_4_Maggioni_Claudio/src/epsilonSimGraph.m

28 lines
No EOL
641 B
Matlab

function [G] = epsilonSimGraph(epsilon, Pts)
% Construct an epsilon similarity graph
% Input
% epsilon: size of neighborhood (calculate from Prim's Algorithm)
% Pts : coordinate list of the sample
%
% Output
% A : the epsilon similarity matrix
%
% USI, ICS, Lugano
% Numerical Computing
fprintf('----------------------------\n');
fprintf('epsilon similarity graph\n');
fprintf('----------------------------\n');
n = size(Pts, 1);
G = zeros(n, n);
for i = 1:n
for j = 1:n
dist = norm((Pts(i, :) - Pts(j, :)), 2);
if dist < epsilon
G(i, j) = 1;
G(j, i) = 1;
end
end
end
end