% make a random graph by choosing
% a total of m edges at random.
% we must have m <= *n*(n-1)/2.

function G=make_rand_graph2(n,m)
N=min(m,n*(n-1)/2);
G=sparse(n,n);
counter=0;
while counter < N
%for k=1:p*n*(n-1)/2
a=randi(n);
b=randi(n);
if (a~=b)&(G(a,b)==0)
G(a,b)=1;
G(b,a)=1;
counter=counter+1;
end % if
end % while
return