
# given a list of independent sets mis for (G,X), extract a list
# of k disjoint members of the list each of size m, and return
# the subgraph G0,X0 induced on the complementary set of vertices.

greedy:=proc(mis,G,X,m,k) local new,X0,i,j;
  new:=mis; X0:=X;
  for i to k do
    new:=map(proc(x,y) if nops(x)=y then x fi end,new,m);
    if nops(new)=0 then ERROR(`impossible`) fi;
    X0:=X0 minus new[1];
    new:=subs({seq(j=NULL,j=new[1])},subsop(1=NULL,new));
  od;
  map(proc(x,y) if nops(x minus y)=0 then x fi end,G,X0),X0;
end:
 
