function ordering = Exhaustive_TSP(cities)
disp('Exhaustive TSP:')
tic
N = length(cities);
orders = perms(1:N);
orders = [orders, orders(:, 1)];
[orow, ocol] = size(orders);

dis = [];
for i = 1:orow
    dist = 0;
    for j = 1:N
        dis_temp = sqrt((cities(orders(i, j), 1)-cities(orders(i, j+1),1))^2 + (cities(orders(i, j),2)-cities(orders(i, j+1),2))^2);
        dist = dist + dis_temp;
    end
    dis = [dis, dist];
end

[min_dis, indx] = min(dis);

ordering = orders(indx,:);
toc

%plot the resulting ordering of cities as
figure;
plot(cities(ordering,1),cities(ordering,2), '-o');
title('Exhaustive TSP');
hold on
for k = 1:N
    text(cities(ordering(k),1),cities(ordering(k),2), num2str(k), 'color', 'r', 'FontSize',18);
end
hold off

min_dis
ordering