diff --git a/doc/grahom.xml b/doc/grahom.xml
index ab261bbc0..79c1345c5 100644
--- a/doc/grahom.xml
+++ b/doc/grahom.xml
@@ -541,3 +541,47 @@ false]]>
<#/GAPDoc>
+
+<#GAPDoc Label="IsDigraphColouring">
+
+
+
+ true or false.
+
+ The operation IsDigraphColouring verifies whether or not
+ the list list describes a proper colouring of the digraph
+ digraph.
+
+
+ A list list describes a proper colouring of a digraph
+ digraph if list consists of positive integers, the length of
+ list equals the number of vertices in digraph, and for any
+ vertices u, v of digraph if u and v are adjacent,
+ then list[u] >< list[v].
+
+
+ A transformation t describes a proper colouring of a digraph
+ digraph, if ImageListOfTransformation(t,
+ DigraphNrVertices(digraph)) is a proper colouring of
+ digraph.
+
+ See also .
+
+ D := JohnsonDigraph(5, 3);
+
+gap> IsDigraphColouring(D, [1, 2, 3, 3, 2, 1, 4, 5, 6, 7]);
+true
+gap> IsDigraphColouring(D, [1, 2, 3, 3, 2, 1, 2, 5, 6, 7]);
+false
+gap> IsDigraphColouring(D, [1, 2, 3, 3, 2, 1, 2, 5, 6, -1]);
+false
+gap> IsDigraphColouring(D, [1, 2, 3]);
+false
+gap> IsDigraphColouring(D, IdentityTransformation);
+true
+]]>
+
+
+<#/GAPDoc>
diff --git a/doc/z-chap6.xml b/doc/z-chap6.xml
index 19fbf1e0a..a0cbcf193 100644
--- a/doc/z-chap6.xml
+++ b/doc/z-chap6.xml
@@ -40,6 +40,7 @@ from} $E_a$ \emph{to} $E_b$. In this case we say that $E_a$ and $E_b$ are
<#Include Label="IsomorphismDigraphsColours">
<#Include Label="RepresentativeOutNeighbours">
<#Include Label="IsDigraphAutomorphism">
+ <#Include Label="IsDigraphColouring">
Homomorphisms of digraphs
diff --git a/gap/grahom.gd b/gap/grahom.gd
index 94c9fd6e4..b5d60c4c3 100644
--- a/gap/grahom.gd
+++ b/gap/grahom.gd
@@ -54,3 +54,6 @@ DeclareOperation("IsDigraphMonomorphism",
[IsDigraph, IsDigraph, IsPerm]);
DeclareOperation("IsDigraphEmbedding",
[IsDigraph, IsDigraph, IsPerm]);
+
+DeclareOperation("IsDigraphColouring", [IsDigraph, IsList]);
+DeclareOperation("IsDigraphColouring", [IsDigraph, IsTransformation]);
diff --git a/gap/grahom.gi b/gap/grahom.gi
index cc318581a..84a2970b8 100644
--- a/gap/grahom.gi
+++ b/gap/grahom.gi
@@ -549,3 +549,31 @@ function(src, ran, x)
od;
return true;
end);
+
+InstallMethod(IsDigraphColouring, "for a digraph and a list",
+[IsDigraph, IsHomogeneousList],
+function(digraph, colours)
+ local n, out, v, w;
+ n := DigraphNrVertices(digraph);
+ if Length(colours) <> n or ForAny(colours, x -> not IsPosInt(x)) then
+ return false;
+ fi;
+ out := OutNeighbours(digraph);
+ for v in DigraphVertices(digraph) do
+ for w in out[v] do
+ if colours[w] = colours[v] then
+ return false;
+ fi;
+ od;
+ od;
+ return true;
+end);
+
+InstallMethod(IsDigraphColouring, "for a digraph and a transformation",
+[IsDigraph, IsTransformation],
+function(digraph, t)
+ local n;
+ n := DigraphNrVertices(digraph);
+ return IsDigraphColouring(digraph,
+ ImageListOfTransformation(t, n));
+end);
diff --git a/tst/standard/grahom.tst b/tst/standard/grahom.tst
index 0b9214e0d..a219e2a18 100644
--- a/tst/standard/grahom.tst
+++ b/tst/standard/grahom.tst
@@ -1084,6 +1084,20 @@ true
gap> IsDigraphEmbedding(src, ran, ());
false
+# IsDigraphColouring
+gap> D := JohnsonDigraph(5, 3);
+
+gap> IsDigraphColouring(D, [1, 2, 3, 3, 2, 1, 4, 5, 6, 7]);
+true
+gap> IsDigraphColouring(D, [1, 2, 3, 3, 2, 1, 2, 5, 6, 7]);
+false
+gap> IsDigraphColouring(D, [1, 2, 3, 3, 2, 1, 2, 5, 6, -1]);
+false
+gap> IsDigraphColouring(D, [1, 2, 3]);
+false
+gap> IsDigraphColouring(D, IdentityTransformation);
+true
+
#T# DIGRAPHS_UnbindVariables
gap> Unbind(edges);
gap> Unbind(epis);