#
# Suppose pg is a list of generators for the automorphism group A of a
# vertex-colored digraph (G,mu) in which block k is a singleton {i}.
# If mu' is the vertex partition obtained by merging blocks k and k+1,
# then A is the stabilizer of i in Aut(G,mu'), and we can determine a
# full set of generators for Aut(G,mu') by using calls to 'cisom' to
# determine the Aut(G,mu')-orbit of i.
#
# The return value is a list of generators for Aut(G,mu').
# Currently used by both 'autgroup' and 'canorder'.
# Errors occur if block k is not a singleton or block k+1 does not exist.
#
`posets/buildgrp`:=proc(pg,G,mu,k) local nu,pg0,pi,alive,i;
  i:=op(mu[k]); alive:=mu[k+1]; pg0:=op(pg);
  while nops(alive)>0 do
    nu:=subs({i=alive[1],alive[1]=i},mu);
    pi:=`posets/cisom`(G,mu,G,nu);
    if pi<>NULL then pg0:=pg0,map(x->if not x then x fi,pi) fi;
    alive:=alive minus `posets/orbit`([pg0],alive[1])
  od; [pg0]
end:
#
save `posets/buildgrp`, cat(HomeLib,`/posets/buildgrp.m`);
quit;

