@@ -993,15 +993,25 @@ end);
993993# 4. Actions
994994# ##############################################################################
995995
996- InstallMethod(OnDigraphs, " for a mutable digraph by out-neighbours and a perm" ,
997- [ IsMutableDigraph and IsDigraphByOutNeighboursRep , IsPerm] ,
996+ InstallMethod(OnDigraphs, " for a digraph and a perm" ,
997+ [ IsDigraph , IsPerm] ,
998998function (D, p )
999- local out;
1000999 if ForAll(DigraphVertices(D), i -> i ^ p = i) then
10011000 return D;
10021001 elif ForAny(DigraphVertices(D), i -> i ^ p > DigraphNrVertices(D)) then
10031002 ErrorNoReturn(" the 2nd argument <p> must be a permutation that permutes " ,
1004- " the vertices of the digraph <D> that is the 1st argument," );
1003+ " the vertices of the digraph <D> that is the 1st argument" );
1004+ fi ;
1005+ return OnDigraphsNC(D, p);
1006+ end );
1007+
1008+ InstallMethod(OnDigraphsNC,
1009+ " for a mutable digraph by out-neighbours and a perm" ,
1010+ [ IsMutableDigraph and IsDigraphByOutNeighboursRep, IsPerm] ,
1011+ function (D, p )
1012+ local out;
1013+ if p = () then
1014+ return D;
10051015 fi ;
10061016 out := D!. OutNeighbours;
10071017 out{ DigraphVertices(D)} := Permuted(out, p);
@@ -1010,26 +1020,40 @@ function(D, p)
10101020 return D;
10111021end );
10121022
1013- InstallMethod(OnDigraphs , " for a immutable digraph and a perm" ,
1023+ InstallMethod(OnDigraphsNC , " for a immutable digraph and a perm" ,
10141024[ IsImmutableDigraph, IsPerm] ,
10151025function (D, p )
1016- if ForAll(DigraphVertices(D), i -> i ^ p = i) then
1026+ local out, permed;
1027+ if p = () then
10171028 return D;
10181029 fi ;
1019- return MakeImmutable(OnDigraphs(DigraphMutableCopy(D), p));
1030+ out := D!. OutNeighbours;
1031+ permed := Permuted(out, p);
1032+ Apply(permed, x -> OnTuples(x, p));
1033+ return DigraphNC(IsImmutableDigraph, permed);
10201034end );
10211035
10221036InstallMethod(OnDigraphs,
1023- " for a mutable digraph by out-neighbours and a transformation" ,
1024- [ IsMutableDigraph and IsDigraphByOutNeighboursRep , IsTransformation] ,
1037+ " for a digraph and a transformation" ,
1038+ [ IsDigraph , IsTransformation] ,
10251039function (D, t )
1026- local old, new, v;
10271040 if ForAll(DigraphVertices(D), i -> i ^ t = i) then
10281041 return D;
10291042 elif ForAny(DigraphVertices(D), i -> i ^ t > DigraphNrVertices(D)) then
10301043 ErrorNoReturn(" the 2nd argument <t> must be a transformation that " ,
10311044 " maps every vertex of the digraph <D> that is the 1st " ,
1032- " argument, to another vertex." );
1045+ " argument, to another vertex" );
1046+ fi ;
1047+ return OnDigraphsNC(D, t);
1048+ end );
1049+
1050+ InstallMethod(OnDigraphsNC,
1051+ " for a mutable digraph by out-neighbours and a transformation" ,
1052+ [ IsMutableDigraph and IsDigraphByOutNeighboursRep, IsTransformation] ,
1053+ function (D, t )
1054+ local old, new, v;
1055+ if t = IdentityTransformation then
1056+ return D;
10331057 fi ;
10341058 old := D!. OutNeighbours;
10351059 new := List(DigraphVertices(D), x -> [] );
@@ -1041,13 +1065,19 @@ function(D, t)
10411065 return D;
10421066end );
10431067
1044- InstallMethod(OnDigraphs , " for a immutable digraph and a transformation" ,
1068+ InstallMethod(OnDigraphsNC , " for a immutable digraph and a transformation" ,
10451069[ IsImmutableDigraph, IsTransformation] ,
10461070function (D, t )
1047- if ForAll(DigraphVertices(D), i -> i ^ t = i) then
1071+ local old, new, v;
1072+ if t = IdentityTransformation then
10481073 return D;
10491074 fi ;
1050- return MakeImmutable(OnDigraphs(DigraphMutableCopy(D), t));
1075+ old := D!. OutNeighbours;
1076+ new := List(DigraphVertices(D), x -> [] );
1077+ for v in DigraphVertices(D) do
1078+ Append(new[ v ^ t] , OnTuples(old[ v] , t));
1079+ od ;
1080+ return DigraphNC(IsImmutableDigraph, new);
10511081end );
10521082
10531083InstallMethod(OnTuplesDigraphs,
@@ -1060,7 +1090,7 @@ InstallMethod(OnSetsDigraphs,
10601090[ IsDigraphCollection and IsHomogeneousList, IsPerm] ,
10611091function (S, p )
10621092 if not IsSet(S) then
1063- ErrorNoReturn(" the first argument must be a set (a strictly sorted list), " );
1093+ ErrorNoReturn(" the first argument must be a set (a strictly sorted list)" );
10641094 fi ;
10651095 return Set(S, D -> OnDigraphs(DigraphMutableCopyIfMutable(D), p));
10661096end );
@@ -1081,7 +1111,7 @@ function(D, perms)
10811111 i -> i ^ perms[ 2 ] > DigraphNrEdges(D)) then
10821112 ErrorNoReturn(" the 2nd entry of the 2nd argument <perms> must " ,
10831113 " permute the edges of the digraph <D> that is the 1st " ,
1084- " argument, " );
1114+ " argument" );
10851115 fi ;
10861116
10871117 return OnDigraphs(D, perms[ 1 ] );
0 commit comments