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

Allow specifying vertex colours in IsDigraphHomomorphism etc. #283

Merged
merged 6 commits into from Jan 24, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
64 changes: 63 additions & 1 deletion doc/grahom.xml
Expand Up @@ -565,9 +565,13 @@ gap> EmbeddingsDigraphs(D1, D2);
<#GAPDoc Label="IsDigraphHomomorphism">
<ManSection>
<Oper Name="IsDigraphHomomorphism" Arg="src, ran, x"/>
<Oper Name="IsDigraphHomomorphism" Arg="src, ran, x, col1, col2"/>
<Oper Name="IsDigraphEpimorphism" Arg="src, ran, x"/>
<Oper Name="IsDigraphEpimorphism" Arg="src, ran, x, col1, col2"/>
<Oper Name="IsDigraphMonomorphism" Arg="src, ran, x"/>
<Oper Name="IsDigraphMonomorphism" Arg="src, ran, x, col1, col2"/>
<Oper Name="IsDigraphEndomorphism" Arg="digraph, x"/>
<Oper Name="IsDigraphEndomorphism" Arg="digraph, x, col"/>
<Returns><K>true</K> or <K>false</K>.</Returns>
<Description>
<C>IsDigraphHomomorphism</C> returns <K>true</K> if the permutation
Expand Down Expand Up @@ -603,6 +607,22 @@ gap> EmbeddingsDigraphs(D1, D2);
</List>
See also <Ref Func="GeneratorsOfEndomorphismMonoid"/>.<P/>

If <A>col1</A> and <A>col2</A>, or <A>col</A>, are given then they must
represent vertex colourings; see <Ref Oper="AutomorphismGroup" Label="for a
digraph and a homogeneous list"/> for details of the permissible values for
these argument. The homomorphism must then also have the property:

<List>
<Item>
<C>col[i] = col[i ^ x]</C> for all vertices <C>i</C> of <A>digraph</A>,
in the case of <C>IsDigraphEndomorphism</C>.</Item>
<Item>
<C>col1[i] = col2[i ^ x]</C> for all vertices <C>i</C> of <A>src</A>,
in the cases of the other operations.</Item>
</List>

See also <Ref Oper="DigraphsRespectsColouring"/>.

<Example><![CDATA[
gap> src := Digraph([[1], [1, 2], [1, 3]]);
<immutable digraph with 3 vertices, 5 edges>
Expand All @@ -616,8 +636,18 @@ gap> IsDigraphHomomorphism(src, ran, Transformation([3, 3, 3]));
false
gap> IsDigraphHomomorphism(src, src, Transformation([3, 3, 3]));
true
gap> IsDigraphHomomorphism(src, ran, Transformation([1, 2, 2]),
> [1, 2, 2], [1, 2]);
true
gap> IsDigraphHomomorphism(src, ran, Transformation([1, 2, 2]),
> [2, 1, 1], [1, 2]);
false
gap> IsDigraphEndomorphism(src, Transformation([3, 3, 3]));
true
gap> IsDigraphEndomorphism(src, Transformation([3, 3, 3]), [1, 1, 1]);
true
gap> IsDigraphEndomorphism(src, Transformation([3, 3, 3]), [1, 1, 2]);
false
gap> IsDigraphEpimorphism(src, ran, Transformation([3, 3, 3]));
false
gap> IsDigraphMonomorphism(src, ran, Transformation([1, 2, 2]));
Expand All @@ -633,11 +663,13 @@ true]]></Example>
<#GAPDoc Label="IsDigraphEmbedding">
<ManSection>
<Oper Name="IsDigraphEmbedding" Arg="src, ran, x"/>
<Oper Name="IsDigraphEmbedding" Arg="src, ran, x, col1, col2"/>
<Returns><K>true</K> or <K>false</K>.</Returns>
<Description>
<C>IsDigraphEmbedding</C> returns <K>true</K> if the permutation
or transformation <A>x</A> is a embedding of the digraph
<A>src</A> into the digraph <A>ran</A>.
<A>src</A> into the digraph <A>ran</A>, while respecting the colourings
<A>col1</A> and <A>col2</A> if given.
<P/>

