From 7ce530713f471fb36ff93a08f2f3ccac9253cec7 Mon Sep 17 00:00:00 2001 From: James Mitchell Date: Tue, 11 Jul 2017 17:07:44 +0100 Subject: [PATCH] Add more attributes for Cayley digraphs Namely, GroupOfCayleyDigraph, SemigroupOfCayleyDigraph, and GeneratorsOfCayleyDigraph, so that the digraph output by CayleyDigraph can recover the semigroup and generating set used to create the digraph. --- doc/digraph.xml | 72 ++++++++++++++++++++++++++++++++++++++-- doc/z-chap2.xml | 2 +- doc/z-chap4.xml | 6 ++++ gap/digraph.gd | 4 +++ gap/digraph.gi | 13 ++++++-- tst/standard/digraph.tst | 6 ++++ 6 files changed, 97 insertions(+), 6 deletions(-) diff --git a/doc/digraph.xml b/doc/digraph.xml index b8e4f7bd0..9a3f247ca 100644 --- a/doc/digraph.xml +++ b/doc/digraph.xml @@ -903,6 +903,12 @@ gap> CycleDigraph(123); If the optional second argument gens is not present, then the generators of G are used by default. + + The digraph created by this operation belongs to the category , the group G can be recovered from the + digraph using , and the generators + gens can be obtained using . + G := DihedralGroup(8); @@ -912,8 +918,70 @@ gap> G := DihedralGroup(IsPermGroup, 8); Group([ (1,2,3,4), (2,4) ]) gap> CayleyDigraph(G); -gap> CayleyDigraph(G, [()]); -]]> +gap> digraph := CayleyDigraph(G, [()]); + +gap> GroupOfCayleyDigraph(digraph) = G; +true +gap> GeneratorsOfCayleyDigraph(digraph); +[ () ]]]> + + +<#/GAPDoc> + +<#GAPDoc Label="GroupOfCayleyDigraph"> + + + + A group or semigroup. + + If digraph is a Cayley graph of a group G and + digraph belongs to the category , then + GroupOfCayleyDigraph returns G. +

+ + If digraph is a Cayley graph of a semigroup S and + digraph belongs to the category , then + SemigroupOfCayleyDigraph returns S. +

+ + See also . + G := DihedralGroup(IsPermGroup, 8); +Group([ (1,2,3,4), (2,4) ]) +gap> digraph := CayleyDigraph(G); + +gap> GroupOfCayleyDigraph(digraph) = G; +true +]]> + + +<#/GAPDoc> + +<#GAPDoc Label="GeneratorsOfCayleyDigraph"> + + + A list of generators. + + If digraph is a Cayley graph of a group or semigroup with + respect to a set of generators gens and digraph belongs to + the category , then + GeneratorsOfCayleyDigraph return the list of generators gens + over which digraph is defined. +

+ + See also + or . + G := DihedralGroup(IsPermGroup, 8); +Group([ (1,2,3,4), (2,4) ]) +gap> digraph := CayleyDigraph(G); + +gap> GeneratorsOfCayleyDigraph(digraph) = GeneratorsOfGroup(G); +true +gap> digraph := CayleyDigraph(G, [()]); + +gap> GeneratorsOfCayleyDigraph(digraph) = [()]; +true]]> <#/GAPDoc> diff --git a/doc/z-chap2.xml b/doc/z-chap2.xml index 002b9448a..52b01d9e7 100644 --- a/doc/z-chap2.xml +++ b/doc/z-chap2.xml @@ -12,6 +12,7 @@ <#Include Label="DigraphByEdges"> <#Include Label="EdgeOrbitsDigraph"> <#Include Label="DigraphByInNeighbours"> + <#Include Label="CayleyDigraph">

Changing representations @@ -72,7 +73,6 @@ <#Include Label="CompleteMultipartiteDigraph"> <#Include Label="CycleDigraph"> <#Include Label="EmptyDigraph"> - <#Include Label="CayleyDigraph"> <#Include Label="JohnsonDigraph">
diff --git a/doc/z-chap4.xml b/doc/z-chap4.xml index 5184833e8..85a33387b 100644 --- a/doc/z-chap4.xml +++ b/doc/z-chap4.xml @@ -59,4 +59,10 @@ <#Include Label="DigraphDegeneracy"> <#Include Label="DigraphDegeneracyOrdering"> + +
Cayley graphs of groups + <#Include Label="GroupOfCayleyDigraph"> + <#Include Label="GeneratorsOfCayleyDigraph"> +
+ diff --git a/gap/digraph.gd b/gap/digraph.gd index fef906dba..777c71ba9 100644 --- a/gap/digraph.gd +++ b/gap/digraph.gd @@ -14,6 +14,10 @@ DeclareCategory("IsDigraph", IsObject); DeclareCategory("IsDigraphWithAdjacencyFunction", IsDigraph); DeclareCategory("IsCayleyDigraph", IsDigraph); +DeclareAttribute("GroupOfCayleyDigraph", IsCayleyDigraph); +DeclareAttribute("SemigroupOfCayleyDigraph", IsCayleyDigraph); +DeclareAttribute("GeneratorsOfCayleyDigraph", IsCayleyDigraph); + # meaning it really has multiple edges!! DeclareProperty("IsMultiDigraph", IsDigraph); diff --git a/gap/digraph.gi b/gap/digraph.gi index acfc80fdf..c3abf5db6 100644 --- a/gap/digraph.gi +++ b/gap/digraph.gi @@ -181,9 +181,7 @@ function(G, gens) if not IsFinite(G) then ErrorNoReturn("Digraphs: CayleyDigraph: usage,\n", "the first argument must be a finite group,"); - fi; - - if not ForAll(gens, x -> x in G) then + elif not ForAll(gens, x -> x in G) then ErrorNoReturn("Digraphs: CayleyDigraph: usage,\n", "elements in the 2nd argument must ", "all belong to the 1st argument ,"); @@ -194,6 +192,9 @@ function(G, gens) end; digraph := Digraph(G, AsList(G), OnRight, adj); SetFilterObj(digraph, IsCayleyDigraph); + SetGroupOfCayleyDigraph(digraph, G); + SetGeneratorsOfCayleyDigraph(digraph, gens); + return digraph; end); @@ -203,6 +204,12 @@ function(G) return CayleyDigraph(G, GeneratorsOfGroup(G)); end); +InstallImmediateMethod(SemigroupOfCayleyDigraph, +IsCayleyDigraph and HasGroupOfCayleyDigraph, 0, +function(digraph) + return GroupOfCayleyDigraph(digraph); +end); + InstallMethod(DoubleDigraph, "for a digraph", [IsDigraph], function(digraph) diff --git a/tst/standard/digraph.tst b/tst/standard/digraph.tst index 2eee2bb9e..2410420a6 100644 --- a/tst/standard/digraph.tst +++ b/tst/standard/digraph.tst @@ -1276,6 +1276,12 @@ gap> IsCayleyDigraph(digraph); true gap> IsDigraph(digraph); true +gap> digraph := CayleyDigraph(group, [()]); + +gap> GroupOfCayleyDigraph(digraph) = group; +true +gap> GeneratorsOfCayleyDigraph(digraph); +[ () ] gap> digraph := CayleyDigraph(group, [(1, 2, 3, 4), (2, 5)]); Error, Digraphs: CayleyDigraph: usage, elements in the 2nd argument must all belong to the 1st argument ,