function s = misseq(A, xy);
% MISSEQ : sequential independent set algorithm
%
% s = misseq(A) returns a maximal independent set of vertices
% in the undirected graph whose adjacency matrix is A
% s = misseq(A, xy) also draws pictures with coords xy

picture = nargin > 1;
A = A | A';
A = A - diag(diag(A));
n = length(A);

if picture
    gplotg(A,xy,'w'); title('Input graph'); 
    disp('hit space to continue'); pause
end;

smask = zeros(1,n);      % independent set mask
for v = 1:n
    adjv = find(A(:,v));
    if nnz(smask(adjv)) == 0
        smask(v) = 1;
    end;
end;
s = find(smask);
 
if picture
    highlight(A,xy,s,'r','w',20); 
    title(['Sequential, size ' num2str(length(s))]);
end;
fprintf('Sequential MIS size = %d\n', length(s));