From ec5fccc5a633aa9b69b38d4149f103fa6f65fb00 Mon Sep 17 00:00:00 2001 From: ChristopherRussell Date: Wed, 24 Jan 2018 12:27:28 +0000 Subject: [PATCH 1/2] add method IsDigraphAutomorphism This operation takes a digraph and a permutation and returns true if the permutation is an automorphism of the digraph. --- doc/isomorph.xml | 28 ++++++++++++++++++++++++++++ gap/isomorph.gd | 2 ++ gap/isomorph.gi | 11 +++++++++++ tst/standard/isomorph.tst | 21 +++++++++++++++++++++ 4 files changed, 62 insertions(+) diff --git a/doc/isomorph.xml b/doc/isomorph.xml index b47c0b781..9ba444dd8 100644 --- a/doc/isomorph.xml +++ b/doc/isomorph.xml @@ -811,3 +811,31 @@ gap> OutNeighbours(canon); <#/GAPDoc> + +<#GAPDoc Label="IsDigraphAutomorphism"> + + + true or false. + + This operation returns true if the permutation x is an automorphism + of the digraph digraph. An permutation g on the vertices of a + digraph gr is an automorphism if it satisfies: (u, v) is an + edge of gr if and only if (g(u), g(v)) is an edge of gr + for all vertices u and v in digraph. See also . + digraph := Digraph([[1], [1, 2], [1, 3]]); + +gap> IsDigraphAutomorphism(digraph, (1, 2, 3)); +false +gap> IsDigraphAutomorphism(digraph, (2, 3)); +true +gap> IsDigraphAutomorphism(digraph, (1, 4)); +false +gap> IsDigraphAutomorphism(digraph, ()); +true +]]> + + +<#/GAPDoc> diff --git a/gap/isomorph.gd b/gap/isomorph.gd index 3fc6aa272..b95f65e7a 100644 --- a/gap/isomorph.gd +++ b/gap/isomorph.gd @@ -43,3 +43,5 @@ DeclareGlobalFunction("DigraphsUseNauty"); BindGlobal("DIGRAPHS_UsingBliss", true); DeclareGlobalFunction("DIGRAPHS_ValidateVertexColouring"); + +DeclareOperation("IsDigraphAutomorphism", [IsDigraph, IsPerm]); diff --git a/gap/isomorph.gi b/gap/isomorph.gi index 9777e82bf..bb0282d20 100644 --- a/gap/isomorph.gi +++ b/gap/isomorph.gi @@ -554,3 +554,14 @@ function(n, partition, method) " is the colour of vertex i; in the second\n", "form, is the list of vertices with colour i,"); end); + +InstallMethod(IsDigraphAutomorphism, +"for a digraph and a permutation", +[IsDigraph, IsPerm], +function(gr, x) + if IsMultiDigraph(gr) then + ErrorNoReturn("Digraphs: IsDigraphAutomorphism: usage,\n", + "the first argument must not have multiple edges,"); + fi; + return OnDigraphs(gr, x) = gr; +end); diff --git a/tst/standard/isomorph.tst b/tst/standard/isomorph.tst index c107273bd..b974c17d2 100644 --- a/tst/standard/isomorph.tst +++ b/tst/standard/isomorph.tst @@ -816,6 +816,27 @@ gap> if not nauty then > DigraphsUseBliss(); > fi; +# IsDigraphAutomorphism +gap> gr1 := Digraph([[1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4], [1]]); + +gap> IsDigraphAutomorphism(gr1, (1, 2, 3)); +false +gap> IsDigraphAutomorphism(gr1, (2, 3)); +true +gap> IsDigraphAutomorphism(gr1, ()); +true +gap> gr2 := Digraph([[1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 2, 3, 4, 5, 6]]); + +gap> IsDigraphAutomorphism(gr2, (2, 3, 4, 5)); +true +gap> IsDigraphAutomorphism(gr2, (1, 6)); +false +gap> IsDigraphAutomorphism(gr2, (2, 3, 6)); +false +gap> IsDigraphAutomorphism(Digraph([[1, 1], [1, 1, 2], [1, 2, 2, 3]]), ()); +Error, Digraphs: IsDigraphAutomorphism: usage, +the first argument must not have multiple edges, + #T# DIGRAPHS_UnbindVariables gap> Unbind(G); gap> Unbind(canon); From e9a2af103c5e7946aaa98db00085c13af323b1d4 Mon Sep 17 00:00:00 2001 From: Wilf Wilson Date: Wed, 24 Jan 2018 16:36:16 +0000 Subject: [PATCH 2/2] Update isomorph.xml --- doc/isomorph.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/isomorph.xml b/doc/isomorph.xml index 9ba444dd8..38baff364 100644 --- a/doc/isomorph.xml +++ b/doc/isomorph.xml @@ -822,7 +822,7 @@ gap> OutNeighbours(canon); of the digraph digraph. An permutation g on the vertices of a digraph gr is an automorphism if it satisfies: (u, v) is an edge of gr if and only if (g(u), g(v)) is an edge of gr - for all vertices u and v in digraph. See also u and v in gr. See also . digraph := Digraph([[1], [1, 2], [1, 3]]);