File tree Expand file tree Collapse file tree 3 files changed +18
-15
lines changed Expand file tree Collapse file tree 3 files changed +18
-15
lines changed Original file line number Diff line number Diff line change @@ -320,8 +320,10 @@ true
320
320
321
321
If <A >digraph</A > belongs to <Ref Filt =" IsMutableDigraph" />, then the
322
322
vertices are added directly to <A >digraph</A >, which is changed in-place.
323
- If <A >digraph</A > belongs to <Ref Filt =" IsImmutableDigraph" />, then the
324
- result is returned as an immutable digraph.
323
+ If <A >digraph</A > belongs to <Ref Filt =" IsImmutableDigraph" />, then
324
+ <A >digraph</A > itself is returned if no vertices are added
325
+ (i.e. <C ><A >m</A >=0</C > or <A >labels</A > is empty), otherwise
326
+ the result is a new immutable digraph.
325
327
<P />
326
328
327
329
<Example ><![CDATA[
Original file line number Diff line number Diff line change 63
63
64
64
InstallMethod(DigraphAddVertices, " for an immutable digraph and list" ,
65
65
[ IsImmutableDigraph, IsList] ,
66
- { D, labels} -> MakeImmutable(DigraphAddVertices(DigraphMutableCopy(D),
67
- labels)));
66
+ function (D, labels )
67
+ if IsEmpty(labels) then
68
+ return D;
69
+ fi ;
70
+ return MakeImmutable(DigraphAddVertices(DigraphMutableCopy(D), labels));
71
+ end );
68
72
69
73
InstallMethod(DigraphAddVertices, " for a mutable digraph and an integer" ,
70
74
[ IsMutableDigraph, IsInt] ,
79
83
80
84
InstallMethod(DigraphAddVertices, " for an immutable digraph and an integer" ,
81
85
[ IsImmutableDigraph, IsInt] ,
82
- { D, m} -> MakeImmutable(DigraphAddVertices(DigraphMutableCopy(D), m)));
86
+ function (D, m )
87
+ if m = 0 then
88
+ return D;
89
+ fi ;
90
+ return MakeImmutable(DigraphAddVertices(DigraphMutableCopy(D), m));
91
+ end );
83
92
84
93
# Included for backwards compatibility, even though the 2nd arg is redundant.
85
94
# See https://github.com/digraphs/Digraphs/issues/264
Original file line number Diff line number Diff line change @@ -617,17 +617,9 @@ gap> DigraphVertexLabels(gr2);
617
617
[ Alt( [ 1 .. 5 ] ), Sym( [ 1 .. 2 ] ), Group(()) ]
618
618
gap> DigraphAddVertices(gr2, -1);
619
619
Error, the 2nd argument <m> must be a non-negative integer,
620
- gap> gr3 := DigraphAddVertices(gr2, 0);
621
- <immutable digraph with 3 vertices, 1 edge>
622
- gap> IsIdenticalObj(gr2, gr3);
623
- false
624
- gap> gr2 = gr3;
620
+ gap> IsIdenticalObj(gr2, DigraphAddVertices(gr2, 0));
625
621
true
626
- gap> gr3 := DigraphAddVertices(gr2, []);
627
- <immutable digraph with 3 vertices, 1 edge>
628
- gap> IsIdenticalObj(gr2, gr3);
629
- false
630
- gap> gr2 = gr3;
622
+ gap> IsIdenticalObj(gr2, DigraphAddVertices(gr2, []));
631
623
true
632
624
633
625
# DigraphAddVertices (redundant three-argument version)
You can’t perform that action at this time.
0 commit comments