@@ -723,9 +723,9 @@ function(gr, hook, user_param, limit, include, exclude, max, size, reps)
723723end );
724724
725725InstallGlobalFunction(DIGRAPHS_BronKerbosch,
726- function (gr, hook, user_param , lim, inc, exc, max, size, reps, inc_var, exc_var )
727- local vtx, grp, invariant_inc, invariant_exc, invariant, adj, exc_inv, start,
728- possible, found_orbits, add, bk, num, x;
726+ function (gr, hook, param , lim, inc, exc, max, size, reps, inc_var, exc_var )
727+ local vtx, invariant_inc, invariant_exc, invariant, adj, exc_inv, start,
728+ possible, isolated, grp, found_orbits, add, bk, num, x, gen ;
729729
730730 # Arguments must be:
731731 # gr - a digraph
@@ -759,7 +759,6 @@ function(gr, hook, user_param, lim, inc, exc, max, size, reps, inc_var, exc_var)
759759
760760 gr := MaximalSymmetricSubdigraphWithoutLoops(gr);
761761 vtx := DigraphVertices(gr);
762- grp := AutomorphismGroup(gr);
763762
764763 invariant_inc := Length(inc_var) = 0 ;
765764 invariant_exc := Length(exc_var) = 0 ;
@@ -793,6 +792,22 @@ function(gr, hook, user_param, lim, inc, exc, max, size, reps, inc_var, exc_var)
793792 IntersectBlist(possible, adj[ x] );
794793 od ;
795794
795+ isolated := DigraphSources(gr); # sources = sinks = isolated vertices
796+ if reps and not IsEmpty(isolated) then
797+ # Optimisation for when there are isolated vertices
798+ grp := Group(());
799+ for gen in GeneratorsOfGroup(AutomorphismGroup(gr)) do
800+ # Discard generators which act on the isolated points
801+ if not SmallestMovedPoint(gen) in isolated then
802+ grp := ClosureGroup(grp, gen);
803+ fi ;
804+ od ;
805+ SubtractBlist(possible, BlistList(vtx, isolated));
806+ possible[ isolated[ 1 ]] := true ;
807+ else
808+ grp := AutomorphismGroup(gr);
809+ fi ;
810+
796811 found_orbits := [] ;
797812
798813 # Function to find the valid cliques of an orbit given an orbit rep
@@ -801,7 +816,7 @@ function(gr, hook, user_param, lim, inc, exc, max, size, reps, inc_var, exc_var)
801816
802817 c := ListBlist(vtx, c);
803818 if reps then # we are only looking for orbit reps, so add the rep
804- hook(user_param , c);
819+ hook(param , c);
805820 num := num + 1 ;
806821 return ;
807822 elif not ForAny(found_orbits, x -> c in x) then
@@ -814,7 +829,7 @@ function(gr, hook, user_param, lim, inc, exc, max, size, reps, inc_var, exc_var)
814829 # are invariant so there is nothing extra to check
815830 n := Minimum(lim - num, n);
816831 for c in orb{[ 1 .. n]} do
817- hook(user_param , c);
832+ hook(param , c);
818833 od ;
819834 num := num + n;
820835 return ;
@@ -827,7 +842,7 @@ function(gr, hook, user_param, lim, inc, exc, max, size, reps, inc_var, exc_var)
827842 i := i + 1 ;
828843 c := BlistList(vtx, orb[ i] );
829844 if SizeBlist(IntersectionBlist(exc_var, c)) = 0 then
830- hook(user_param , orb[ i] );
845+ hook(param , orb[ i] );
831846 num := num + 1 ;
832847 fi ;
833848 od ;
@@ -838,7 +853,7 @@ function(gr, hook, user_param, lim, inc, exc, max, size, reps, inc_var, exc_var)
838853 i := i + 1 ;
839854 c := BlistList(vtx, orb[ i] );
840855 if IsSubsetBlist(c, inc_var) then
841- hook(user_param , orb[ i] );
856+ hook(param , orb[ i] );
842857 num := num + 1 ;
843858 fi ;
844859 od ;
@@ -851,7 +866,7 @@ function(gr, hook, user_param, lim, inc, exc, max, size, reps, inc_var, exc_var)
851866 c := BlistList(vtx, orb[ i] );
852867 if SizeBlist(IntersectionBlist(exc_var, c)) = 0
853868 and IsSubsetBlist(c, inc_var) then
854- hook(user_param , orb[ i] );
869+ hook(param , orb[ i] );
855870 num := num + 1 ;
856871 fi ;
857872 od ;
@@ -973,5 +988,5 @@ function(gr, hook, user_param, lim, inc, exc, max, size, reps, inc_var, exc_var)
973988 num := 0 ;
974989
975990 bk(start, possible, BlistList(vtx, [] ), grp, Length(inc));
976- return user_param ;
991+ return param ;
977992end );
0 commit comments