From 2b23a400723555069671a8006ae782d7a7c6c38c Mon Sep 17 00:00:00 2001 From: Chris Jefferson Date: Mon, 28 Oct 2019 14:21:15 +0000 Subject: [PATCH] Speed up OnDigraphs for a graph and a permutation * Instead of checking if the permutation fixes the vertices, check if it is the identity (which is much cheaper, although catches less cases) * Do not check explictly if the permutation maps the vertices of the graph to itself, do the mapping then check afterwards. --- gap/oper.gi | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/gap/oper.gi b/gap/oper.gi index e1231fa88..39659fa0a 100644 --- a/gap/oper.gi +++ b/gap/oper.gi @@ -665,15 +665,19 @@ end); InstallMethod(OnDigraphs, "for a mutable digraph by out-neighbours and a perm", [IsMutableDigraph and IsDigraphByOutNeighboursRep, IsPerm], function(D, p) - local out; - if ForAll(DigraphVertices(D), i -> i ^ p = i) then + local out, permed; + if p = () then return D; - elif ForAny(DigraphVertices(D), i -> i ^ p > DigraphNrVertices(D)) then + fi; + + out := D!.OutNeighbours; + permed := Permuted(out, p); + if Length(permed) > DigraphNrVertices(D) then ErrorNoReturn("the 2nd argument

must be a permutation that permutes ", "of the digraph that is the 1st argument,"); fi; - out := D!.OutNeighbours; - out{DigraphVertices(D)} := Permuted(out, p); + + out{DigraphVertices(D)} := permed; Apply(out, x -> OnTuples(x, p)); ClearDigraphEdgeLabels(D); return D; @@ -682,7 +686,7 @@ end); InstallMethod(OnDigraphs, "for a immutable digraph and a perm", [IsImmutableDigraph, IsPerm], function(D, p) - if ForAll(DigraphVertices(D), i -> i ^ p = i) then + if p = () then return D; fi; return MakeImmutable(OnDigraphs(DigraphMutableCopy(D), p));