Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add method IsDigraphAutomorphism #106

Merged
merged 2 commits into from
Jan 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 <C>gr</C>. 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);
21 changes: 21 additions & 0 deletions tst/standard/isomorph.tst
Original file line number Diff line number Diff line change
Expand Up @@ -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]]);
<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, (2, 3, 6));
false
gap> IsDigraphAutomorphism(Digraph([[1, 1], [1, 1, 2], [1, 2, 2, 3]]), ());
Error, Digraphs: IsDigraphAutomorphism: usage,
the first argument <gr> must not have multiple edges,

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