% input number of nodes n and number of edges m < n*(n-1)/2
density=7/(n);
r=sprandsym(n,density);  
r(1:n+1:end)=zeros(n,1);
[inode,jnode]=find(triu(r));
[inodeAL,jnodeAL]=find(r);
%[i,j]=sort(inode);
%inode=inode(j);
%jnode=jnode(j);
indsE=sub2ind([n,n],inode,jnode);
indsEAL=sub2ind([n,n],inodeAL,jnodeAL);
mm=length(indsE);

G=zeros(n);
G(indsE)=ones(mm,1);
temp=find(triu(ones(n),1));
indsEc=setdiff(temp,indsE);


GAL=zeros(n);
GAL(indsEAL)=ones(2*mm,1);
GAL(1:n+1:end)=ones(n,1);
indsEAL1=find(GAL);
temp=find(ones(n));
indsEcAL=setdiff(temp,indsEAL1); 

mc=length(indsEc);
[ iE,jE ] = ind2sub([n,n],indsE);
adj = [iE,jE];


