Skip to content

Commit

Permalink
add method IsDigraphAutomorphism
Browse files Browse the repository at this point in the history
This operation takes a digraph and a permutation and returns true if the
permutation is an automorphism of the digraph.
  • Loading branch information
ChristopherRussell committed Jan 24, 2018
1 parent 51e34ad commit 0e5ecc1
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 0 deletions.
23 changes: 23 additions & 0 deletions doc/isomorph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -811,3 +811,26 @@ gap> OutNeighbours(canon);
</Description>
</ManSection>
<#/GAPDoc>

<#GAPDoc Label="IsDigraphAutomorphism">
<ManSection>
<Oper Name="IsDigraphAutomorphism" Label="for a digraph and permutation" Arg="digraph, x"/>
<Returns><K>true</K> or <K>false</K>.</Returns>
<Description>
This operation returns true if the permutation <A>x</x> is an automorphism
of the digraph <A>digraph</A>.
<Example><![CDATA[
gap> digraph := Digraph([[1], [1, 2], [1, 3]]);
<digraph with 3 vertices, 5 edges>
gap> IsDigraphAutomorphism(digraph, (1, 2, 3));
false
gap> IsDigraphAutomorphism(digraph, (2, 3));
true
gap> IsDigraphAutomorphism(digraph, (1, 4));
false
gap> IsDigraphAutomorphism(digraph, ());
true
]]></Example>
</Description>
</ManSection>
<#/GAPDoc>
2 changes: 2 additions & 0 deletions gap/isomorph.gd
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,5 @@ DeclareGlobalFunction("DigraphsUseNauty");
BindGlobal("DIGRAPHS_UsingBliss", true);

DeclareGlobalFunction("DIGRAPHS_ValidateVertexColouring");

DeclareOperation("IsDigraphAutomorphism", [IsDigraph, IsPerm]);
9 changes: 9 additions & 0 deletions gap/isomorph.gi
Original file line number Diff line number Diff line change
Expand Up @@ -554,3 +554,12 @@ function(n, partition, method)
"<partition[i]> is the colour of vertex i; in the second\n",
"form, <partition[i]> is the list of vertices with colour i,");
end);

InstallMethod(IsDigraphAutomorphism,
"for a digraph and a permutation",
[IsDigraph, IsPerm],
function(gr, x)
local E;
E := DigraphEdges(gr);
return ForAll(E, e -> [e[1] ^ x, e[2] ^ x] in E);
end);
18 changes: 18 additions & 0 deletions tst/standard/isomorph.tst
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,24 @@ gap> if not nauty then
> DigraphsUseBliss();
> fi;

# IsDigraphAutomorphism
gap> gr1 := Digraph([[1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4], [1]]);
<digraph with 4 vertices, 13 edges>
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]]);
<digraph with 6 vertices, 15 edges>
gap> IsDigraphAutomorphism(gr2, (2, 3, 4, 5));
true
gap> IsDigraphAutomorphism(gr2, (1, 6));
false
gap> IsDigraphAutomorphism(gr2, (6, 7, 8));
false

#T# DIGRAPHS_UnbindVariables
gap> Unbind(G);
gap> Unbind(canon);
Expand Down

0 comments on commit 0e5ecc1

Please sign in to comment.