A permutation or transformation <A>x</A> is a <E>embedding</E> of a digraph
Expand All @@ -657,6 +689,10 @@ gap> IsDigraphMonomorphism(src, ran, ());
true
gap> IsDigraphEmbedding(src, ran, ());
true
gap> IsDigraphEmbedding(src, ran, (), [2, 1], [2, 1, 1]);
true
gap> IsDigraphEmbedding(src, ran, (), [2, 1], [1, 2, 1]);
false
gap> ran := Digraph([[1, 2], [1, 2], [1, 3]]);
<immutable digraph with 3 vertices, 6 edges>
gap> IsDigraphMonomorphism(src, ran, IdentityTransformation);
Expand Down Expand Up @@ -710,3 +746,29 @@ true
</Description>
</ManSection>
<#/GAPDoc>

<#GAPDoc Label="DigraphsRespectsColouring">
<ManSection>
<Oper Name="DigraphsRespectsColouring" Arg="src, ran, x, col1, col2"/>
<Returns> <K>true</K> or <K>false</K>. </Returns>
<Description>
The operation <C>DigraphsRespectsColouring</C> verifies whether or not
the permutation or transformation <A>x</A> respects the vertex colourings
<A>col1</A> and <A>col2</A> of the digraphs <A>src</A> and <A>range</A>.
That is, <C>DigraphsRespectsColouring</C> returns true if and only if for
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"true" -> "<K>true</K>"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all vertices <C>i</C> of <A>src</A>, <C>col1[i] = col2[i ^ x]</C>.
<P/>

<Example><![CDATA[
gap> src := Digraph([[1], [1, 2]]);
<immutable digraph with 2 vertices, 3 edges>
gap> ran := Digraph([[1], [1, 2], [1, 3]]);
<immutable digraph with 3 vertices, 5 edges>
gap> DigraphsRespectsColouring(src, ran, (1, 2), [2, 1], [1, 2, 1]);
true
gap> DigraphsRespectsColouring(src, ran, (1, 2), [2, 1], [2, 1, 1]);
false
]]></Example>
</Description>
</ManSection>
<#/GAPDoc>
25 changes: 25 additions & 0 deletions doc/isomorph.xml
Expand Up @@ -753,7 +753,9 @@ gap> OutNeighbours(canon);
<#GAPDoc Label="IsDigraphAutomorphism">
<ManSection>
<Oper Name="IsDigraphIsomorphism" Arg="src, ran, x"/>
<Oper Name="IsDigraphIsomorphism" Arg="src, ran, x, col1, col2"/>
<Oper Name="IsDigraphAutomorphism" Arg="digraph, x"/>
<Oper Name="IsDigraphAutomorphism" Arg="digraph, x, col"/>
<Returns><K>true</K> or <K>false</K>.</Returns>
<Description>
<C>IsDigraphIsomorphism</C> returns <K>true</K> if the permutation or
Expand Down Expand Up @@ -783,6 +785,21 @@ gap> OutNeighbours(canon);
</List>
See also <Ref Attr="AutomorphismGroup" Label="for a digraph"
/>.<P/>


If <A>col1</A> and <A>col2</A>, or <A>col</A>, are given, then they must
represent vertex colourings; see <Ref Oper="AutomorphismGroup" Label="for a
digraph and a homogeneous list"/> for details of the permissible values for
these arguments. The homomorphism must then also have the property:

<List>
<Item>
<C>col1[i] = col2[i ^ x]</C> for all vertices <C>i</C> of <A>src</A>,
for <C>IsDigraphIsomorphism</C>. </Item>
<Item>
<C>col[i] = col[i ^ x]</C> for all vertices <C>i</C> of <A>digraph</A>,
for <C>IsDigraphAutomorphism</C>. </Item>
</List>

