% function to convert a graph in list form to 
% an adjancency matrix. List form means the the 
% graph is given a an array with V rows, and the
% non-zero entries of the kth row give the vertices 
% adjacent to vertex k

function M=list2adjmat(G)
   V=size(G,1);
   M=zeros(V);
   for k=1:V
       row=G(k,:);
       row=row(row>0);
       M(k,row)=1;
   end % for k
return 