diff --git a/doc/oper.xml b/doc/oper.xml
index 6b5398e6f..ae5e20c45 100644
--- a/doc/oper.xml
+++ b/doc/oper.xml
@@ -320,8 +320,10 @@ true
If digraph belongs to , then the
vertices are added directly to digraph, which is changed in-place.
- If digraph belongs to , then the
- result is returned as an immutable digraph.
+ If digraph belongs to , then
+ digraph itself is returned if no vertices are added
+ (i.e. m=0 or labels is empty), otherwise
+ the result is returned as a new immutable digraph.
MakeImmutable(DigraphAddVertices(DigraphMutableCopy(D),
- labels)));
+function(D, labels)
+ if IsEmpty(labels) then
+ return D;
+ fi;
+ return MakeImmutable(DigraphAddVertices(DigraphMutableCopy(D), labels));
+end);
InstallMethod(DigraphAddVertices, "for a mutable digraph and an integer",
[IsMutableDigraph, IsInt],
@@ -79,7 +83,12 @@ end);
InstallMethod(DigraphAddVertices, "for an immutable digraph and an integer",
[IsImmutableDigraph, IsInt],
-{D, m} -> MakeImmutable(DigraphAddVertices(DigraphMutableCopy(D), m)));
+function(D, m)
+ if m = 0 then
+ return D;
+ fi;
+ return MakeImmutable(DigraphAddVertices(DigraphMutableCopy(D), m));
+end);
# Included for backwards compatibility, even though the 2nd arg is redundant.
# See https://github.com/gap-packages/Digraphs/issues/264
diff --git a/tst/standard/oper.tst b/tst/standard/oper.tst
index 3fc7f5efb..7ad336117 100644
--- a/tst/standard/oper.tst
+++ b/tst/standard/oper.tst
@@ -617,17 +617,9 @@ gap> DigraphVertexLabels(gr2);
[ Alt( [ 1 .. 5 ] ), Sym( [ 1 .. 2 ] ), Group(()) ]
gap> DigraphAddVertices(gr2, -1);
Error, the 2nd argument must be a non-negative integer,
-gap> gr3 := DigraphAddVertices(gr2, 0);
-
-gap> IsIdenticalObj(gr2, gr3);
-false
-gap> gr2 = gr3;
+gap> IsIdenticalObj(gr2, DigraphAddVertices(gr2, 0));
true
-gap> gr3 := DigraphAddVertices(gr2, []);
-
-gap> IsIdenticalObj(gr2, gr3);
-false
-gap> gr2 = gr3;
+gap> IsIdenticalObj(gr2, DigraphAddVertices(gr2, []));
true
# DigraphAddVertices (redundant three-argument version)