From b7d39ce489b18f82aff3696e3edd6cc9c2389452 Mon Sep 17 00:00:00 2001 From: Wilf Wilson Date: Wed, 20 Jan 2021 14:43:13 +0000 Subject: [PATCH] grape: add vertex & edge labels to Cayley digraphs This was originally Jan de Beule's idea. --- doc/grape.xml | 19 +++++++++++++------ gap/grape.gi | 4 +++- tst/standard/grape.tst | 10 +++++++++- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/doc/grape.xml b/doc/grape.xml index e9d98c5e9..012033761 100644 --- a/doc/grape.xml +++ b/doc/grape.xml @@ -1,7 +1,7 @@ ############################################################################# ## #W grape.xml -#Y Copyright (C) 2014-19 James D. Mitchell +#Y Copyright (C) 2014-21 James D. Mitchell ## ## Licensing information can be found in the README file of this package. ## @@ -51,12 +51,19 @@ true]]> Let G be any group and let gens be a list of elements of G. This operation returns an immutable digraph that corresponds to - the Cayley graph of G with respect - gens. The vertices are the elements of G. There exists an edge - from the vertex u to the vertex v if and only if there exists - a generator g in gens such that x * g = y.

+ the Cayley graph of G with respect to gens.

- + The vertices of the digraph correspond to the elements of G, + in the order given by AsList(G). + There exists an edge from vertex u to vertex v + if and only if there exists a generator g in gens + such that AsList(G)[u] * g = AsList(G)[v].

+ + The labels of the vertices u, v, and the edge [u, v] + are the corresponding elements AsList(G)[u], + AsList(G)[v], and generator g, respectively; + see and . +

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

diff --git a/gap/grape.gi b/gap/grape.gi index d550a6546..c39035203 100644 --- a/gap/grape.gi +++ b/gap/grape.gi @@ -1,7 +1,7 @@ ############################################################################# ## ## grape.gi -## Copyright (C) 2019 James D. Mitchell +## Copyright (C) 2019-21 James D. Mitchell ## ## Licensing information can be found in the README file of this package. ## @@ -111,6 +111,8 @@ function(G, gens) SetFilterObj(D, IsCayleyDigraph); SetGroupOfCayleyDigraph(D, G); SetGeneratorsOfCayleyDigraph(D, gens); + SetDigraphEdgeLabels(D, ListWithIdenticalEntries(Size(G), gens)); + SetDigraphVertexLabels(D, AsList(G)); return D; end); diff --git a/tst/standard/grape.tst b/tst/standard/grape.tst index 4cf6d0ec1..1a679e317 100644 --- a/tst/standard/grape.tst +++ b/tst/standard/grape.tst @@ -1,7 +1,7 @@ ############################################################################# ## #W standard/grape.tst -#Y Copyright (C) 2019 James D. Mitchell +#Y Copyright (C) 2019-21 James D. Mitchell ## ## Licensing information can be found in the README file of this package. ## @@ -18,6 +18,14 @@ gap> group := DihedralGroup(8); gap> digraph := CayleyDigraph(group); +gap> DigraphVertexLabels(digraph) = AsList(group); +true +gap> DigraphEdgeLabels(digraph) = +> ListWithIdenticalEntries(Size(group), GeneratorsOfGroup(group)); +true +gap> ForAll(DigraphEdges(digraph), e -> AsList(group)[e[1]] +> * DigraphEdgeLabel(digraph, e[1], e[2]) = AsList(group)[e[2]]); +true gap> group := DihedralGroup(IsPermGroup, 8); Group([ (1,2,3,4), (2,4) ]) gap> digraph := CayleyDigraph(group);