Skip to content

Commit 6a4ab85

Browse files
wilfwilsonjames-d-mitchell
authored andcommitted
grape: add vertex & edge labels to Cayley digraphs
This was originally Jan de Beule's idea.
1 parent 28946b8 commit 6a4ab85

File tree

3 files changed

+25
-8
lines changed

3 files changed

+25
-8
lines changed

doc/grape.xml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#############################################################################
22
##
33
#W grape.xml
4-
#Y Copyright (C) 2014-19 James D. Mitchell
4+
#Y Copyright (C) 2014-21 James D. Mitchell
55
##
66
## Licensing information can be found in the README file of this package.
77
##
@@ -51,12 +51,19 @@ true]]></Example>
5151
<Description>
5252
Let <A>G</A> be any group and let <A>gens</A> be a list of elements of
5353
<A>G</A>. This operation returns an immutable digraph that corresponds to
54-
the Cayley graph of <A>G</A> with respect
55-
<A>gens</A>. The vertices are the elements of <A>G</A>. There exists an edge
56-
from the vertex <C>u</C> to the vertex <C>v</C> if and only if there exists
57-
a generator <C>g</C> in <A>gens</A> such that <C>x * g = y</C>. <P/>
54+
the Cayley graph of <A>G</A> with respect to <A>gens</A>. <P/>
5855

59-
<!-- FIXME What is the correspondence between vertices and elements? -->
56+
The vertices of the digraph correspond to the elements of <A>G</A>,
57+
in the order given by <C>AsList(<A>G</A>)</C>.
58+
There exists an edge from vertex <C>u</C> to vertex <C>v</C>
59+
if and only if there exists a generator <C>g</C> in <A>gens</A>
60+
such that <C>AsList(<A>G</A>)[u] * g = AsList(<A>G</A>)[v]</C>. <P/>
61+
62+
The labels of the vertices <C>u</C>, <C>v</C>, and the edge <C>[u, v]</C>
63+
are the corresponding elements <C>AsList(<A>G</A>)[u]</C>,
64+
<C>AsList(<A>G</A>)[v]</C>, and generator <C>g</C>, respectively;
65+
see <Ref Oper="DigraphVertexLabel"/> and <Ref Oper="DigraphEdgeLabel"/>.
66+
<P/>
6067

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

gap/grape.gi

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#############################################################################
22
##
33
## grape.gi
4-
## Copyright (C) 2019 James D. Mitchell
4+
## Copyright (C) 2019-21 James D. Mitchell
55
##
66
## Licensing information can be found in the README file of this package.
77
##
@@ -111,6 +111,8 @@ function(G, gens)
111111
SetFilterObj(D, IsCayleyDigraph);
112112
SetGroupOfCayleyDigraph(D, G);
113113
SetGeneratorsOfCayleyDigraph(D, gens);
114+
SetDigraphEdgeLabels(D, ListWithIdenticalEntries(Size(G), gens));
115+
SetDigraphVertexLabels(D, AsList(G));
114116

115117
return D;
116118
end);

tst/standard/grape.tst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#############################################################################
22
##
33
#W standard/grape.tst
4-
#Y Copyright (C) 2019 James D. Mitchell
4+
#Y Copyright (C) 2019-21 James D. Mitchell
55
##
66
## Licensing information can be found in the README file of this package.
77
##
@@ -18,6 +18,14 @@ gap> group := DihedralGroup(8);
1818
<pc group of size 8 with 3 generators>
1919
gap> digraph := CayleyDigraph(group);
2020
<immutable digraph with 8 vertices, 24 edges>
21+
gap> DigraphVertexLabels(digraph) = AsList(group);
22+
true
23+
gap> DigraphEdgeLabels(digraph) =
24+
> ListWithIdenticalEntries(Size(group), GeneratorsOfGroup(group));
25+
true
26+
gap> ForAll(DigraphEdges(digraph), e -> AsList(group)[e[1]]
27+
> * DigraphEdgeLabel(digraph, e[1], e[2]) = AsList(group)[e[2]]);
28+
true
2129
gap> group := DihedralGroup(IsPermGroup, 8);
2230
Group([ (1,2,3,4), (2,4) ])
2331
gap> digraph := CayleyDigraph(group);

0 commit comments

Comments
 (0)