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 1cb3fb7
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 0 deletions.
28 changes: 28 additions & 0 deletions doc/isomorph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -811,3 +811,31 @@ 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</A> is an automorphism
of the digraph <A>digraph</A>. An permutation <C>g</C> on the vertices of a
digraph <C>gr</C> is an automorphism if it satisfies: <C>(u, v)</C> is an
edge of <C>gr</C> if and only if <C>(g(u), g(v))</C> is an edge of <C>gr</C>
for all vertices <C>u</C> and <C>v</C> in digraph. See also <Ref
Attr="AutomorphismGroup" Label="for a digraph" />.
<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]);
11 changes: 11 additions & 0 deletions gap/isomorph.gi
Original file line number Diff line number Diff line change
Expand Up @@ -554,3 +554,14 @@ 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)
if IsMultiDigraph(gr) then
ErrorNoReturn("Digraphs: IsDigraphAutomorphism: usage,\n",
"the first argument <gr> must not have multiple edges,");
fi;
return OnDigraphs(gr, x) = gr;
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 1cb3fb7

Please sign in to comment.