% test if graph is bipartite
function ans=is_bipartite(G)
   [count,sizes,new_G]=find_comps_nopic(G)
   start=[0,cumsum(sizes)]
   ans=1;
   for m=1:count
     list=start(m)+1:start(m+1)
     H=G(list,list);
     [tree1,tree2,dist]=spanning_tree(H,1);
     V=length(dist);
     dist
     for k=1:V
        for j=find(H(k,:)>0)
          if mod(dist(k),2)==mod(dist(j),2)
             [k,dist(k),j,dist(j)]
	     ans=0;
          end %if
        end % for j
     end % for k
   end  % for m
return 
