diff --git a/.gaplint.yml b/.gaplint.yml index a6e81f9d9..892afe13f 100644 --- a/.gaplint.yml +++ b/.gaplint.yml @@ -1,2 +1,3 @@ disable: - align-assignments +duplicate-function-min-length: 4 diff --git a/doc/digraph.xml b/doc/digraph.xml index bae318126..d992fbe3e 100644 --- a/doc/digraph.xml +++ b/doc/digraph.xml @@ -752,7 +752,7 @@ gap> T := AsSemigroup(IsPartialPermSemigroup, gap> Size(T); 20 gap> D := GreensDClasses(T);; -gap> List(D, x -> Size(x)); +gap> List(D, Size); [ 6, 12, 2 ] ]]> diff --git a/doc/examples.xml b/doc/examples.xml index d3c63f92f..f9a2c9c6a 100644 --- a/doc/examples.xml +++ b/doc/examples.xml @@ -943,7 +943,7 @@ gap> D := BondyGraph(1); gap> IsHamiltonianDigraph(D); false gap> G := List([1 .. 22], x -> DigraphRemoveVertex(D, x));; -gap> ForAll(G, x -> IsHamiltonianDigraph(x)); +gap> ForAll(G, IsHamiltonianDigraph); true]]> diff --git a/etc/gaplint.sh b/etc/gaplint.sh index 57c8b27e6..a478f4697 100755 --- a/etc/gaplint.sh +++ b/etc/gaplint.sh @@ -1,4 +1,4 @@ #!/bin/bash set -e -gaplint --disable W004 *.g gap/* doc/*.xml tst/testinstall.tst tst/standard/*.tst tst/extreme/*.tst tst/workspaces/*.tst +gaplint --disable W004 $@ *.g gap/* doc/*.xml tst/testinstall.tst tst/standard/*.tst tst/extreme/*.tst tst/workspaces/*.tst diff --git a/gap/attr.gi b/gap/attr.gi index 1f0b2dde0..1d99d2015 100644 --- a/gap/attr.gi +++ b/gap/attr.gi @@ -154,15 +154,11 @@ end); InstallMethod(ArticulationPoints, "for a digraph by out-neighbours", [IsDigraphByOutNeighboursRep], -function(D) - return DIGRAPHS_ArticulationPointsBridgesStrongOrientation(D)[2]; -end); +D -> DIGRAPHS_ArticulationPointsBridgesStrongOrientation(D)[2]); InstallMethod(Bridges, "for a digraph by out-neighbours", [IsDigraphByOutNeighboursRep], -function(D) - return DIGRAPHS_ArticulationPointsBridgesStrongOrientation(D)[3]; -end); +D -> DIGRAPHS_ArticulationPointsBridgesStrongOrientation(D)[3]); InstallMethodThatReturnsDigraph(StrongOrientation, "for a digraph by out-neighbours", diff --git a/gap/digraph.gi b/gap/digraph.gi index e4c0d2704..4516135ab 100644 --- a/gap/digraph.gi +++ b/gap/digraph.gi @@ -105,7 +105,7 @@ list -> MakeImmutable(ConvertToMutableDigraphNC(list))); InstallMethod(DigraphConsNC, "for IsMutableDigraph and a record", [IsMutableDigraph, IsRecord], -function(filt, record) +function(_, record) local required, out, name; required := ["DigraphRange", "DigraphSource", "DigraphNrVertices"]; for name in required do @@ -123,7 +123,7 @@ end); InstallMethod(DigraphConsNC, "for IsMutableDigraph and a dense list of out-neighbours", [IsMutableDigraph, IsDenseList], -function(filt, list) +function(_, list) Assert(1, not IsMutable(list)); return ConvertToMutableDigraphNC(List(list, ShallowCopy)); end); @@ -131,11 +131,11 @@ end); InstallMethod(DigraphConsNC, "for IsMutableDigraph and a dense mutable list of out-neighbours", [IsMutableDigraph, IsDenseList and IsMutable], -{filt, list} -> ConvertToMutableDigraphNC(StructuralCopy(list))); +{_, list} -> ConvertToMutableDigraphNC(StructuralCopy(list))); InstallMethod(DigraphConsNC, "for IsImmutableDigraph and a record", [IsImmutableDigraph, IsRecord], -function(filt, record) +function(_, record) local D; D := MakeImmutable(DigraphConsNC(IsMutableDigraph, record)); SetDigraphSource(D, StructuralCopy(record.DigraphSource)); @@ -145,7 +145,7 @@ end); InstallMethod(DigraphConsNC, "for IsImmutableDigraph and a dense list", [IsImmutableDigraph, IsDenseList], -{filt, list} -> MakeImmutable(DigraphConsNC(IsMutableDigraph, list))); +{_, list} -> MakeImmutable(DigraphConsNC(IsMutableDigraph, list))); InstallMethod(DigraphNC, "for a function and a dense list", [IsFunction, IsDenseList], DigraphConsNC); @@ -235,7 +235,7 @@ end); InstallMethod(DigraphCons, "for IsMutableDigraph and a record", [IsMutableDigraph, IsRecord], -function(filt, record) +function(_, record) local D, cmp, labels, i; if IsGraph(record) then @@ -287,9 +287,9 @@ function(filt, record) record.DigraphNrVertices := Length(record.DigraphVertices); fi; - if not ForAll(record.DigraphSource, x -> cmp(x)) then + if not ForAll(record.DigraphSource, cmp) then ErrorNoReturn("the record component 'DigraphSource' is invalid,"); - elif not ForAll(record.DigraphRange, x -> cmp(x)) then + elif not ForAll(record.DigraphRange, cmp) then ErrorNoReturn("the record component 'DigraphRange' is invalid,"); fi; @@ -321,7 +321,7 @@ end); InstallMethod(DigraphCons, "for IsMutableDigraph and a dense list of out-neighbours", [IsMutableDigraph, IsDenseList], -function(filt, list) +function(_, list) local sublist, v; for sublist in list do if not IsHomogeneousList(sublist) then @@ -341,7 +341,7 @@ end); InstallMethod(DigraphCons, "for IsMutableDigraph, a list, and function", [IsMutableDigraph, IsList, IsFunction], -function(filt, list, func) +function(_, list, func) local N, out, x, i, j; N := Size(list); # number of vertices out := List([1 .. N], x -> []); @@ -359,7 +359,7 @@ end); InstallMethod(DigraphCons, "for IsMutableDigraph, a number of vertices, source, and range", [IsMutableDigraph, IsInt, IsList, IsList], -function(filt, N, src, ran) +function(_, N, src, ran) return DigraphCons(IsMutableDigraph, rec(DigraphNrVertices := N, DigraphSource := src, DigraphRange := ran)); @@ -368,7 +368,7 @@ end); InstallMethod(DigraphCons, "for IsMutableDigraph, a list of vertices, source, and range", [IsMutableDigraph, IsList, IsList, IsList], -function(filt, domain, src, ran) +function(_, domain, src, ran) local D; D := DigraphCons(IsMutableDigraph, rec(DigraphVertices := domain, DigraphSource := src, @@ -379,7 +379,7 @@ end); InstallMethod(DigraphCons, "for IsImmutableDigraph and a record", [IsImmutableDigraph, IsRecord], -function(filt, record) +function(_, record) local D; D := MakeImmutable(DigraphCons(IsMutableDigraph, record)); if IsGraph(record) then @@ -400,11 +400,11 @@ end); InstallMethod(DigraphCons, "for IsImmutableDigraph and a dense list of out-neighbours", [IsImmutableDigraph, IsDenseList], -{filt, list} -> MakeImmutable(DigraphCons(IsMutableDigraph, list))); +{_, list} -> MakeImmutable(DigraphCons(IsMutableDigraph, list))); InstallMethod(DigraphCons, "for IsImmutableDigraph, a list, and function", [IsImmutableDigraph, IsList, IsFunction], -function(filt, list, func) +function(_, list, func) local D; D := MakeImmutable(DigraphCons(IsMutableDigraph, list, func)); SetDigraphAdjacencyFunction(D, {u, v} -> func(list[u], list[v])); @@ -416,16 +416,14 @@ end); InstallMethod(DigraphCons, "for IsImmutableDigraph, a number of vertices, source, and range", [IsImmutableDigraph, IsInt, IsList, IsList], -function(filt, N, src, ran) - return MakeImmutable(DigraphCons(IsMutableDigraph, N, src, ran)); -end); +{_, N, src, ran} +-> MakeImmutable(DigraphCons(IsMutableDigraph, N, src, ran))); InstallMethod(DigraphCons, "for IsImmutableDigraph, a list of vertices, source, and range", [IsImmutableDigraph, IsList, IsList, IsList], -function(filt, domain, src, ran) - return MakeImmutable(DigraphCons(IsMutableDigraph, domain, src, ran)); -end); +{_, domain, src, ran} -> +MakeImmutable(DigraphCons(IsMutableDigraph, domain, src, ran))); InstallMethod(Digraph, "for a filter and a record", [IsFunction, IsRecord], DigraphCons); @@ -744,7 +742,7 @@ function(D) fi; od; - lengths := List(strings, x -> Length(x)); + lengths := List(strings, Length); return strings[Position(lengths, Minimum(lengths))]; end); @@ -763,7 +761,7 @@ InstallMethod(\<, "for two digraphs", [IsDigraph, IsDigraph], DIGRAPH_LT); InstallMethod(DigraphByAdjacencyMatrixConsNC, "for IsMutableDigraph and a homogeneous list", [IsMutableDigraph, IsHomogeneousList], -function(filt, mat) +function(_, mat) local add_edge, n, list, i, j; if IsInt(mat[1][1]) then @@ -795,7 +793,7 @@ end); InstallMethod(DigraphByAdjacencyMatrixCons, "for IsMutableDigraph and a homogeneous list", [IsMutableDigraph, IsHomogeneousList], -function(filt, mat) +function(_, mat) local n, i, j; n := Length(mat); if not IsRectangularTable(mat) or Length(mat[1]) <> n then @@ -820,12 +818,12 @@ InstallMethod(DigraphByAdjacencyMatrixCons, InstallMethod(DigraphByAdjacencyMatrixConsNC, "for IsMutableDigraph and an empty list", [IsMutableDigraph, IsList and IsEmpty], -{filt, dummy} -> EmptyDigraph(IsMutableDigraph, 0)); +{_, dummy} -> EmptyDigraph(IsMutableDigraph, 0)); InstallMethod(DigraphByAdjacencyMatrixCons, "for IsImmutableDigraph and a homogeneous list", [IsImmutableDigraph, IsHomogeneousList], -function(filt, mat) +function(_, mat) local D; D := MakeImmutable(DigraphByAdjacencyMatrixCons(IsMutableDigraph, mat)); if IsEmpty(mat) or IsInt(mat[1][1]) then @@ -848,7 +846,7 @@ mat -> DigraphByAdjacencyMatrixCons(IsImmutableDigraph, mat)); InstallMethod(DigraphByEdgesCons, "for IsMutableDigraph, a list, and an integer", [IsMutableDigraph, IsList, IsInt], -function(filt, edges, n) +function(_, edges, n) local list, edge; if IsEmpty(edges) then return NullDigraph(IsMutableDigraph, n); @@ -870,7 +868,7 @@ end); InstallMethod(DigraphByEdgesCons, "for IsMutableDigraph and a list", [IsMutableDigraph, IsList], -function(filt, edges) +function(_, edges) local n; if IsEmpty(edges) then n := 0; @@ -882,7 +880,7 @@ end); InstallMethod(DigraphByEdgesCons, "for an ImmutableDigraph and a list", [IsImmutableDigraph, IsList], -function(filt, edges) +function(_, edges) local D; D := MakeImmutable(DigraphByEdges(IsMutableDigraph, edges)); SetDigraphEdges(D, edges); @@ -893,7 +891,7 @@ end); InstallMethod(DigraphByEdgesCons, "for IsImmutableDigraph, a list, and an integer", [IsImmutableDigraph, IsList, IsInt], -function(filt, edges, n) +function(_, edges, n) local D; D := MakeImmutable(DigraphByEdges(IsMutableDigraph, edges, n)); SetDigraphEdges(D, edges); @@ -916,7 +914,7 @@ InstallMethod(DigraphByEdges, "for a function and a list", InstallMethod(DigraphByInNeighboursCons, "for IsMutableDigraph, and a list", [IsMutableDigraph, IsList], -function(filt, list) +function(_, list) local n, x; n := Length(list); # number of vertices for x in list do @@ -930,7 +928,7 @@ end); InstallMethod(DigraphByInNeighboursCons, "for IsImmutableDigraph and a list", [IsImmutableDigraph, IsList], -function(filt, list) +function(_, list) local D; D := MakeImmutable(DigraphByInNeighboursCons(IsMutableDigraph, list)); SetInNeighbours(D, list); @@ -939,11 +937,11 @@ end); InstallMethod(DigraphByInNeighboursConsNC, "for IsMutableDigraph and a list", [IsMutableDigraph, IsList], -{filt, list} -> DigraphNC(IsMutableDigraph, DIGRAPH_IN_OUT_NBS(list))); +{_, list} -> DigraphNC(IsMutableDigraph, DIGRAPH_IN_OUT_NBS(list))); InstallMethod(DigraphByInNeighboursConsNC, "for IsImmutableDigraph and a list", [IsImmutableDigraph, IsList], -function(filt, list) +function(_, list) local D; D := MakeImmutable(DigraphByInNeighboursConsNC(IsMutableDigraph, list)); SetInNeighbours(D, list); @@ -963,7 +961,7 @@ DigraphByInNeighboursCons); InstallMethod(AsDigraphCons, "for IsMutableDigraph and a binary relation", [IsMutableDigraph, IsBinaryRelation], -function(filt, rel) +function(_, rel) local dom, list, i; dom := GeneratorsOfDomain(UnderlyingDomainOfBinaryRelation(rel)); if not IsRange(dom) or dom[1] <> 1 then @@ -979,7 +977,7 @@ end); InstallMethod(AsDigraphCons, "for IsImmutableDigraph and a binary relation", [IsImmutableDigraph, IsBinaryRelation], -function(filt, rel) +function(_, rel) local D; D := MakeImmutable(AsDigraph(IsMutableDigraph, rel)); SetIsMultiDigraph(D, false); @@ -1007,7 +1005,7 @@ InstallMethod(AsDigraph, "for a function and a binary relation", InstallMethod(AsDigraphCons, "for IsMutableDigraph, a transformation, and an integer", [IsMutableDigraph, IsTransformation, IsInt], -function(filt, f, n) +function(_, f, n) local list, x, i; if n < 0 then ErrorNoReturn("the 2nd argument should be a non-negative integer,"); @@ -1027,7 +1025,7 @@ end); InstallMethod(AsDigraphCons, "for IsImmutableDigraph, a transformation, and an integer", [IsImmutableDigraph, IsTransformation, IsInt], -function(filt, f, n) +function(_, f, n) local D; D := AsDigraph(IsMutableDigraph, f, n); if D <> fail then @@ -1071,7 +1069,7 @@ p -> AsDigraph(AsTransformation(p))); InstallMethod(AsDigraphCons, "for IsMutableDigraph, a partial perm, and an integer", [IsMutableDigraph, IsPartialPerm, IsInt], -function(filt, f, n) +function(_, f, n) local list, x, i; if n < 0 then ErrorNoReturn("the 2nd argument should be a non-negative integer,"); @@ -1094,7 +1092,7 @@ end); InstallMethod(AsDigraphCons, "for IsImmutableDigraph, a partial perm, and an integer", [IsImmutableDigraph, IsPartialPerm, IsInt], -function(filt, f, n) +function(_, f, n) local D; D := AsDigraph(IsMutableDigraph, f, n); if D <> fail then @@ -1220,7 +1218,7 @@ function(filt, digraph, gps, homs) ErrorNoReturn("the second argument must be a join semilattice ", "digraph or a meet semilattice digraph,"); fi; - elif not ForAll(gps, x -> IsGroup(x)) then + elif not ForAll(gps, IsGroup) then ErrorNoReturn("the third argument must be a list of groups,"); elif not Length(gps) = DigraphNrVertices(digraph) then ErrorNoReturn("the third argument must have length equal to the number ", @@ -1344,70 +1342,63 @@ end); InstallMethod(RandomDigraphCons, "for IsMutableDigraph and an integer", [IsMutableDigraph, IsInt], -function(filt, n) - return RandomDigraphCons(IsMutableDigraph, n, Float(Random([0 .. n])) / n); -end); +{_, n} +-> RandomDigraphCons(IsMutableDigraph, n, Float(Random([0 .. n])) / n)); InstallMethod(RandomDigraphCons, "for IsMutableDigraph and an integer", [IsImmutableDigraph, IsInt], -function(filt, n) - return RandomDigraphCons(IsImmutableDigraph, n, Float(Random([0 .. n])) / n); -end); +{_, n} +-> RandomDigraphCons(IsImmutableDigraph, n, Float(Random([0 .. n])) / n)); InstallMethod(RandomDigraphCons, "for IsHamiltonianDigraph and an integer", [IsHamiltonianDigraph, IsInt], -function(filt, n) - return RandomDigraphCons(IsHamiltonianDigraph, n, Float(Random([0 .. n])) / n); -end); +{_, n} +-> RandomDigraphCons(IsHamiltonianDigraph, n, Float(Random([0 .. n])) / n)); InstallMethod(RandomDigraphCons, "for IsEulerianDigraph and an integer", [IsEulerianDigraph, IsInt], -function(filt, n) - return RandomDigraphCons(IsEulerianDigraph, n, Float(Random([0 .. n])) / n); -end); +{_, n} +-> RandomDigraphCons(IsEulerianDigraph, n, Float(Random([0 .. n])) / n)); InstallMethod(RandomDigraphCons, "for IsConnectedDigraph and an integer", [IsConnectedDigraph, IsInt], -function(filt, n) - return RandomDigraphCons(IsConnectedDigraph, n, Float(Random([0 .. n])) / n); -end); +{_, n} +-> RandomDigraphCons(IsConnectedDigraph, n, Float(Random([0 .. n])) / n)); InstallMethod(RandomDigraphCons, "for IsAcyclicDigraph and an integer", [IsAcyclicDigraph, IsInt], -function(filt, n) - return RandomDigraphCons(IsAcyclicDigraph, n, Float(Random([0 .. n])) / n); -end); +{_, n} +-> RandomDigraphCons(IsAcyclicDigraph, n, Float(Random([0 .. n])) / n)); InstallMethod(RandomDigraphCons, "for IsSymmetricDigraph and an integer", [IsSymmetricDigraph, IsInt], -function(filt, n) - return RandomDigraphCons(IsSymmetricDigraph, n, Float(Random([0 .. n])) / n); -end); +{_, n} +-> RandomDigraphCons(IsSymmetricDigraph, n, Float(Random([0 .. n])) / n)); InstallMethod(RandomDigraphCons, "for IsMutableDigraph, an integer, and a rational", [IsMutableDigraph, IsInt, IsRat], -{filt, n, p} -> RandomDigraphCons(IsMutableDigraph, n, Float(p))); +{_, n, p} -> RandomDigraphCons(IsMutableDigraph, n, Float(p))); InstallMethod(RandomDigraphCons, "for IsImmutableDigraph, an integer, and a rational", [IsImmutableDigraph, IsInt, IsRat], -{filt, n, p} -> RandomDigraphCons(IsImmutableDigraph, n, Float(p))); +{_, n, p} -> RandomDigraphCons(IsImmutableDigraph, n, Float(p))); InstallMethod(RandomDigraphCons, "for IsHamiltonianDigraph, an integer, and a rational", [IsHamiltonianDigraph, IsInt, IsRat], -{filt, n, p} -> RandomDigraphCons(IsHamiltonianDigraph, n, Float(p))); +{_, n, p} -> RandomDigraphCons(IsHamiltonianDigraph, n, Float(p))); InstallMethod(RandomDigraphCons, "for IsEulerianDigraph, an integer, and a rational", [IsEulerianDigraph, IsInt, IsRat], -{filt, n, p} -> RandomDigraphCons(IsEulerianDigraph, n, Float(p))); +{_, n, p} -> RandomDigraphCons(IsEulerianDigraph, n, Float(p))); InstallMethod(RandomDigraphCons, "for IsConnectedDigraph, an integer, and a rational", [IsConnectedDigraph, IsInt, IsRat], -{filt, n, p} -> RandomDigraphCons(IsConnectedDigraph, n, Float(p))); +{_, n, p} -> RandomDigraphCons(IsConnectedDigraph, n, Float(p))); InstallMethod(RandomDigraphCons, "for IsStronglyConnectedDigraph, an integer, and a rational", @@ -1417,17 +1408,17 @@ InstallMethod(RandomDigraphCons, InstallMethod(RandomDigraphCons, "for IsAcyclicDigraph, an integer, and a rational", [IsAcyclicDigraph, IsInt, IsRat], -{filt, n, p} -> RandomDigraphCons(IsAcyclicDigraph, n, Float(p))); +{_, n, p} -> RandomDigraphCons(IsAcyclicDigraph, n, Float(p))); InstallMethod(RandomDigraphCons, "for IsSymmetricDigraph, an integer, and a rational", [IsSymmetricDigraph, IsInt, IsRat], -{filt, n, p} -> RandomDigraphCons(IsSymmetricDigraph, n, Float(p))); +{_, n, p} -> RandomDigraphCons(IsSymmetricDigraph, n, Float(p))); InstallMethod(RandomDigraphCons, "for IsMutableDigraph, a positive integer, and a float", [IsMutableDigraph, IsPosInt, IsFloat], -function(filt, n, p) +function(_, n, p) if p < 0.0 or 1.0 < p then ErrorNoReturn("the 2nd argument

