function h=plotlattice(G,str);
%PLOTLATTICE.m--pretty picture of a randomized ring lattice (reworklattice.m)
%
%h=plotlattice(G,str);
%
%Makes a pretty picture of a graph with n vertices and edges defined by 
%n-by-n sparse matrix G.  The edges are assumed to lie on a circle of
%radius 1.  str is an optional plot option (e.g. 'ro','b','g:',etc)
%


[m,n]=size(G);
if(m~=n)
	error('G should be square')
end

[I,J]=find(G);%get edges

theta=linspace(0,2*pi,n+1);
theta=theta(1:n)';
x=sin(theta);y=cos(theta); %x and y coordinates

X=[x(I),x(J)]';Y=[y(I),y(J)]';
if(nargin>1)
	h=plot(X,Y,str); 
else
	h=plot(X,Y);
end
