Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Solving the shortest distance problem with matlab
Solving the shortest distance problem with matlab
The matrix dist is used to store the distance between each point, that is, (dist)ij is the distance between points I and J.

N = size(dist, 1);

seq = 1: 1:N;

perm = perms(seq);

size_perm = size(perm, 1);

min _ dist = inf

for i = 1: 1:size_perm

total _ dist = 0;

For j = 1: 1:N

total_dist = total_dist + dist(j,perm(i,j));

end

If total _ dist & lt minimum distance

min _ dist = total _ dist

end

end