function M=minitsp(A,N);
% generates a random N city tsp
% from a (larger) tsp A

[m,n]=size(A); % m==n!

if (N>m),
  sprintf('Please select N < number of nodes in A')
M=0;
return;
end

p=randperm(m);
nodes=p(1:N); % these are our nodes to include

ii=zeros(m,1);
ii(nodes)=1;

I=ii*ii';

L=A(I==1);

M=zeros(N);

for i=1:N,
M(:,i)=L((i-1)*N + 1:i*N);
end