must be between 0 and 1,"); fi; @@ -1459,7 +1450,7 @@ end); InstallMethod(RandomDigraphCons, "for IsHamiltonianDigraph, a positive integer, and a float", [IsHamiltonianDigraph, IsPosInt, IsFloat], -function(filt, n, p) +function(_, n, p) local adjacencyList, vertices, i, startVertex, hamiltonianCycle, x, j; adjacencyList := EmptyPlist(n); @@ -1506,7 +1497,7 @@ end); InstallMethod(RandomDigraphCons, "for IsEulerianDigraph, a positive integer, and a float", [IsEulerianDigraph, IsPosInt, IsFloat], -function(filt, n, p) +function(_, n, p) local adjacencyList, vertices, probability, startVertex, circuitVertex, i, continueCircuit, verticesToConsider, connectedVertices, verticesToCheck; @@ -1605,7 +1596,7 @@ end); InstallMethod(RandomDigraphCons, "for IsConnectedDigraph, a positive integer, and a float", [IsConnectedDigraph, IsPosInt, IsFloat], -function(filt, n, p) +function(_, n, p) local adjacencyList, vertices, startVertex, tree, x, i, j; adjacencyList := EmptyPlist(n); @@ -1678,7 +1669,7 @@ end); InstallMethod(RandomDigraphCons, "for IsAcyclicDigraph, a positive integer, and a float", [IsAcyclicDigraph, IsPosInt, IsFloat], -function(filt, n, p) +function(_, n, p) local adjacencyList, vertices, probability, i, j; adjacencyList := EmptyPlist(n); @@ -1711,7 +1702,7 @@ end); InstallMethod(RandomDigraphCons, "for IsSymmetricDigraph, a positive integer, and a float", [IsSymmetricDigraph, IsPosInt, IsFloat], -function(filt, n, p) +function(_, n, p) local adjacencyList, vertices, probability, i, j; adjacencyList := EmptyPlist(n); @@ -1744,7 +1735,7 @@ end); InstallMethod(RandomDigraphCons, "for IsImmutableDigraph, a positive integer, and a float", [IsImmutableDigraph, IsPosInt, IsFloat], -function(filt, n, p) +function(_, n, p) local D; D := MakeImmutable(RandomDigraphCons(IsMutableDigraph, n, p)); SetIsMultiDigraph(D, false); @@ -1777,7 +1768,7 @@ InstallMethod(RandomMultiDigraph, "for two pos ints", [IsPosInt, IsPosInt], InstallMethod(RandomTournamentCons, "for IsMutableDigraph and an integer", [IsMutableDigraph, IsInt], -function(filt, n) +function(_, n) local choice, nodes, list, v, w; if n < 0 then ErrorNoReturn("the argument must be a non-negative integer,"); @@ -1801,7 +1792,7 @@ end); InstallMethod(RandomTournamentCons, "for IsImmutableDigraph and an integer", [IsImmutableDigraph, IsInt], -function(filt, n) +function(_, n) local D; D := MakeImmutable(RandomTournamentCons(IsMutableDigraph, n)); SetIsTournament(D, true); @@ -1821,7 +1812,7 @@ InstallMethod(RandomTournament, "for a func and an integer", InstallMethod(RandomLatticeCons, "for IsMutableDigraph and a pos int", [IsMutableDigraph, IsPosInt], -function(filt, n) +function(_, n) local fam, rand_blist; fam := [BlistList([1 .. n], [])]; @@ -1836,7 +1827,7 @@ end); InstallMethod(RandomLatticeCons, "for IsImmutableDigraph and a pos int", [IsImmutableDigraph, IsPosInt], -function(filt, n) +function(_, n) local D; D := MakeImmutable(RandomLatticeCons(IsMutableDigraph, n)); SetIsLatticeDigraph(D, true); diff --git a/gap/examples.gi b/gap/examples.gi index 9db299b0e..a5d0e4be4 100644 --- a/gap/examples.gi +++ b/gap/examples.gi @@ -13,7 +13,7 @@ InstallMethod(EmptyDigraphCons, "for IsMutableDigraph and an integer", [IsMutableDigraph, IsInt], -function(filt, n) +function(_, n) if n < 0 then ErrorNoReturn("the argument must be a non-negative integer,"); fi; @@ -22,7 +22,7 @@ end); InstallMethod(EmptyDigraphCons, "for IsImmutableDigraph and an integer", [IsImmutableDigraph, IsInt], -function(filt, n) +function(_, n) local D; if n < 0 then ErrorNoReturn("the argument must be a non-negative integer,"); @@ -43,7 +43,7 @@ InstallMethod(EmptyDigraph, "for a function and an integer", InstallMethod(CompleteBipartiteDigraphCons, "for IsMutableDigraph and two positive integers", [IsMutableDigraph, IsPosInt, IsPosInt], -function(filt, m, n) +function(_, m, n) local src, ran, count, k, i, j; src := EmptyPlist(2 * m * n); ran := EmptyPlist(2 * m * n); @@ -66,7 +66,7 @@ end); InstallMethod(CompleteBipartiteDigraphCons, "for IsImmutableDigraph and two positive integers", [IsImmutableDigraph, IsPosInt, IsPosInt], -function(filt, m, n) +function(_, m, n) local D, aut; D := MakeImmutable(CompleteBipartiteDigraph(IsMutableDigraph, m, n)); SetIsSymmetricDigraph(D, true); @@ -98,7 +98,7 @@ CompleteBipartiteDigraphCons); InstallMethod(CompleteMultipartiteDigraphCons, "for IsMutableDigraph and a list", [IsMutableDigraph, IsList], -function(filt, list) +function(_, list) local M, N, out, start, next, i, v; if not ForAll(list, IsPosInt) then ErrorNoReturn("the argument must be a list of positive ", @@ -127,7 +127,7 @@ end); InstallMethod(CompleteMultipartiteDigraphCons, "for IsImmutableDigraph and a list", [IsImmutableDigraph, IsList], -function(filt, list) +function(_, list) local D; D := MakeImmutable(CompleteMultipartiteDigraph(IsMutableDigraph, list)); SetIsEmptyDigraph(D, Length(list) <= 1); @@ -148,7 +148,7 @@ InstallMethod(CompleteMultipartiteDigraph, "for a function and a list", InstallMethod(ChainDigraphCons, "for IsMutableDigraph and a positive integer", [IsMutableDigraph, IsPosInt], -function(filt, n) +function(_, n) local list, i; list := EmptyPlist(n); for i in [1 .. n - 1] do @@ -161,7 +161,7 @@ end); InstallMethod(ChainDigraphCons, "for IsImmutableDigraph and a positive integer", [IsImmutableDigraph, IsPosInt], -function(filt, n) +function(_, n) local D; D := MakeImmutable(ChainDigraphCons(IsMutableDigraph, n)); SetIsChainDigraph(D, true); @@ -186,7 +186,7 @@ n -> ChainDigraphCons(IsImmutableDigraph, n)); InstallMethod(CompleteDigraphCons, "for IsMutableDigraph and an integer", [IsMutableDigraph, IsInt], -function(filt, n) +function(_, n) local verts, out, i; if n < 0 then ErrorNoReturn("the argument must be a non-negative integer,"); @@ -203,7 +203,7 @@ end); InstallMethod(CompleteDigraphCons, "for IsImmutableDigraph and an integer", [IsImmutableDigraph, IsInt], -function(filt, n) +function(_, n) local D; D := MakeImmutable(CompleteDigraphCons(IsMutableDigraph, n)); SetIsEmptyDigraph(D, n <= 1); @@ -227,7 +227,7 @@ n -> CompleteDigraphCons(IsImmutableDigraph, n)); InstallMethod(CycleDigraphCons, "for IsMutableDigraph and a positive integer", [IsMutableDigraph, IsPosInt], -function(filt, n) +function(_, n) local list, i; list := EmptyPlist(n); for i in [1 .. n - 1] do @@ -240,7 +240,7 @@ end); InstallMethod(CycleDigraphCons, "for IsImmutableDigraph and a positive integer", [IsImmutableDigraph, IsPosInt], -function(filt, n) +function(_, n) local D; D := MakeImmutable(CycleDigraphCons(IsMutableDigraph, n)); SetIsAcyclicDigraph(D, false); @@ -268,7 +268,7 @@ n -> CycleDigraphCons(IsImmutableDigraph, n)); InstallMethod(JohnsonDigraphCons, "for IsMutableDigraph and two integers", [IsMutableDigraph, IsInt, IsInt], -function(filt, n, k) +function(_, n, k) if n < 0 or k < 0 then ErrorNoReturn("the arguments and must be ", "non-negative integers,"); @@ -281,7 +281,7 @@ end); InstallMethod(JohnsonDigraphCons, "for IsImmutableDigraph, integer, integer", [IsImmutableDigraph, IsInt, IsInt], -function(filt, n, k) +function(_, n, k) local D; D := MakeImmutable(JohnsonDigraphCons(IsMutableDigraph, n, k)); SetIsMultiDigraph(D, false); @@ -297,7 +297,7 @@ InstallMethod(JohnsonDigraph, "for integer, integer", [IsInt, IsInt], {n, k} -> JohnsonDigraphCons(IsImmutableDigraph, n, k)); InstallMethod(PetersenGraphCons, "for IsMutableDigraph", [IsMutableDigraph], -function(filt) +function(_) local mat; mat := [[0, 1, 0, 0, 1, 1, 0, 0, 0, 0], [1, 0, 1, 0, 0, 0, 1, 0, 0, 0], @@ -315,7 +315,7 @@ end); InstallMethod(PetersenGraphCons, "for IsImmutableDigraph", [IsImmutableDigraph], -filt -> MakeImmutable(PetersenGraphCons(IsMutableDigraph))); +_ -> MakeImmutable(PetersenGraphCons(IsMutableDigraph))); InstallMethod(PetersenGraph, "for a function", [IsFunction], PetersenGraphCons); @@ -352,7 +352,7 @@ end); InstallMethod(GeneralisedPetersenGraphCons, "for IsImmutableDigraph, positive integer, int", [IsImmutableDigraph, IsPosInt, IsInt], -function(filt, n, k) +function(_, n, k) local D; D := MakeImmutable(GeneralisedPetersenGraphCons(IsMutableDigraph, n, k)); SetIsMultiDigraph(D, false); @@ -371,7 +371,7 @@ InstallMethod(GeneralisedPetersenGraph, "for a positive integer and integer", InstallMethod(LollipopGraphCons, "for IsMutableDigraph and two positive integers", [IsMutableDigraph, IsPosInt, IsPosInt], -function(filt, m, n) +function(_, m, n) local D; D := DigraphDisjointUnion(CompleteDigraph(IsMutableDigraph, m), DigraphSymmetricClosure(ChainDigraph(IsMutableDigraph, n))); @@ -382,7 +382,7 @@ end); InstallMethod(LollipopGraphCons, "for IsImmutableDigraph and two positive integers", [IsImmutableDigraph, IsPosInt, IsPosInt], -function(filt, m, n) +function(_, m, n) local D; D := MakeImmutable(LollipopGraphCons(IsMutableDigraph, m, n)); SetIsMultiDigraph(D, false); @@ -412,7 +412,7 @@ InstallMethod(LollipopGraph, "for a function and two pos int", InstallMethod(SquareGridGraphCons, "for IsMutableDigraph and two positive integers", [IsMutableDigraph, IsPosInt, IsPosInt], -function(filt, n, k) +function(_, n, k) local D1, D2; D1 := DigraphSymmetricClosure(ChainDigraph(IsMutableDigraph, n)); D2 := DigraphSymmetricClosure(ChainDigraph(IsMutableDigraph, k)); @@ -422,7 +422,7 @@ end); InstallMethod(SquareGridGraphCons, "for IsImmutableDigraph and two positive integers", [IsImmutableDigraph, IsPosInt, IsPosInt], -function(filt, n, k) +function(_, n, k) local D; D := MakeImmutable(SquareGridGraphCons(IsMutableDigraph, n, k)); SetIsMultiDigraph(D, false); @@ -447,7 +447,7 @@ InstallMethod(SquareGridGraph, "for two integers", [IsPosInt, IsPosInt], InstallMethod(TriangularGridGraphCons, "for IsMutableDigraph and two integers", [IsMutableDigraph, IsPosInt, IsPosInt], -function(filt, n, k) +function(_, n, k) local D, a, b, i, j; D := SquareGridGraph(IsMutableDigraph, n, k); for i in [1 .. (k - 1)] do @@ -464,7 +464,7 @@ end); InstallMethod(TriangularGridGraphCons, "for IsImmutableDigraph and two positive integers", [IsImmutableDigraph, IsPosInt, IsPosInt], -function(filt, n, k) +function(_, n, k) local D; D := MakeImmutable(TriangularGridGraphCons(IsMutableDigraph, n, k)); SetIsMultiDigraph(D, false); @@ -486,7 +486,7 @@ InstallMethod(TriangularGridGraph, "for two positive integers", InstallMethod(StarGraphCons, "for IsMutableDigraph and a positive integer", [IsMutableDigraph, IsPosInt], -function(filt, k) +function(_, k) if k = 1 then return EmptyDigraph(IsMutable, 1); fi; @@ -503,7 +503,7 @@ InstallMethod(StarGraph, "for integer", [IsPosInt], InstallMethod(StarGraphCons, "for IsImmutableDigraph and a positive integer", [IsImmutableDigraph, IsPosInt], -function(filt, k) +function(_, k) local D; D := MakeImmutable(StarGraph(IsMutableDigraph, k)); SetIsMultiDigraph(D, false); @@ -515,7 +515,7 @@ end); InstallMethod(KingsGraphCons, "for IsMutableDigraph and two positive integers", [IsMutableDigraph, IsPosInt, IsPosInt], -function(filt, n, k) +function(_, n, k) local D, a, b, i, j; D := TriangularGridGraph(IsMutableDigraph, n, k); for i in [1 .. (k - 1)] do @@ -532,7 +532,7 @@ end); InstallMethod(KingsGraphCons, "for IsImmutableDigraph and two positive integers", [IsImmutableDigraph, IsPosInt, IsPosInt], -function(filt, n, k) +function(_, n, k) local D; D := MakeImmutable(KingsGraphCons(IsMutableDigraph, n, k)); SetIsMultiDigraph(D, false); @@ -555,7 +555,7 @@ InstallMethod(KingsGraph, "two positive integers", InstallMethod(QueensGraphCons, "for IsMutableDigraph and two integers", [IsMutableDigraph, IsPosInt, IsPosInt], -function(filt, m, n) +function(_, m, n) local D1, D2, labels; D1 := RooksGraphCons(IsMutableDigraph, m, n); D2 := BishopsGraphCons(IsMutableDigraph, m, n); @@ -568,7 +568,7 @@ end); InstallMethod(QueensGraphCons, "for IsImmutableDigraph and two positive integers", [IsImmutableDigraph, IsPosInt, IsPosInt], -function(filt, m, n) +function(_, m, n) local D; D := MakeImmutable(QueensGraphCons(IsMutableDigraph, m, n)); SetIsMultiDigraph(D, false); @@ -589,7 +589,7 @@ InstallMethod(QueensGraph, "for two positive integers", InstallMethod(RooksGraphCons, "for IsMutableDigraph and two positive integers", [IsMutableDigraph, IsPosInt, IsPosInt], -function(filt, m, n) +function(_, m, n) local D1, D2; D1 := CompleteDigraph(IsMutableDigraph, m); D2 := CompleteDigraph(n); @@ -599,7 +599,7 @@ end); InstallMethod(RooksGraphCons, "for IsImmutableDigraph and two positive integers", [IsImmutableDigraph, IsPosInt, IsPosInt], -function(filt, m, n) +function(_, m, n) local D; D := MakeImmutable(RooksGraphCons(IsMutableDigraph, m, n)); SetIsMultiDigraph(D, false); @@ -622,7 +622,7 @@ InstallMethod(RooksGraph, "for two positive integers", InstallMethod(BishopsGraphCons, "for IsMutableDigraph, a string and two positive integers", [IsMutableDigraph, IsString, IsPosInt, IsPosInt], -function(filt, color, m, n) +function(_, color, m, n) local both, dark, nr, D1, D2, upL, inc, step, labels, v, not_final_row, i, j, is_dark_square, range; @@ -705,7 +705,7 @@ end); InstallMethod(BishopsGraphCons, "for IsImmutableDigraph, a string and two positive integers", [IsImmutableDigraph, IsString, IsPosInt, IsPosInt], -function(filt, color, m, n) +function(_, color, m, n) local D; D := MakeImmutable(BishopsGraphCons(IsMutableDigraph, color, m, n)); SetIsMultiDigraph(D, false); @@ -726,12 +726,12 @@ InstallMethod(BishopsGraph, "for a string and two positive integers", InstallMethod(BishopsGraphCons, "for IsMutableDigraph and two positive integers", [IsMutableDigraph, IsPosInt, IsPosInt], -{filt, m, n} -> BishopsGraphCons(IsMutableDigraph, "both", m, n)); +{_, m, n} -> BishopsGraphCons(IsMutableDigraph, "both", m, n)); InstallMethod(BishopsGraphCons, "for IsImmutableDigraph and two positive integers", [IsImmutableDigraph, IsPosInt, IsPosInt], -function(filt, m, n) +function(_, m, n) local D; D := MakeImmutable(BishopsGraphCons(IsMutableDigraph, "both", m, n)); SetIsMultiDigraph(D, false); @@ -752,7 +752,7 @@ InstallMethod(BishopsGraph, "for two positive integers", InstallMethod(KnightsGraphCons, "for IsMutableDigraph and two positive integers", [IsMutableDigraph, IsPosInt, IsPosInt], -function(filt, m, n) +function(_, m, n) local D, moves, labels, v, r, s, range, j, i, move; D := EmptyDigraph(IsMutableDigraph, m * n); @@ -781,7 +781,7 @@ end); InstallMethod(KnightsGraphCons, "for IsImmutableDigraph and two positive integers", [IsImmutableDigraph, IsPosInt, IsPosInt], -function(filt, m, n) +function(_, m, n) local D; D := MakeImmutable(KnightsGraphCons(IsMutableDigraph, m, n)); SetIsMultiDigraph(D, false); @@ -800,7 +800,7 @@ InstallMethod(KnightsGraph, "for two positive integers", [IsPosInt, IsPosInt], InstallMethod(HaarGraphCons, "for IsMutableDigraph and a positive integer", [IsMutableDigraph, IsPosInt], -function(filt, n) +function(_, n) local m, binaryList, D, i, j; m := Log(n, 2) + 1; binaryList := DIGRAPHS_BlistNumber(n + 1, m); @@ -820,7 +820,7 @@ end); InstallMethod(HaarGraphCons, "for IsImmutableDigraph and a positive integer", [IsImmutableDigraph, IsPosInt], -function(filt, n) +function(_, n) local D; D := MakeImmutable(HaarGraphCons(IsMutableDigraph, n)); SetIsMultiDigraph(D, false); @@ -841,7 +841,7 @@ InstallMethod(HaarGraph, "for a positive integer", [IsPosInt], InstallMethod(BananaTreeCons, "for IsMutableDigraph and two positive integers", [IsMutableDigraph, IsPosInt, IsPosInt], -function(filt, m, n) +function(_, m, n) local D, j, list; if n = 1 then ErrorNoReturn("The second argument must be an integer", @@ -859,7 +859,7 @@ end); InstallMethod(BananaTreeCons, "for IsImmutableDigraph and two positive integers", [IsImmutableDigraph, IsPosInt, IsPosInt], -function(filt, m, n) +function(_, m, n) local D; D := MakeImmutable(BananaTreeCons(IsMutableDigraph, m, n)); SetIsMultiDigraph(D, false); @@ -879,7 +879,7 @@ InstallMethod(BananaTree, "for a function and two positive integers", InstallMethod(TadpoleGraphCons, "for IsMutableDigraph and two positive integers", [IsMutableDigraph, IsPosInt, IsPosInt], -function(filt, m, n) +function(_, m, n) local tail, graph; if m < 3 then ErrorNoReturn("the first argument must be an integer greater than 2"); @@ -901,7 +901,7 @@ InstallMethod(TadpoleGraph, "for two positive integers", [IsPosInt, IsPosInt], InstallMethod(TadpoleGraphCons, "for IsImmutableDigraph and two positive integers", [IsImmutableDigraph, IsPosInt, IsPosInt], -function(filt, m, n) +function(_, m, n) local D; D := MakeImmutable(TadpoleGraph(IsMutableDigraph, m, n)); SetIsMultiDigraph(D, false); @@ -923,7 +923,7 @@ m -> BookGraphCons(IsImmutableDigraph, m)); InstallMethod(BookGraphCons, "for IsImmutableDigraph and a positive integer", [IsImmutableDigraph, IsPosInt], -function(filt, m) +function(_, m) local D; D := MakeImmutable(BookGraph(IsMutableDigraph, m)); SetIsMultiDigraph(D, false); @@ -935,7 +935,7 @@ end); InstallMethod(StackedBookGraphCons, "for IsMutableDigraph and two positive integers", [IsMutableDigraph, IsPosInt, IsPosInt], -function(filt, m, n) +function(_, m, n) local book; book := DigraphSymmetricClosure(ChainDigraph(IsMutable, n)); return DigraphCartesianProduct(book, StarGraph(IsMutable, m + 1)); @@ -952,7 +952,7 @@ InstallMethod(StackedBookGraph, "for two positive integers", InstallMethod(StackedBookGraphCons, "for IsImmutableDigraph and two positive integers", [IsImmutableDigraph, IsPosInt, IsPosInt], -function(filt, m, n) +function(_, m, n) local D; D := MakeImmutable(StackedBookGraph(IsMutableDigraph, m, n)); SetIsMultiDigraph(D, false); @@ -964,7 +964,7 @@ end); InstallMethod(BinaryTreeCons, "for IsMutableDigraph and positive integer", [IsMutableDigraph, IsPosInt], -function(filt, depth) +function(_, depth) local D, x, i, j; D := [[]]; for i in [1 .. depth - 1] do @@ -979,7 +979,7 @@ end); InstallMethod(BinaryTreeCons, "for IsImmutableDigraph and positive integer", [IsImmutableDigraph, IsPosInt], -function(filt, depth) +function(_, depth) local D; D := BinaryTreeCons(IsMutableDigraph, depth); MakeImmutable(D); @@ -994,7 +994,7 @@ InstallMethod(BinaryTree, "for a function and a positive integer", InstallMethod(AndrasfaiGraphCons, "for IsMutableDigraph and an integer", [IsMutableDigraph, IsPosInt], -function(filt, n) +function(_, n) local js; js := List([0 .. (n - 1)], x -> (3 * x) + 1); return CirculantGraph(IsMutableDigraph, (3 * n) - 1, js); @@ -1003,7 +1003,7 @@ end); InstallMethod(AndrasfaiGraphCons, "for IsImmutableDigraph, integer", [IsImmutableDigraph, IsPosInt], -function(filt, n) +function(_, n) local D; D := MakeImmutable(AndrasfaiGraphCons(IsMutableDigraph, n)); SetIsMultiDigraph(D, false); @@ -1024,7 +1024,7 @@ InstallMethod(AndrasfaiGraph, "for a function and an integer", InstallMethod(BinomialTreeGraphCons, "for IsMutableDigraph and an integer", [IsMutableDigraph, IsPosInt], -function(filt, n) +function(_, n) local bits, is2n, verts, D, rep, pos, parent, parVert, i; bits := Log(n, 2); is2n := IsEvenInt(n) and IsPrimePowerInt(n); @@ -1050,7 +1050,7 @@ end); InstallMethod(BinomialTreeGraphCons, "for IsImmutableDigraph, integer", [IsImmutableDigraph, IsPosInt], -function(filt, n) +function(_, n) local D; D := MakeImmutable(BinomialTreeGraphCons(IsMutableDigraph, n)); SetIsMultiDigraph(D, false); @@ -1068,7 +1068,7 @@ InstallMethod(BinomialTreeGraph, "for a function and an integer", InstallMethod(BondyGraphCons, "for IsMutableDigraph and an integer", [IsMutableDigraph, IsInt], -function(filt, n) +function(_, n) if n < 0 then ErrorNoReturn("the argument must be a non-negative integer,"); fi; @@ -1078,7 +1078,7 @@ end); InstallMethod(BondyGraphCons, "for IsImmutableDigraph, integer", [IsImmutableDigraph, IsInt], -function(filt, n) +function(_, n) local D; D := MakeImmutable(BondyGraphCons(IsMutableDigraph, n)); SetIsMultiDigraph(D, false); @@ -1095,7 +1095,7 @@ InstallMethod(BondyGraph, "for a function and an integer", InstallMethod(CirculantGraphCons, "for IsMutableDigraph, an integer and a list", [IsMutableDigraph, IsPosInt, IsList], -function(filt, n, par) +function(_, n, par) local D, i, j; if (n < 2) or (not ForAll(par, x -> IsInt(x) and x in [1 .. n])) then ErrorNoReturn("arguments must be an integer greater ", @@ -1123,7 +1123,7 @@ end); InstallMethod(CirculantGraphCons, "for IsImmutableDigraph, integer, list of integers", [IsImmutableDigraph, IsPosInt, IsList], -function(filt, n, par) +function(_, n, par) local D; D := MakeImmutable(CirculantGraphCons(IsMutableDigraph, n, par)); SetIsMultiDigraph(D, false); @@ -1154,7 +1154,7 @@ end); InstallMethod(CycleGraphCons, "for IsImmutableDigraph, integer", [IsImmutableDigraph, IsPosInt], -function(filt, n) +function(_, n) local D; D := MakeImmutable(CycleGraphCons(IsMutableDigraph, n)); SetIsMultiDigraph(D, false); @@ -1170,7 +1170,7 @@ InstallMethod(CycleGraph, "for a function and an integer", InstallMethod(GearGraphCons, "for IsMutableDigraph and an integer", [IsMutableDigraph, IsPosInt], -function(filt, n) +function(_, n) local D, i, central; if n < 3 then ErrorNoReturn("the argument must be an integer greater than 2,"); @@ -1188,7 +1188,7 @@ end); InstallMethod(GearGraphCons, "for IsImmutableDigraph, integer", [IsImmutableDigraph, IsPosInt], -function(filt, n) +function(_, n) local D; D := MakeImmutable(GearGraphCons(IsMutableDigraph, n)); SetIsMultiDigraph(D, false); @@ -1204,7 +1204,7 @@ InstallMethod(GearGraph, "for a function and an integer", InstallMethod(HalvedCubeGraphCons, "for IsMutableDigraph and an integer", [IsMutableDigraph, IsPosInt], -function(filt, n) +function(_, n) local D, tuples, vertices, i, j; tuples := Tuples([0, 1], n); vertices := List([1 .. (2 ^ (n - 1))], x -> []); @@ -1231,7 +1231,7 @@ end); InstallMethod(HalvedCubeGraphCons, "for IsImmutableDigraph, integer", [IsImmutableDigraph, IsPosInt], -function(filt, n) +function(_, n) local D; D := MakeImmutable(HalvedCubeGraphCons(IsMutableDigraph, n)); SetIsMultiDigraph(D, false); @@ -1250,7 +1250,7 @@ InstallMethod(HalvedCubeGraph, "for a function and an integer", InstallMethod(HanoiGraphCons, "for IsMutableDigraph and an integer", [IsMutableDigraph, IsPosInt], -function(filt, n) +function(_, n) local D, nrVert, prevNrVert, exp, i; D := Digraph(IsMutableDigraph, []); nrVert := 3 ^ n; @@ -1274,7 +1274,7 @@ end); InstallMethod(HanoiGraphCons, "for IsImmutableDigraph, integer", [IsImmutableDigraph, IsPosInt], -function(filt, n) +function(_, n) local D; D := MakeImmutable(HanoiGraphCons(IsMutableDigraph, n)); SetIsMultiDigraph(D, false); @@ -1292,7 +1292,7 @@ InstallMethod(HanoiGraph, "for a function and an integer", InstallMethod(HelmGraphCons, "for IsMutableDigraph and an integer", [IsMutableDigraph, IsPosInt], -function(filt, n) +function(_, n) local D; if n < 3 then ErrorNoReturn("the argument must be an integer greater than 2,"); @@ -1307,7 +1307,7 @@ end); InstallMethod(HelmGraphCons, "for IsImmutableDigraph, integer", [IsImmutableDigraph, IsPosInt], -function(filt, n) +function(_, n) local D; D := MakeImmutable(HelmGraphCons(IsMutableDigraph, n)); SetIsMultiDigraph(D, false); @@ -1324,7 +1324,7 @@ InstallMethod(HelmGraph, "for a function and an integer", InstallMethod(HypercubeGraphCons, "for IsImmutableDigraph, integer", [IsImmutableDigraph, IsInt], -function(filt, n) +function(_, n) local D; D := MakeImmutable(HypercubeGraphCons(IsMutableDigraph, n)); SetIsMultiDigraph(D, false); @@ -1338,7 +1338,7 @@ end); InstallMethod(HypercubeGraphCons, "for IsMutableDigraph and an integer", [IsMutableDigraph, IsInt], -function(filt, n) +function(_, n) local D, vertices, i, j; if n < 0 then ErrorNoReturn("the argument must be a non-negative integer,"); @@ -1365,7 +1365,7 @@ InstallMethod(HypercubeGraph, "for a function and an integer", InstallMethod(KellerGraphCons, "for IsMutableDigraph and an integer", [IsMutableDigraph, IsInt], -function(filt, n) +function(_, n) local D, vertices, i, j; if n < 0 then ErrorNoReturn("the argument must be a non-negative integer,"); @@ -1390,7 +1390,7 @@ end); InstallMethod(KellerGraphCons, "for IsImmutableDigraph, integer", [IsImmutableDigraph, IsInt], -function(filt, n) +function(_, n) local D; D := MakeImmutable(KellerGraphCons(IsMutableDigraph, n)); SetIsMultiDigraph(D, false); @@ -1412,7 +1412,7 @@ InstallMethod(KellerGraph, "for a function and an integer", InstallMethod(KneserGraphCons, "for IsMutableDigraph and two integers", [IsMutableDigraph, IsPosInt, IsPosInt], -function(filt, n, k) +function(_, n, k) local D, vertices, i, j; if n < k then ErrorNoReturn("argument must be greater than or equal to argument ,"); @@ -1433,7 +1433,7 @@ end); InstallMethod(KneserGraphCons, "for IsImmutableDigraph, integer, integer", [IsImmutableDigraph, IsPosInt, IsPosInt], -function(filt, n, k) +function(_, n, k) local D; D := MakeImmutable(KneserGraphCons(IsMutableDigraph, n, k)); SetIsMultiDigraph(D, false); @@ -1462,7 +1462,7 @@ InstallMethod(KneserGraph, "for a function and two integers", InstallMethod(LindgrenSousselierGraphCons, "for IsMutableDigraph and an integer", [IsMutableDigraph, IsPosInt], -function(filt, n) +function(_, n) local D, central, i, threei; central := 6 * n + 4; D := CycleGraph(IsMutableDigraph, central - 1); @@ -1484,7 +1484,7 @@ end); InstallMethod(LindgrenSousselierGraphCons, "for IsImmutableDigraph, integer", [IsImmutableDigraph, IsPosInt], -function(filt, n) +function(_, n) local D; D := MakeImmutable(LindgrenSousselierGraphCons(IsMutableDigraph, n)); SetIsMultiDigraph(D, false); @@ -1501,7 +1501,7 @@ InstallMethod(LindgrenSousselierGraph, "for a function and an integer", InstallMethod(MobiusLadderGraphCons, "for IsMutableDigraph and an integer", [IsMutableDigraph, IsPosInt], -function(filt, n) +function(_, n) local D, i; if n < 4 then ErrorNoReturn("the argument must be an integer equal to 4 or more,"); @@ -1517,7 +1517,7 @@ end); InstallMethod(MobiusLadderGraphCons, "for IsImmutableDigraph, integer", [IsImmutableDigraph, IsPosInt], -function(filt, n) +function(_, n) local D; D := MakeImmutable(MobiusLadderGraphCons(IsMutableDigraph, n)); SetIsMultiDigraph(D, false); @@ -1533,7 +1533,7 @@ InstallMethod(MobiusLadderGraph, "for a function and an integer", InstallMethod(MycielskiGraphCons, "for IsMutableDigraph and an integer", [IsMutableDigraph, IsPosInt], -function(filt, n) +function(_, n) local D, i; if n < 2 then ErrorNoReturn("the argument must be an integer greater than 1,"); @@ -1550,7 +1550,7 @@ end); InstallMethod(MycielskiGraphCons, "for IsImmutableDigraph, integer", [IsImmutableDigraph, IsPosInt], -function(filt, n) +function(_, n) local D; D := MakeImmutable(MycielskiGraphCons(IsMutableDigraph, n)); SetIsMultiDigraph(D, false); @@ -1569,7 +1569,7 @@ InstallMethod(MycielskiGraph, "for a function and an integer", InstallMethod(OddGraphCons, "for IsMutableDigraph and an integer", [IsMutableDigraph, IsInt], -function(filt, n) +function(_, n) if n < 1 then ErrorNoReturn("the argument must be an integer greater than 0,"); fi; @@ -1579,7 +1579,7 @@ end); InstallMethod(OddGraphCons, "for IsImmutableDigraph, integer", [IsImmutableDigraph, IsInt], -function(filt, n) +function(_, n) local D; D := MakeImmutable(OddGraphCons(IsMutableDigraph, n)); SetIsMultiDigraph(D, false); @@ -1600,14 +1600,12 @@ InstallMethod(OddGraph, "for a function and an integer", InstallMethod(PathGraphCons, "for IsMutableDigraph and an integer", [IsMutableDigraph, IsPosInt], -function(filt, n) - return DigraphSymmetricClosure(ChainDigraph(IsMutableDigraph, n)); -end); +{_, n} -> DigraphSymmetricClosure(ChainDigraph(IsMutableDigraph, n))); InstallMethod(PathGraphCons, "for IsImmutableDigraph, integer", [IsImmutableDigraph, IsPosInt], -function(filt, n) +function(_, n) local D; D := MakeImmutable(PathGraphCons(IsMutableDigraph, n)); SetIsMultiDigraph(D, false); @@ -1625,7 +1623,7 @@ InstallMethod(PathGraph, "for a function and an integer", InstallMethod(PermutationStarGraphCons, "for IsMutableDigraph and two integers", [IsMutableDigraph, IsPosInt, IsInt], -function(filt, n, k) +function(_, n, k) local D, permList, vertices, bList, pos, i, j; if k < 0 then ErrorNoReturn("the arguments and must be integers, ", @@ -1660,7 +1658,7 @@ end); InstallMethod(PermutationStarGraphCons, "for IsImmutableDigraph, integer, integer", [IsImmutableDigraph, IsPosInt, IsInt], -function(filt, n, k) +function(_, n, k) local D; D := MakeImmutable(PermutationStarGraphCons(IsMutableDigraph, n, k)); SetIsMultiDigraph(D, false); @@ -1683,7 +1681,7 @@ InstallMethod(PermutationStarGraph, "for a function and two integers", InstallMethod(PrismGraphCons, "for IsMutableDigraph and an integer", [IsMutableDigraph, IsPosInt], -function(filt, n) +function(_, n) if n < 3 then ErrorNoReturn("the argument must be an integer equal to 3 or more,"); else @@ -1694,7 +1692,7 @@ end); InstallMethod(PrismGraphCons, "for IsImmutableDigraph, integer", [IsImmutableDigraph, IsPosInt], -function(filt, n) +function(_, n) local D; D := MakeImmutable(PrismGraphCons(IsMutableDigraph, n)); SetIsMultiDigraph(D, false); @@ -1710,7 +1708,7 @@ InstallMethod(PrismGraph, "for a function and an integer", InstallMethod(StackedPrismGraphCons, "for IsMutableDigraph and two integers", [IsMutableDigraph, IsPosInt, IsPosInt], -function(filt, n, k) +function(_, n, k) if n < 3 then ErrorNoReturn("the arguments and must be integers, ", "with greater than 2 and greater than 0,"); @@ -1722,7 +1720,7 @@ end); InstallMethod(StackedPrismGraphCons, "for IsImmutableDigraph, integer, integer", [IsImmutableDigraph, IsPosInt, IsPosInt], -function(filt, n, k) +function(_, n, k) local D; D := MakeImmutable(StackedPrismGraphCons(IsMutableDigraph, n, k)); SetIsMultiDigraph(D, false); @@ -1738,7 +1736,7 @@ InstallMethod(StackedPrismGraph, "for a function and two integers", InstallMethod(WalshHadamardGraphCons, "for IsMutableDigraph and an integer", [IsMutableDigraph, IsPosInt], -function(filt, n) +function(_, n) local H_2, H_n, i, D, j, sideHn; H_2 := [[1, 1], [1, -1]]; @@ -1767,7 +1765,7 @@ end); InstallMethod(WalshHadamardGraphCons, "for IsImmutableDigraph, integer", [IsImmutableDigraph, IsPosInt], -function(filt, n) +function(_, n) local D; D := MakeImmutable(WalshHadamardGraphCons(IsMutableDigraph, n)); SetIsMultiDigraph(D, false); @@ -1784,7 +1782,7 @@ InstallMethod(WalshHadamardGraph, "for a function and an integer", InstallMethod(WebGraphCons, "for IsMutableDigraph and an integer", [IsMutableDigraph, IsPosInt], -function(filt, n) +function(_, n) local D, i; if n < 3 then ErrorNoReturn("the argument must be an integer greater than 2,"); @@ -1801,7 +1799,7 @@ end); InstallMethod(WebGraphCons, "for IsImmutableDigraph, integer", [IsImmutableDigraph, IsPosInt], -function(filt, n) +function(_, n) local D; D := MakeImmutable(WebGraphCons(IsMutableDigraph, n)); SetIsMultiDigraph(D, false); @@ -1817,7 +1815,7 @@ InstallMethod(WebGraph, "for a function and an integer", InstallMethod(WheelGraphCons, "for IsMutableDigraph and an integer", [IsMutableDigraph, IsPosInt], -function(filt, n) +function(_, n) local D; if n < 4 then ErrorNoReturn("the argument must be an integer greater than 3,"); @@ -1832,7 +1830,7 @@ end); InstallMethod(WheelGraphCons, "for IsImmutableDigraph, integer", [IsImmutableDigraph, IsPosInt], -function(filt, n) +function(_, n) local D; D := MakeImmutable(WheelGraphCons(IsMutableDigraph, n)); SetIsMultiDigraph(D, false); @@ -1855,7 +1853,7 @@ InstallMethod(WheelGraph, "for a function and an integer", InstallMethod(WindmillGraphCons, "for IsMutableDigraph and two integers", [IsMutableDigraph, IsPosInt, IsPosInt], -function(filt, n, m) +function(_, n, m) local D, i, K, nrVert; if m < 2 or n < 2 then ErrorNoReturn("the arguments and must be integers greater than 1,"); @@ -1877,7 +1875,7 @@ end); InstallMethod(WindmillGraphCons, "for IsImmutableDigraph, integer, integer", [IsImmutableDigraph, IsPosInt, IsPosInt], -function(filt, n, m) +function(_, n, m) local D; D := MakeImmutable(WindmillGraphCons(IsMutableDigraph, n, m)); SetIsMultiDigraph(D, false); diff --git a/gap/grahom.gi b/gap/grahom.gi index 806c802d4..1b7d854b6 100644 --- a/gap/grahom.gi +++ b/gap/grahom.gi @@ -475,9 +475,8 @@ end); InstallMethod(DigraphsRespectsColouring, [IsDigraph, IsDigraph, IsPerm, IsList, IsList], -function(src, ran, x, cols1, cols2) - return DigraphsRespectsColouring(src, ran, AsTransformation(x), cols1, cols2); -end); +{src, ran, x, cols1, cols2} +-> DigraphsRespectsColouring(src, ran, AsTransformation(x), cols1, cols2)); InstallMethod(IsDigraphHomomorphism, "for a digraph by out-neighbours, a digraph, and a perm", @@ -728,7 +727,7 @@ function(D1, D2) L := MaximalCommonSubdigraph(D1, D2); L[2] := List([1 .. DigraphNrVertices(L[1])], x -> x ^ L[2]); L[3] := List([1 .. DigraphNrVertices(L[1])], x -> x ^ L[3]); - out := List(OutNeighbours(D1), x -> ShallowCopy(x)); + out := List(OutNeighbours(D1), ShallowCopy); newvertices := Filtered(DigraphVertices(D2), x -> not x in L[3]); embedding1 := [1 .. DigraphNrVertices(D1)]; @@ -822,7 +821,7 @@ function(L1, L2) return next; end; - Recurse := function(last_defined, depth, print) + Recurse := function(depth, print) local next, value, try_next_value, prev, x; if depth = N1 + 1 then # When depth = N1 + 1, we have defined all images @@ -879,7 +878,7 @@ function(L1, L2) FlipBlist(in2[value]); fi; od; - if Recurse(next, depth + 1, print) then + if Recurse(depth + 1, print) then return true; fi; fi; @@ -892,7 +891,7 @@ function(L1, L2) return false; end; - if Recurse(1, 1, false) then + if Recurse(1, false) then Append(map, [N1 + 1 .. N2]); return p ^ -1 * Transformation(map); fi; @@ -926,9 +925,7 @@ function(L1, L2, map) if join2 = fail or meet2 = fail then ErrorNoReturn("the 2nd argument (a digraph) must be a lattice digraph"); - fi; - - if Maximum(ImageSetOfTransformation(map, N1)) > N2 then + elif Maximum(ImageSetOfTransformation(map, N1)) > N2 then return false; fi; # The above checks if the and entries of diff --git a/gap/grape.gi b/gap/grape.gi index e629e0e29..6b1f158fc 100644 --- a/gap/grape.gi +++ b/gap/grape.gi @@ -77,9 +77,7 @@ function(imm, G, obj, act, adj) D := DigraphNC(imm, out); if IsImmutableDigraph(D) then - adj_func := function(u, v) - return adj(obj[u], obj[v]); - end; + adj_func := {u, v} -> adj(obj[u], obj[v]); SetFilterObj(D, IsDigraphWithAdjacencyFunction); SetDigraphAdjacencyFunction(D, adj_func); SetDigraphGroup(D, Range(hom)); diff --git a/gap/io.gi b/gap/io.gi index 59df19285..ebf3b0310 100644 --- a/gap/io.gi +++ b/gap/io.gi @@ -209,7 +209,8 @@ function(arg) fi; end; - record.ShallowCopy := function(iter) + # TODO store filename, decoder in iter? + record.ShallowCopy := function(_) local file; file := DigraphFile(UserHomeExpand(filename), decoder, "r"); return rec(file := file, current := file!.coder(file)); @@ -595,7 +596,7 @@ end); InstallMethod(DigraphFromGraph6StringCons, "for IsMutableDigraph and a string", [IsMutableDigraph, IsString], -function(func, s) +function(filt, s) local FindCoord, list, n, start, maxedges, out, pos, nredges, i, bpos, edge, j; @@ -672,13 +673,13 @@ function(func, s) od; pos := pos + 6; od; - return DigraphNC(IsMutableDigraph, out); + return DigraphNC(filt, out); end); InstallMethod(DigraphFromGraph6StringCons, "for IsImmutableDigraph and a string", [IsImmutableDigraph, IsString], -function(filt, s) +function(_, s) local D; D := MakeImmutable(DigraphFromGraph6StringCons(IsMutableDigraph, s)); SetIsSymmetricDigraph(D, true); @@ -696,7 +697,7 @@ s -> DigraphFromGraph6String(IsImmutableDigraph, s)); InstallMethod(DigraphFromDigraph6StringCons, "for IsMutableDigraph and a string", [IsMutableDigraph, IsString], -function(func, s) +function(filt, s) local legacy, list, n, start, i, range, source, pos, len, j, bpos, tabpos; # NOTE: this package originally used a version of digraph6 that reads down # the columns of an adjacency matrix, and appends a '+' to the start. This @@ -775,12 +776,12 @@ function(func, s) od; if legacy then # source and range are reversed - return DigraphNC(IsMutableDigraph, + return DigraphNC(filt, rec(DigraphNrVertices := n, DigraphSource := range, DigraphRange := source)); fi; - return DigraphNC(IsMutableDigraph, + return DigraphNC(filt, rec(DigraphNrVertices := n, DigraphRange := range, DigraphSource := source)); @@ -800,7 +801,7 @@ InstallMethod(DigraphFromDigraph6String, "for a string", InstallMethod(DigraphFromSparse6StringCons, "for IsMutableDigraph and a string", [IsMutableDigraph, IsString], -function(func, s) +function(filt, s) local list, n, start, blist, pos, num, bpos, k, range, source, len, v, i, finish, x, j; @@ -908,7 +909,7 @@ function(func, s) range := range + 1; source := source + 1; - return DigraphNC(IsMutableDigraph, (rec(DigraphNrVertices := n, + return DigraphNC(filt, (rec(DigraphNrVertices := n, DigraphRange := range, DigraphSource := source))); end); @@ -916,7 +917,7 @@ end); InstallMethod(DigraphFromSparse6StringCons, "for IsImmutableDigraph and a string", [IsImmutableDigraph, IsString], -function(filt, s) +function(_, s) local D; D := MakeImmutable(DigraphFromSparse6String(IsMutableDigraph, s)); SetIsSymmetricDigraph(D, true); @@ -924,8 +925,7 @@ function(filt, s) end); InstallMethod(DigraphFromSparse6String, "for a function and a string", -[IsFunction, IsString], -DigraphFromSparse6StringCons); +[IsFunction, IsString], DigraphFromSparse6StringCons); InstallMethod(DigraphFromSparse6String, "for a string", [IsString], @@ -1059,9 +1059,9 @@ function(func, s) od; range := range + 1; source := source + 1; - return DigraphNC(IsMutableDigraph, (rec(DigraphNrVertices := n, - DigraphRange := range, - DigraphSource := source))); + return DigraphNC(func, (rec(DigraphNrVertices := n, + DigraphRange := range, + DigraphSource := source))); end); InstallMethod(DigraphFromDiSparse6StringCons, @@ -1102,21 +1102,19 @@ InstallMethod(DigraphFromPlainTextStringCons, "for IsMutableDigraph and a string", [IsMutableDigraph, IsString], function(filt, s) local f; - f := x -> DigraphByEdges(IsMutableDigraph, x); + f := x -> DigraphByEdges(filt, x); return DIGRAPHS_PlainTextLineDecoder(f, " ", " ", 1)(Chomp(s)); end); InstallMethod(DigraphFromPlainTextStringCons, "for IsImmutableDigraph and a string", [IsImmutableDigraph, IsString], -{filt, s} -> MakeImmutable(DigraphFromPlainTextStringCons(IsMutableDigraph, s))); +{_, s} -> MakeImmutable(DigraphFromPlainTextStringCons(IsMutableDigraph, s))); InstallMethod(DigraphFromPlainTextString, "for a function and a string", -[IsFunction, IsString], -DigraphFromPlainTextStringCons); +[IsFunction, IsString], DigraphFromPlainTextStringCons); InstallMethod(DigraphFromPlainTextString, "for a string", -[IsString], -s -> DigraphFromPlainTextString(IsImmutableDigraph, s)); +[IsString], s -> DigraphFromPlainTextString(IsImmutableDigraph, s)); # DIMACS format: for symmetric digraphs, one per file, can have loops and # multiple edges. @@ -1610,10 +1608,20 @@ function(D) return List(list, i -> CharInt(i + 63)); end); +BindGlobal("DIGRAPHS_AddBinary", +function(blist, k, nextbit, i) + local b; + for b in [1 .. k] do + blist[nextbit] := Int((i mod (2 ^ (k - b + 1))) / (2 ^ (k - b))) = 1; + nextbit := nextbit + 1; + od; + return nextbit; +end); + InstallMethod(Sparse6String, "for a digraph by out-neighbours", [IsDigraphByOutNeighboursRep], function(D) - local list, n, lenlist, adj, nredges, k, blist, v, nextbit, AddBinary, i, j, + local list, n, lenlist, adj, nredges, k, blist, v, nextbit, i, j, bitstopad, pos, block; if not IsSymmetricDigraph(D) then ErrorNoReturn("the argument must be a symmetric digraph,"); @@ -1648,13 +1656,6 @@ function(D) blist := BlistList([1 .. nredges * (k + 1) / 2], []); v := 0; nextbit := 1; - AddBinary := function(blist, i) - local b; - for b in [1 .. k] do - blist[nextbit] := Int((i mod (2 ^ (k - b + 1))) / (2 ^ (k - b))) = 1; - nextbit := nextbit + 1; - od; - end; for i in [1 .. Length(adj)] do for j in adj[i] do if i < j then @@ -1668,13 +1669,12 @@ function(D) v := v + 1; elif i > v + 2 then blist[nextbit] := true; - nextbit := nextbit + 1; - AddBinary(blist, i - 1); + nextbit := DIGRAPHS_AddBinary(blist, k, nextbit + 1, i - 1); v := i - 1; blist[nextbit] := false; nextbit := nextbit + 1; fi; - AddBinary(blist, j - 1); + nextbit := DIGRAPHS_AddBinary(blist, k, nextbit, j - 1); od; od; @@ -1721,7 +1721,7 @@ InstallMethod(DiSparse6String, "for a digraph by out-neighbours", [IsDigraphByOutNeighboursRep], function(D) local list, n, lenlist, adj, source_i, range_i, source_d, range_d, len1, - len2, sort_d, perm, sort_i, k, blist, v, nextbit, AddBinary, bitstopad, + len2, sort_d, perm, sort_i, k, blist, v, nextbit, bitstopad, pos, block, i, j; list := []; @@ -1800,13 +1800,6 @@ function(D) blist := []; v := 0; nextbit := 1; - AddBinary := function(blist, i) - local b; - for b in [1 .. k] do - blist[nextbit] := Int((i mod (2 ^ (k - b + 1))) / (2 ^ (k - b))) = 1; - nextbit := nextbit + 1; - od; - end; for i in [1 .. Length(source_d)] do if source_d[i] = v then blist[nextbit] := false; @@ -1817,19 +1810,17 @@ function(D) v := v + 1; elif source_d[i] > v + 1 then # is this check necessary blist[nextbit] := true; - nextbit := nextbit + 1; - AddBinary(blist, source_d[i]); + nextbit := DIGRAPHS_AddBinary(blist, k, nextbit + 1, source_d[i]); v := source_d[i]; blist[nextbit] := false; nextbit := nextbit + 1; fi; - AddBinary(blist, range_d[i]); + nextbit := DIGRAPHS_AddBinary(blist, k, nextbit, range_d[i]); od; # Add a separation symbol (1 n). blist[nextbit] := true; - nextbit := nextbit + 1; - AddBinary(blist, n); + nextbit := DIGRAPHS_AddBinary(blist, k, nextbit + 1, n); # Repeat everything for increasing edges v := 0; @@ -1843,13 +1834,12 @@ function(D) v := v + 1; elif range_i[i] > v + 1 then # is this check necessary blist[nextbit] := true; - nextbit := nextbit + 1; - AddBinary(blist, range_i[i]); + nextbit := DIGRAPHS_AddBinary(blist, k, nextbit + 1, range_i[i]); v := range_i[i]; blist[nextbit] := false; nextbit := nextbit + 1; fi; - AddBinary(blist, source_i[i]); + nextbit := DIGRAPHS_AddBinary(blist, k, nextbit, source_i[i]); od; # Add padding bits: diff --git a/gap/isomorph.gi b/gap/isomorph.gi index 119dec136..d00bef066 100644 --- a/gap/isomorph.gi +++ b/gap/isomorph.gi @@ -117,7 +117,7 @@ end); ## Returns a list where the first position is the automorphism group, and the ## second is the canonical labelling. BindGlobal("BLISS_DATA", -function(D, vert_colours, edge_colours, calling_function_name) +function(D, vert_colours, edge_colours) if vert_colours <> fail then vert_colours := DIGRAPHS_ValidateVertexColouring(DigraphNrVertices(D), vert_colours); @@ -128,10 +128,7 @@ function(D, vert_colours, edge_colours, calling_function_name) return BLISS_DATA_NC(D, vert_colours, edge_colours); end); -BindGlobal("BLISS_DATA_NO_COLORS", -function(D) - return BLISS_DATA(D, fail, fail, ""); -end); +BindGlobal("BLISS_DATA_NO_COLORS", D -> BLISS_DATA(D, fail, fail)); if DIGRAPHS_NautyAvailable then BindGlobal("NAUTY_DATA", @@ -181,12 +178,7 @@ end); InstallMethod(BlissCanonicalLabelling, "for a digraph and vertex coloring", [IsDigraph, IsHomogeneousList], -function(D, colors) - return BLISS_DATA(D, - colors, - fail, - "BlissCanonicalLabelling")[2]; -end); +{D, colors} -> BLISS_DATA(D, colors, fail)[2]); InstallMethod(NautyCanonicalLabelling, "for a digraph", [IsDigraph], @@ -292,23 +284,13 @@ function(D) end); InstallMethod(BlissAutomorphismGroup, "for a digraph and vertex coloring", -[IsDigraph, IsHomogeneousList], -function(D, colors) - return BLISS_DATA(D, - colors, - fail, - "AutomorphismGroup")[1]; -end); +[IsDigraph, IsHomogeneousList], {D, colors} -> BLISS_DATA(D, colors, fail)[1]); InstallMethod(BlissAutomorphismGroup, "for a digraph, vertex colouring, and edge colouring", [IsDigraph, IsHomogeneousList, IsList], -function(digraph, vert_colours, edge_colours) - return BLISS_DATA(digraph, - vert_colours, - edge_colours, - "AutomorphismGroup")[1]; -end); +{digraph, vert_colours, edge_colours} +-> BLISS_DATA(digraph, vert_colours, edge_colours)[1]); InstallMethod(BlissAutomorphismGroup, "for a digraph, fail, and edge colouring", @@ -317,10 +299,7 @@ function(digraph, vert_colours, edge_colours) if not vert_colours = fail then TryNextMethod(); fi; - return BLISS_DATA(digraph, - vert_colours, - edge_colours, - "AutomorphismGroup")[1]; + return BLISS_DATA(digraph, vert_colours, edge_colours)[1]; end); InstallMethod(NautyAutomorphismGroup, "for a digraph and vertex coloring", diff --git a/gap/labels.gi b/gap/labels.gi index 17965083a..0018963ef 100644 --- a/gap/labels.gi +++ b/gap/labels.gi @@ -79,9 +79,7 @@ function(D) end); InstallMethod(HaveEdgeLabelsBeenAssigned, "for a digraph", [IsDigraph], -function(D) - return IsBound(D!.edgelabels); -end); +D -> IsBound(D!.edgelabels)); InstallMethod(SetDigraphEdgeLabel, "for a digraph, a pos int, a pos int, and an object", diff --git a/gap/oper.gi b/gap/oper.gi index 5273dcd0b..5186a7d3f 100644 --- a/gap/oper.gi +++ b/gap/oper.gi @@ -193,9 +193,8 @@ end); InstallMethod(DigraphAddEdge, "for an immutable digraph and two positive integers", [IsImmutableDigraph, IsPosInt, IsPosInt], -function(D, src, ran) - return MakeImmutable(DigraphAddEdge(DigraphMutableCopy(D), src, ran)); -end); +{D, src, ran} +-> MakeImmutable(DigraphAddEdge(DigraphMutableCopy(D), src, ran))); InstallMethod(DigraphAddEdge, "for a mutable digraph and a list", [IsMutableDigraph, IsList], @@ -250,9 +249,8 @@ end); InstallMethod(DigraphRemoveEdge, "for a immutable digraph and two positive integers", [IsImmutableDigraph, IsPosInt, IsPosInt], -function(D, src, ran) - return MakeImmutable(DigraphRemoveEdge(DigraphMutableCopy(D), src, ran)); -end); +{D, src, ran} +-> MakeImmutable(DigraphRemoveEdge(DigraphMutableCopy(D), src, ran))); InstallMethod(DigraphRemoveEdge, "for a mutable digraph and a list", [IsMutableDigraph, IsList], @@ -619,7 +617,8 @@ InstallMethod(ModularProduct, "for a digraph and digraph", function(D1, D2) local edge_function; - edge_function := function(u, v, m, n, map) + edge_function := function(u, v, m, n, map) # gaplint: disable=W000 + # neither m nor n is used, but can't replace them both with _ local w, x, connections; connections := []; for w in OutNeighbours(D1)[u] do @@ -647,7 +646,8 @@ InstallMethod(StrongProduct, "for a digraph and digraph", function(D1, D2) local edge_function; - edge_function := function(u, v, m, n, map) + edge_function := function(u, v, m, n, map) # gaplint: disable=W000 + # neither m nor n is used, but can't replace them both with _ local w, x, connections; connections := []; for x in OutNeighbours(D2)[v] do @@ -694,7 +694,7 @@ InstallMethod(HomomorphicProduct, "for a digraph and digraph", function(D1, D2) local edge_function; - edge_function := function(u, v, m, n, map) + edge_function := function(u, v, _, n, map) local w, x, connections; connections := []; for x in [1 .. n] do @@ -716,7 +716,7 @@ InstallMethod(LexicographicProduct, "for a digraph and digraph", function(D1, D2) local edge_function; - edge_function := function(u, v, m, n, map) + edge_function := function(u, v, _, n, map) local w, x, connections; connections := []; for w in OutNeighbours(D1)[u] do @@ -752,9 +752,7 @@ function(D1, D2, edge_function) edges := EmptyPlist(m * n); - map := function(a, b) - return (a - 1) * n + b; - end; + map := {a, b} -> (a - 1) * n + b; for u in [1 .. m] do for v in [1 .. n] do @@ -984,9 +982,8 @@ end); InstallMethod(QuotientDigraph, "for an immutable digraph and a homogeneous list", [IsImmutableDigraph, IsHomogeneousList], -function(D, partition) - return MakeImmutable(QuotientDigraph(DigraphMutableCopy(D), partition)); -end); +{D, partition} -> +MakeImmutable(QuotientDigraph(DigraphMutableCopy(D), partition))); ############################################################################# # 6. In and out degrees, neighbours, and edges of vertices @@ -2198,9 +2195,7 @@ function(D, i, j) if HasDigraphJoinTable(D) then return DigraphJoinTable(D)[i, j]; - fi; - - if not IsPartialOrderDigraph(D) then + elif not IsPartialOrderDigraph(D) then ErrorNoReturn("the 1st argument must satisfy ", "IsPartialOrderDigraph,"); elif not i in DigraphVertices(D) then @@ -2230,9 +2225,7 @@ function(D, i, j) if HasDigraphMeetTable(D) then return DigraphMeetTable(D)[i, j]; - fi; - - if not IsPartialOrderDigraph(D) then + elif not IsPartialOrderDigraph(D) then ErrorNoReturn("the 1st argument must satisfy ", "IsPartialOrderDigraph,"); elif not i in DigraphVertices(D) then diff --git a/gap/orbits.gi b/gap/orbits.gi index c3bfe4867..eefc39e5c 100644 --- a/gap/orbits.gi +++ b/gap/orbits.gi @@ -87,7 +87,7 @@ function(D) return out; end); -InstallImmediateMethod(DigraphGroup, IsDigraph and HasAutomorphismGroup, 0, +BindGlobal("DIGRAPHS_DigraphGroup", function(D) if IsMultiDigraph(D) then return Range(Projection(AutomorphismGroup(D), 1)); @@ -95,14 +95,10 @@ function(D) return AutomorphismGroup(D); end); -InstallMethod(DigraphGroup, "for a digraph", -[IsDigraph], -function(D) - if IsMultiDigraph(D) then - return Range(Projection(AutomorphismGroup(D), 1)); - fi; - return AutomorphismGroup(D); -end); +InstallImmediateMethod(DigraphGroup, IsDigraph and HasAutomorphismGroup, 0, +DIGRAPHS_DigraphGroup); + +InstallMethod(DigraphGroup, "for a digraph", [IsDigraph], DIGRAPHS_DigraphGroup); InstallMethod(DigraphOrbits, "for a digraph", [IsDigraph], diff --git a/gap/prop.gi b/gap/prop.gi index 6f29c6fe1..0f4fd0d18 100644 --- a/gap/prop.gi +++ b/gap/prop.gi @@ -623,7 +623,7 @@ function(D) # complete digraph on 2 vertices. proper_endo_found := false; - hook := function(unneded_argument, T) + hook := function(_, T) # the hook is required by HomomorphismDigraphsFinder to have two arguments, # the 1st of which is user_param, which this method doesn't need. if RankOfTransformation(T, [1 .. N]) < N then diff --git a/gap/utils.gi b/gap/utils.gi index 1b3ded314..841c8073e 100644 --- a/gap/utils.gi +++ b/gap/utils.gi @@ -34,11 +34,7 @@ function() end); InstallGlobalFunction(DIGRAPHS_Test, -function(filename) - return DIGRAPHS_RunTest(function() - return Test(filename, rec(showProgress := false)); - end); -end); +fname -> DIGRAPHS_RunTest({} -> Test(fname, rec(showProgress := false)))); # The parameter should be a 0-argument function which returns true or # false. @@ -106,10 +102,7 @@ function() "main.xml", DIGRAPHS_DocXMLFiles, "Single"); end); -InstallGlobalFunction(DIGRAPHS_Dir, -function() - return GAPInfo.PackagesLoaded.digraphs[1]; -end); +InstallGlobalFunction(DIGRAPHS_Dir, {} -> GAPInfo.PackagesLoaded.digraphs[1]); ############################################################################# # User facing stuff @@ -163,9 +156,7 @@ function(arg) fi; dir := DirectoriesPackageLibrary("digraphs", "tst/standard/"); - return DIGRAPHS_RunTest(function() - return TestDirectory(dir, opts); - end); + return DIGRAPHS_RunTest({} -> TestDirectory(dir, opts)); end); InstallGlobalFunction(DigraphsTestExtreme, @@ -207,9 +198,7 @@ function(arg) fi; dir := DirectoriesPackageLibrary("digraphs", "tst/extreme/"); - return DIGRAPHS_RunTest(function() - return TestDirectory(dir, opts); - end); + return DIGRAPHS_RunTest({} -> TestDirectory(dir, opts)); end); InstallGlobalFunction(DigraphsMakeDoc, diff --git a/tst/extreme/oper.tst b/tst/extreme/oper.tst index e388e1132..82b9aeb31 100644 --- a/tst/extreme/oper.tst +++ b/tst/extreme/oper.tst @@ -113,15 +113,15 @@ gap> list := ReadDigraphs(Concatenation(DIGRAPHS_Dir(), > "/digraphs-lib/fining.p.gz"));; gap> gr := list[4];; gap> gr2 := DigraphCopy(gr);; -gap> layers1 := List(DigraphLayers(gr, 1), x -> Set(x));; -gap> layers2 := List(DigraphLayers(gr2, 1), x -> Set(x));; +gap> layers1 := List(DigraphLayers(gr, 1), Set);; +gap> layers2 := List(DigraphLayers(gr2, 1), Set);; gap> layers1 = layers2; true gap> layers := [];; gap> for i in list do > Add(layers, DigraphLayers(i, 1)); > od; -gap> List(layers, x -> Size(x)); +gap> List(layers, Size); [ 3, 3, 5, 5, 7, 9 ] gap> gr := list[4];; gap> DigraphLayers(gr, 1); diff --git a/tst/standard/digraph.tst b/tst/standard/digraph.tst index 06a99877b..20933e2ca 100644 --- a/tst/standard/digraph.tst +++ b/tst/standard/digraph.tst @@ -684,8 +684,8 @@ gap> D := [ > "&G~sC~EocF?oC", "&F~lQG{IB?_", "&G~s[~EocF?oC", "&G~tKpCO{D?oC", > "&F~jrGcMB?_", "&I~|SrNCKNoR?{@OB?C", "&F~lQG{IB?_", "&F~irgcIB?_", > "&F~kqG{IB?_"];; -gap> D := List(D, x -> DigraphFromDigraph6String(x));; -gap> iso := [];; +gap> D := List(D, DigraphFromDigraph6String);; +gap> iso := [];; gap> iso_distr := [];; gap> eq := [];; gap> eq_distr := [];; @@ -1523,7 +1523,7 @@ gap> gr; gap> Size(T); 32 gap> D := GreensDClasses(T);; -gap> List(D, x -> Size(x)); +gap> List(D, Size); [ 6, 24, 2 ] gap> for i in [1 .. 3] do > for j in [1 .. 3] do @@ -1550,7 +1550,7 @@ gap> T := AsSemigroup(IsPartialPermSemigroup, gr2, [G1, G2, G3, G4], > [[1, 3, hom13], [2, 3, hom23], [4, 1, hom41], [4, 2, hom42]]);; gap> Size(T); 56 -gap> List(GreensDClasses(T), x -> Size(x)); +gap> List(GreensDClasses(T), Size); [ 6, 24, 2, 24 ] gap> List(GreensDClasses(T), x -> Size(x) = Size(GroupHClassOfGreensDClass(x))); [ true, true, true, true ] @@ -1572,7 +1572,7 @@ gap> T := AsSemigroup(IsPartialPermSemigroup, gr4, [G1, G2, G3, G4, G5], > [[2, 1, hom21], [3, 1, hom31], [4, 1, hom41], [5, 2, hom52], [5, 3, hom53]]);; gap> Size(T); 90 -gap> List(GreensDClasses(T), x -> Size(x)); +gap> List(GreensDClasses(T), Size); [ 24, 24, 6, 24, 12 ] gap> U := AsSemigroup(IsPartialPermSemigroup, > DigraphReverse(gr4), diff --git a/tst/standard/io.tst b/tst/standard/io.tst index 3439b0cdd..ad77eec19 100644 --- a/tst/standard/io.tst +++ b/tst/standard/io.tst @@ -33,7 +33,7 @@ gap> DigraphFromGraph6String(str); gap> l := ["BW", "C]", "DQw", "ECO_", "FCZUo", "GCZenS", "HCQTndn", > "H?qcyxf"];; -gap> List(l, x -> DigraphFromGraph6String(x)); +gap> List(l, DigraphFromGraph6String); [ , , , @@ -234,7 +234,7 @@ IO_OK # Note that some vertices in gr[2] are lost due to the file format not # supporting isolated vertices (i.e. vertices exist only because they are -# involved in an edge). +# involved in an edge). gap> filename := Concatenation(DIGRAPHS_Dir(), "/tst/out/test.txt");; gap> ReadDigraphs(filename); [ , @@ -471,7 +471,7 @@ Error, the 2nd argument must be a non-empty string, gap> DigraphFromDiSparse6String(""); Error, the 2nd argument must be a non-empty string, -# DiSparse6 +# DiSparse6 gap> DigraphFromDiSparse6String("I'm a string"); Error, the 2nd argument is not a valid disparse6 string, gap> DigraphFromDiSparse6String(".~~"); @@ -488,7 +488,7 @@ gap> gr := Digraph([[], [], [1, 2]]);; gap> DiSparse6String(gr); ".BoN" -# Plain text encoding +# Plain text encoding gap> gr := CompleteDigraph(3); gap> str := PlainTextString(gr); diff --git a/tst/standard/oper.tst b/tst/standard/oper.tst index beb378aaf..80086203b 100644 --- a/tst/standard/oper.tst +++ b/tst/standard/oper.tst @@ -980,7 +980,7 @@ gap> gr := DigraphAddEdges(gr, [[2, 3], [5, 6], [9, 10]]); gap> gr = ChainDigraph(14); true gap> n := 10;; -gap> DigraphDisjointUnion(List([1 .. n], x -> EmptyDigraph(x))) = +gap> DigraphDisjointUnion(List([1 .. n], EmptyDigraph)) = > EmptyDigraph(Int(n * (n + 1) / 2)); true gap> D1 := CycleDigraph(3);; D2 := DigraphReverse(D1);;