For some digraphs, it can be faster to use <C>IsDigraphAutomorphism</C>
than to test membership in the automorphism group of <A>digraph</A>.
Expand All @@ -794,6 +811,10 @@ gap> IsDigraphAutomorphism(src, (1, 2, 3));
false
gap> IsDigraphAutomorphism(src, (2, 3));
true
gap> IsDigraphAutomorphism(src, (2, 3), [2, 1, 1]);
true
gap> IsDigraphAutomorphism(src, (2, 3), [2, 2, 1]);
false
gap> IsDigraphAutomorphism(src, (2, 3)(4, 5));
false
gap> IsDigraphAutomorphism(src, (1, 4));
Expand All @@ -810,6 +831,10 @@ gap> IsDigraphIsomorphism(ran, src, (1, 2));
true
gap> IsDigraphIsomorphism(src, Digraph([[3], [1, 3], [2]]), (1, 2, 3));
false
gap> IsDigraphIsomorphism(src, ran, (1, 2), [1, 2, 3], [2, 1, 3]);
true
gap> IsDigraphIsomorphism(src, ran, (1, 2), [1, 2, 2], [2, 1, 3]);
false
]]></Example>
</Description>
</ManSection>
Expand Down
1 change: 1 addition & 0 deletions doc/z-chap6.xml
Expand Up @@ -62,6 +62,7 @@ from} $E_a$ \emph{to} $E_b$. In this case we say that $E_a$ and $E_b$ are
<#Include Label="EmbeddingsDigraphs">
<#Include Label="IsDigraphHomomorphism">
<#Include Label="IsDigraphEmbedding">
<#Include Label="DigraphsRespectsColouring">
<#Include Label="GeneratorsOfEndomorphismMonoid">
<#Include Label="DigraphColouring">
<#Include Label="DigraphGreedyColouring">
Expand Down
29 changes: 29 additions & 0 deletions gap/grahom.gd
Expand Up @@ -43,23 +43,52 @@ DeclareOperation("IsDigraphEndomorphism", [IsDigraph, IsTransformation]);
DeclareOperation("IsDigraphHomomorphism",
[IsDigraph, IsDigraph, IsTransformation]);

DeclareOperation("IsDigraphEndomorphism",
[IsDigraph, IsTransformation, IsList]);
DeclareOperation("IsDigraphHomomorphism",
[IsDigraph, IsDigraph, IsTransformation, IsList, IsList]);

DeclareOperation("IsDigraphEndomorphism", [IsDigraph, IsPerm]);
DeclareOperation("IsDigraphHomomorphism",
[IsDigraph, IsDigraph, IsPerm]);

DeclareOperation("IsDigraphEndomorphism",
[IsDigraph, IsPerm, IsList]);
DeclareOperation("IsDigraphHomomorphism",
[IsDigraph, IsDigraph, IsPerm, IsList, IsList]);

DeclareOperation("IsDigraphEpimorphism",
[IsDigraph, IsDigraph, IsTransformation]);
DeclareOperation("IsDigraphMonomorphism",
[IsDigraph, IsDigraph, IsTransformation]);
DeclareOperation("IsDigraphEmbedding",
[IsDigraph, IsDigraph, IsTransformation]);

DeclareOperation("IsDigraphEpimorphism",
[IsDigraph, IsDigraph, IsTransformation, IsList, IsList]);
DeclareOperation("IsDigraphMonomorphism",
[IsDigraph, IsDigraph, IsTransformation, IsList, IsList]);
DeclareOperation("IsDigraphEmbedding",
[IsDigraph, IsDigraph, IsTransformation, IsList, IsList]);

DeclareOperation("IsDigraphEpimorphism",
[IsDigraph, IsDigraph, IsPerm]);
DeclareOperation("IsDigraphMonomorphism",
[IsDigraph, IsDigraph, IsPerm]);
DeclareOperation("IsDigraphEmbedding",
[IsDigraph, IsDigraph, IsPerm]);

DeclareOperation("IsDigraphEpimorphism",
[IsDigraph, IsDigraph, IsPerm, IsList, IsList]);
DeclareOperation("IsDigraphMonomorphism",
[IsDigraph, IsDigraph, IsPerm, IsList, IsList]);
DeclareOperation("IsDigraphEmbedding",
[IsDigraph, IsDigraph, IsPerm, IsList, IsList]);

DeclareOperation("IsDigraphColouring", [IsDigraph, IsList]);
DeclareOperation("IsDigraphColouring", [IsDigraph, IsTransformation]);

DeclareOperation("DigraphsRespectsColouring",
[IsDigraph, IsDigraph, IsTransformation, IsList, IsList]);
DeclareOperation("DigraphsRespectsColouring",
[IsDigraph, IsDigraph, IsPerm, IsList, IsList]);