Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions doc/grahom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,8 @@ gap> MonomorphismsDigraphsRepresentatives(gr1, CompleteDigraph(3));
the vertices and the edges of <A>digraph1</A>, and are therefore possibly
strictly contained in the induced subdigraph on the same vertex set.
<Example><![CDATA[
gap> SubdigraphsMonomorphisms(CompleteBipartiteDigraph(2, 2),
> CompleteDigraph(4));
gap> Set(SubdigraphsMonomorphisms(CompleteBipartiteDigraph(2, 2),
> CompleteDigraph(4)));
[ Transformation( [ 1, 3, 2 ] ), Transformation( [ 2, 3, 1 ] ),
Transformation( [ 3, 4, 2, 1 ] ) ]
gap> SubdigraphsMonomorphismsRepresentatives(
Expand Down
4 changes: 2 additions & 2 deletions gap/attr.gd
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ DeclareAttributeThatReturnsDigraph("DigraphDual", IsDigraph);
DeclareAttributeThatReturnsDigraph("ReducedDigraph", IsDigraph);
DeclareAttributeThatReturnsDigraph("DigraphRemoveAllMultipleEdges", IsDigraph);

# TODO replace all DeclareOperations below to DeclareAttributeThatReturnsDigraph,
# and remove the *Attr versions.
# TODO replace all DeclareOperations below to
# DeclareAttributeThatReturnsDigraph, and remove the *Attr versions.

DeclareOperation("DigraphAddAllLoops", [IsDigraph]);
DeclareAttribute("DigraphAddAllLoopsAttr", IsDigraph);
Expand Down
12 changes: 7 additions & 5 deletions gap/attr.gi
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,8 @@ function(D)
fi;
od;
# Iterate over the maximal independent sets of V[S]
subset_mis := DIGRAPHS_MaximalIndependentSetsSubtractedSet(mis, S, infinity);
subset_mis :=
DIGRAPHS_MaximalIndependentSetsSubtractedSet(mis, S, infinity);
# Flip the list, as we now need the actual set.
FlipBlist(S);
for I in subset_mis do
Expand Down Expand Up @@ -1673,9 +1674,9 @@ function(D, rotationSystem)

if Difference(Union(rotationSystem), DigraphVertices(D))
<> [] then
Error("the 2nd argument (dense list <rotationSystem>) is not a rotation",
" system for the 1st argument (digraph <D>), expected the union",
" to be ", DigraphVertices(D), " but found ",
Error("the 2nd argument (dense list <rotationSystem>) is not ",
"a rotation system for the 1st argument (digraph <D>), ",
"expected the union to be ", DigraphVertices(D), " but found ",
Union(rotationSystem));
fi;

Expand Down Expand Up @@ -2953,7 +2954,8 @@ function(D)
# Ensure that InducedSubdigraph is given a digraph with vertex labels equal
# to DigraphVertices(D).
SetDigraphVertexLabels(G, DigraphVertices(G));
G := InducedSubdigraph(G, Difference(DigraphVertices(G), DigraphLoops(G)));
G := InducedSubdigraph(G, Difference(DigraphVertices(G),
DigraphLoops(G)));
lab := DigraphVertexLabels(G);
G := DigraphSymmetricClosure(G);
mateG := DIGRAPHS_MaximalMatching(G);
Expand Down
20 changes: 15 additions & 5 deletions gap/cliques.gi
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ function(D, set)
return not ForAny(try, x -> IsEmpty(Intersection(set, nbs[x])));
end);

InstallMethod(IsClique, "for a digraph by out-neighbours and a homogeneous list",
InstallMethod(IsClique,
"for a digraph by out-neighbours and a homogeneous list",
[IsDigraphByOutNeighboursRep, IsHomogeneousList],
function(D, clique)
local nbs, v;
Expand Down Expand Up @@ -432,7 +433,15 @@ function(arg...)
return DigraphCliquesAttr(D);
fi;

out := CliquesFinder(D, fail, [], limit, include, exclude, false, size, false);
out := CliquesFinder(D,
fail,
[],
limit,
include,
exclude,
false,
size,
false);
# Store the result if appropriate (not special case due to params)
if IsEmpty(include) and IsEmpty(exclude) and limit = infinity and size = fail
and IsImmutableDigraph(D) then
Expand Down Expand Up @@ -550,7 +559,7 @@ function(arg...)
orbits := HashMap();
for c in cliques do
if not c in orbits then
DIGRAPHS_AddOrbitToHashMap(G, c, orbits);
DIGRAPHS_AddOrbitToHashMap(G, c, OnSets, orbits);
fi;
od;
out := Keys(orbits);
Expand Down Expand Up @@ -709,7 +718,8 @@ function(digraph, hook, user_param, limit, include, exclude, max, size, reps)

new_found := 0;
if not clique in found_orbits then
orbit := DIGRAPHS_AddOrbitToHashMap(group, clique, found_orbits);
orbit :=
DIGRAPHS_AddOrbitToHashMap(group, clique, OnSets, found_orbits);
n := Length(orbit);

if invariant_include and invariant_exclude then
Expand Down Expand Up @@ -895,7 +905,7 @@ function(D, hook, param, lim, inc, exc, max, size, reps, inc_var, exc_var)
num := num + 1;
return;
elif not c in found_orbits then
orb := DIGRAPHS_AddOrbitToHashMap(grp, c, found_orbits);
orb := DIGRAPHS_AddOrbitToHashMap(grp, c, OnSets, found_orbits);
n := Length(orb);

if invariant then # we're not just looking for orbit reps, but inc and
Expand Down
7 changes: 5 additions & 2 deletions gap/digraph.gi
Original file line number Diff line number Diff line change
Expand Up @@ -859,8 +859,11 @@ function(_, edges, n)
for edge in edges do
pos := pos + 1;
if not IsList(edge) then
ErrorNoReturn("the 1st argument (list of edges) must be a list of lists, ",
"but found ", TNAM_OBJ(edge), " in position ", pos);
ErrorNoReturn("the 1st argument (list of edges) must be a list of ",
"lists, but found ",
TNAM_OBJ(edge),
" in position ",
pos);
elif Length(edge) <> 2 then
ErrorNoReturn("the 1st argument (list of edges) must be a list of lists ",
"of length 2, found ", edge, " (length ", Length(edge),
Expand Down
9 changes: 6 additions & 3 deletions gap/display.gi
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,13 @@ InstallMethod(DotDigraph, "for a digraph by out-neighbours",
[IsDigraphByOutNeighboursRep],
D -> DIGRAPHS_DotDigraph(D, [], []));

InstallMethod(DotColoredDigraph, "for a digraph by out-neighbours and two lists",
InstallMethod(DotColoredDigraph,
"for a digraph by out-neighbours and two lists",
[IsDigraphByOutNeighboursRep, IsList, IsList],
function(D, vert, edge)
local vert_func, edge_func;
if DIGRAPHS_ValidVertColors(D, vert) and DIGRAPHS_ValidEdgeColors(D, edge) then
if DIGRAPHS_ValidVertColors(D, vert)
and DIGRAPHS_ValidEdgeColors(D, edge) then
vert_func := i -> StringFormatted("[color={}, style=filled]", vert[i]);
edge_func := {i, j} -> StringFormatted("[color={}]", edge[i][j]);
return DIGRAPHS_DotDigraph(D, [vert_func], [edge_func]);
Expand Down Expand Up @@ -226,7 +228,8 @@ InstallMethod(DotSymmetricColoredDigraph,
[IsDigraphByOutNeighboursRep, IsList, IsList],
function(D, vert, edge)
local vert_func, edge_func;
if DIGRAPHS_ValidVertColors(D, vert) and DIGRAPHS_ValidEdgeColors(D, edge) then
if DIGRAPHS_ValidVertColors(D, vert)
and DIGRAPHS_ValidEdgeColors(D, edge) then
vert_func := i -> StringFormatted("[color={}, style=filled]", vert[i]);
edge_func := {i, j} -> StringFormatted("[color={}]", edge[i][j]);
return DIGRAPHS_DotSymmetricDigraph(D, [vert_func], [edge_func]);
Expand Down
5 changes: 3 additions & 2 deletions gap/examples.gi
Original file line number Diff line number Diff line change
Expand Up @@ -1422,7 +1422,7 @@ InstallMethod(KneserGraphCons, "for IsMutableDigraph and two integers",
function(_, n, k)
local D, vertices, i, j;
if n < k then
ErrorNoReturn("argument <n> must be greater than or equal to argument <k>,");
ErrorNoReturn("argument <n> must be greater than or equal to argument <k>");
fi;
vertices := Combinations([1 .. n], k);
D := EmptyDigraph(IsMutableDigraph, Length(vertices));
Expand Down Expand Up @@ -1467,7 +1467,8 @@ InstallMethod(KneserGraph, "for two integers", [IsPosInt, IsPosInt],
InstallMethod(KneserGraph, "for a function and two integers",
[IsFunction, IsPosInt, IsPosInt], KneserGraphCons);

InstallMethod(LindgrenSousselierGraphCons, "for IsMutableDigraph and an integer",
InstallMethod(LindgrenSousselierGraphCons,
"for IsMutableDigraph and an integer",
[IsMutableDigraph, IsPosInt],
function(_, n)
local D, central, i, threei;
Expand Down
88 changes: 36 additions & 52 deletions gap/grahom.gi
Original file line number Diff line number Diff line change
Expand Up @@ -333,75 +333,59 @@ end);
InstallMethod(SubdigraphsMonomorphismsRepresentatives,
"for a digraph and a digraph", [IsDigraph, IsDigraph],
function(H, G)
local GV, HN, map, reps, result, set, rep;

GV := DigraphVertices(G);
HN := DigraphNrVertices(H);
local AG, map, result, K, rep;

AG := AutomorphismGroup(G);
map := HashMap();
reps := [];
result := [];

for set in Combinations(GV, HN) do
if not set in map then
Add(reps, set);
DIGRAPHS_AddOrbitToHashMap(AutomorphismGroup(G), set, map);
for rep in MonomorphismsDigraphsRepresentatives(H, G) do
K := OnSetsTuples(DigraphEdges(H), rep);
if not K in map then
Add(result, rep);
DIGRAPHS_AddOrbitToHashMap(AG, K, OnSetsTuples, map);
fi;
od;

result := [];
for rep in reps do
map :=
HomomorphismDigraphsFinder(H, # domain
G, # range
fail, # hook
[], # user_param
1, # max_results
HN, # hint (i.e. rank)
true, # injective
rep, # image
[], # partial_map
fail, # colors1
fail, # colors2
DigraphWelshPowellOrder(H),
Group(()));
if Length(map) <> 0 then
Add(result, map[1]);
fi;
od;
return result;
end);

InstallMethod(SubdigraphsMonomorphisms, "for a digraph and a digraph",
[IsDigraph, IsDigraph],
function(H, G)
local ApplyHomomorphismNC, reps, AG, result, sub, o, x, rep, i;

ApplyHomomorphismNC := function(D1, D2, t)
local old, new, v, im;
old := OutNeighbours(D1);
new := List([1 .. DigraphNrVertices(D2)], x -> []);
for v in DigraphVertices(D1) do
im := v ^ t;
if not IsBound(new[im]) then
new[im] := [];
fi;
Append(new[im], OnTuples(old[v], t));
local AddOrbitToHashMap, AG, map, K, rep;

AddOrbitToHashMap := function(G, set, act, hashmap, rep)
local gens, o, im, pt, g;

gens := GeneratorsOfGroup(G);
o := [set];
Assert(1, not set in hashmap);
hashmap[set] := rep;
for pt in o do
for g in gens do
im := act(pt, g);
if not im in hashmap then
hashmap[im] := hashmap[pt] * g;
# Assert(0, OnSetsTuples(set, hashmap[im]) = im);
Add(o, im);
fi;
od;
od;
return DigraphNC(new);
return o;
end;

reps := SubdigraphsMonomorphismsRepresentatives(H, G);
AG := AutomorphismGroup(G);
result := [];
for rep in reps do
sub := ApplyHomomorphismNC(H, G, rep);
o := Enumerate(Orb(AG, sub, OnDigraphs, rec(schreier := true)));
for i in [1 .. Length(o)] do
x := EvaluateWord(GeneratorsOfGroup(AG), TraceSchreierTreeForward(o, i));
Add(result, rep * x);
od;
map := HashMap();

for rep in MonomorphismsDigraphsRepresentatives(H, G) do
K := OnSetsTuples(DigraphEdges(H), rep);
if not K in map then
AddOrbitToHashMap(AG, K, OnSetsTuples, map, rep);
fi;
od;
return result;

return Values(map);
end);

################################################################################
Expand Down
3 changes: 2 additions & 1 deletion gap/io.gi
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,8 @@ DigraphFromGraph6StringCons);
InstallMethod(DigraphFromGraph6String, "for a string", [IsString],
s -> DigraphFromGraph6String(IsImmutableDigraph, s));

InstallMethod(DigraphFromDigraph6StringCons, "for IsMutableDigraph and a string",
InstallMethod(DigraphFromDigraph6StringCons,
"for IsMutableDigraph and a string",
[IsMutableDigraph, IsString],
function(filt, s)
local legacy, list, n, start, i, range, source, pos, len, j, bpos, tabpos;
Expand Down
12 changes: 8 additions & 4 deletions gap/isomorph.gd
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,14 @@ DeclareGlobalFunction("DIGRAPHS_ValidateEdgeColouring");
DeclareGlobalFunction("DIGRAPHS_CollapseMultiColouredEdges");
DeclareGlobalFunction("DIGRAPHS_CollapseMultipleEdges");

DeclareOperation("IsDigraphAutomorphism", [IsDigraph, IsPerm]);
DeclareOperation("IsDigraphAutomorphism", [IsDigraph, IsPerm, IsList]);
DeclareOperation("IsDigraphAutomorphism", [IsDigraph, IsTransformation]);
DeclareOperation("IsDigraphAutomorphism", [IsDigraph, IsTransformation, IsList]);
DeclareOperation("IsDigraphAutomorphism",
[IsDigraph, IsPerm]);
DeclareOperation("IsDigraphAutomorphism",
[IsDigraph, IsPerm, IsList]);
DeclareOperation("IsDigraphAutomorphism",
[IsDigraph, IsTransformation]);
DeclareOperation("IsDigraphAutomorphism",
[IsDigraph, IsTransformation, IsList]);

DeclareOperation("IsDigraphIsomorphism", [IsDigraph, IsDigraph, IsPerm]);
DeclareOperation("IsDigraphIsomorphism",
Expand Down
7 changes: 4 additions & 3 deletions gap/orbits.gi
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function(G, domain)
end);

InstallGlobalFunction(DIGRAPHS_AddOrbitToHashMap,
function(G, set, hashmap)
function(G, set, act, hashmap)
local gens, o, im, pt, g;

gens := GeneratorsOfGroup(G);
Expand All @@ -78,7 +78,7 @@ function(G, set, hashmap)
hashmap[set] := true;
for pt in o do
for g in gens do
im := OnSets(pt, g);
im := act(pt, g);
if not im in hashmap then
hashmap[im] := true;
Add(o, im);
Expand Down Expand Up @@ -118,7 +118,8 @@ end);
InstallImmediateMethod(DigraphGroup, IsDigraph and HasAutomorphismGroup, 0,
DIGRAPHS_DigraphGroup);

InstallMethod(DigraphGroup, "for a digraph", [IsDigraph], DIGRAPHS_DigraphGroup);
InstallMethod(DigraphGroup, "for a digraph", [IsDigraph],
DIGRAPHS_DigraphGroup);

InstallMethod(DigraphOrbits, "for a digraph",
[IsDigraph],
Expand Down
3 changes: 2 additions & 1 deletion gap/weights.gd
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
DeclareAttribute("EdgeWeights", IsDigraph);
DeclareGlobalFunction("EdgeWeightedDigraph");
DeclareProperty("IsNegativeEdgeWeightedDigraph", IsDigraph and HasEdgeWeights);
DeclareAttribute("EdgeWeightedDigraphTotalWeight", IsDigraph and HasEdgeWeights);
DeclareAttribute("EdgeWeightedDigraphTotalWeight",
IsDigraph and HasEdgeWeights);

# 2. Edge Weight Copies
DeclareOperation("EdgeWeightsMutableCopy", [IsDigraph and HasEdgeWeights]);
Expand Down
3 changes: 2 additions & 1 deletion gap/weights.gi
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,8 @@ end);

InstallMethod(EdgeWeightedDigraphShortestPaths,
"for a digraph with edge weights and known shortest paths and a pos int",
[IsDigraph and HasEdgeWeights and HasEdgeWeightedDigraphShortestPaths, IsPosInt],
[IsDigraph and HasEdgeWeights and HasEdgeWeightedDigraphShortestPaths,
IsPosInt],
function(digraph, source)
local all_paths;
if not source in DigraphVertices(digraph) then
Expand Down
2 changes: 1 addition & 1 deletion tst/standard/examples.tst
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ gap> KneserGraph(6, 3);
<immutable edge- and vertex-transitive symmetric digraph with 20 vertices, 20 \
edges>
gap> KneserGraph(3, 4);
Error, argument <n> must be greater than or equal to argument <k>,
Error, argument <n> must be greater than or equal to argument <k>
gap> KneserGraph(3, -1);
Error, no method found! For debugging hints type ?Recovery from NoMethodFound
Error, no 1st choice method found for `KneserGraph' on 2 arguments
Expand Down
Loading
Loading