Skip to content

Commit

Permalink
Merge pull request #73 from james-d-mitchell/cayley
Browse files Browse the repository at this point in the history
Add more attributes for Cayley digraphs
  • Loading branch information
wilfwilson authored Jul 19, 2017
2 parents 7af18af + 7ce5307 commit 8da0a57
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 6 deletions.
72 changes: 70 additions & 2 deletions doc/digraph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -903,6 +903,12 @@ gap> CycleDigraph(123);

If the optional second argument <A>gens</A> is not present, then the
generators of <A>G</A> are used by default.

The digraph created by this operation belongs to the category <Ref
Filt="IsCayleyDigraph"/>, the group <A>G</A> can be recovered from the
digraph using <Ref Attr="GroupOfCayleyDigraph"/>, and the generators
<A>gens</A> can be obtained using <Ref Attr="GeneratorsOfCayleyDigraph"/>.

<Example><![CDATA[
gap> G := DihedralGroup(8);
<pc group of size 8 with 3 generators>
Expand All @@ -912,8 +918,70 @@ gap> G := DihedralGroup(IsPermGroup, 8);
Group([ (1,2,3,4), (2,4) ])
gap> CayleyDigraph(G);
<digraph with 8 vertices, 16 edges>
gap> CayleyDigraph(G, [()]);
<digraph with 8 vertices, 8 edges>]]></Example>
gap> digraph := CayleyDigraph(G, [()]);
<digraph with 8 vertices, 8 edges>
gap> GroupOfCayleyDigraph(digraph) = G;
true
gap> GeneratorsOfCayleyDigraph(digraph);
[ () ]]]></Example>
</Description>
</ManSection>
<#/GAPDoc>

<#GAPDoc Label="GroupOfCayleyDigraph">
<ManSection>
<Attr Name="GroupOfCayleyDigraph" Arg="digraph"/>
<Attr Name="SemigroupOfCayleyDigraph" Arg="digraph"/>
<Returns>A group or semigroup.</Returns>
<Description>
If <A>digraph</A> is a Cayley graph of a group <C>G</C> and
<A>digraph</A> belongs to the category <Ref Filt="IsCayleyDigraph"/>, then
<C>GroupOfCayleyDigraph</C> returns <C>G</C>.
<P/>

If <A>digraph</A> is a Cayley graph of a semigroup <C>S</C> and
<A>digraph</A> belongs to the category <Ref Filt="IsCayleyDigraph"/>, then
<C>SemigroupOfCayleyDigraph</C> returns <C>S</C>.
<P/>

See also <Ref Attr="GeneratorsOfCayleyDigraph"/>.
<Example><![CDATA[
gap> G := DihedralGroup(IsPermGroup, 8);
Group([ (1,2,3,4), (2,4) ])
gap> digraph := CayleyDigraph(G);
<digraph with 8 vertices, 16 edges>
gap> GroupOfCayleyDigraph(digraph) = G;
true
]]></Example>
</Description>
</ManSection>
<#/GAPDoc>

<#GAPDoc Label="GeneratorsOfCayleyDigraph">
<ManSection>
<Attr Name="GeneratorsOfCayleyDigraph" Arg="digraph"/>
<Returns>A list of generators.</Returns>
<Description>
If <A>digraph</A> is a Cayley graph of a group or semigroup with
respect to a set of generators <C>gens</C> and <A>digraph</A> belongs to
the category <Ref Filt="IsCayleyDigraph"/>, then
<C>GeneratorsOfCayleyDigraph</C> return the list of generators <C>gens</C>
over which <A>digraph</A> is defined.
<P/>

See also <Ref Attr="GroupOfCayleyDigraph"/>
or <Ref Attr="SemigroupOfCayleyDigraph"/>.
<Example><![CDATA[
gap> G := DihedralGroup(IsPermGroup, 8);
Group([ (1,2,3,4), (2,4) ])
gap> digraph := CayleyDigraph(G);
<digraph with 8 vertices, 16 edges>
gap> GeneratorsOfCayleyDigraph(digraph) = GeneratorsOfGroup(G);
true
gap> digraph := CayleyDigraph(G, [()]);
<digraph with 8 vertices, 8 edges>
gap> GeneratorsOfCayleyDigraph(digraph) = [()];
true]]></Example>
</Description>
</ManSection>
<#/GAPDoc>
Expand Down
2 changes: 1 addition & 1 deletion doc/z-chap2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<#Include Label="DigraphByEdges">
<#Include Label="EdgeOrbitsDigraph">
<#Include Label="DigraphByInNeighbours">
<#Include Label="CayleyDigraph">
</Section>

<Section><Heading>Changing representations</Heading>
Expand Down Expand Up @@ -72,7 +73,6 @@
<#Include Label="CompleteMultipartiteDigraph">
<#Include Label="CycleDigraph">
<#Include Label="EmptyDigraph">
<#Include Label="CayleyDigraph">
<#Include Label="JohnsonDigraph">
</Section>

Expand Down
6 changes: 6 additions & 0 deletions doc/z-chap4.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,10 @@
<#Include Label="DigraphDegeneracy">
<#Include Label="DigraphDegeneracyOrdering">
</Section>

<Section><Heading>Cayley graphs of groups</Heading>
<#Include Label="GroupOfCayleyDigraph">
<#Include Label="GeneratorsOfCayleyDigraph">
</Section>

</Chapter>
4 changes: 4 additions & 0 deletions gap/digraph.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
13 changes: 10 additions & 3 deletions gap/digraph.gi
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,7 @@ function(G, gens)
if not IsFinite(G) then
ErrorNoReturn("Digraphs: CayleyDigraph: usage,\n",
"the first argument <G> 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 <gens> must ",
"all belong to the 1st argument <G>,");
Expand All @@ -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);

Expand All @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions tst/standard/digraph.tst
Original file line number Diff line number Diff line change
Expand Up @@ -1276,6 +1276,12 @@ gap> IsCayleyDigraph(digraph);
true
gap> IsDigraph(digraph);
true
gap> digraph := CayleyDigraph(group, [()]);
<digraph with 8 vertices, 8 edges>
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 <gens> must all belong to the 1st argument <G>,
Expand Down

0 comments on commit 8da0a57

Please sign in to comment.