function [best_route, shortest_distance]=traveler_comb(x,y);
	% x - cities x coordinates
	% y - cities y coordinates

	N=length(x);
	init_sqeuence=1:N;

	p=init_sqeuence(2:N-1); % since we start at 1st city and end in the last
	pold=p*0; % pold MUST be not equal to p



	function dist=route_distance(route)
		dx=diff( x(route) );
		dy=diff( y(route) );
		dist = sum( sqrt(dx.^2 + dy.^2) );
	end

	route=[1,p,N];
	best_route=route;
	shortest_distance=route_distance(route);
	% show initial guess
	figure(1);
	plot( x(1), y(1), 'x', x(N), y(N), 'x',  x(2:N-1), y(2:N-1), 'o', x(route), y(route), '-');

	while ( any(pold ~=p) ) % notice any operator since we compare 2 vectors
		pold=p;
		p=permutation(pold);
		route=[1,p,N];
		dist=route_distance(route);
		if (dist < shortest_distance)
			shortest_distance=dist;
			best_route=route;
			% show updated guess
			figure(1);
			plot( x(1), y(1), 'x', x(N), y(N), 'x',  x(2:N-1), y(2:N-1), 'o', x(route), y(route), '-');
		end
	end
end


