Skip to content

Commit 6c61036

Browse files
committed
Use these new properties in methods
1 parent 0e7ca9b commit 6c61036

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

gap/attr.gi

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,7 +1080,7 @@ function(D)
10801080
# alter the answer for the diameter/girth if necessary. This function is
10811081
# called, if appropriate, by DigraphDiameter and DigraphUndirectedGirth.
10821082

1083-
if DigraphNrVertices(D) = 0 and IsImmutableDigraph(D) then
1083+
if DigraphHasNoVertices(D) and IsImmutableDigraph(D) then
10841084
SetDigraphDiameter(D, fail);
10851085
SetDigraphUndirectedGirth(D, infinity);
10861086
return rec(diameter := fail, girth := infinity);
@@ -1491,10 +1491,10 @@ end);
14911491

14921492
InstallMethod(DegreeMatrix, "for a digraph", [IsDigraph],
14931493
function(D)
1494-
if DigraphNrVertices(D) = 0 then
1495-
return [];
1494+
if DigraphHasAVertex(D) then
1495+
return DiagonalMat(OutDegrees(D));
14961496
fi;
1497-
return DiagonalMat(OutDegrees(D));
1497+
return [];
14981498
end);
14991499

15001500
InstallMethod(LaplacianMatrix, "for a digraph", [IsDigraph],
@@ -1815,7 +1815,7 @@ function(D)
18151815
SetDigraphAddAllLoopsAttr(D, C);
18161816
SetIsReflexiveDigraph(C, true);
18171817
SetIsMultiDigraph(C, ismulti);
1818-
SetDigraphHasLoops(C, DigraphNrVertices(C) > 0);
1818+
SetDigraphHasLoops(C, DigraphHasAVertex(C));
18191819
fi;
18201820
return C;
18211821
end);
@@ -2264,7 +2264,7 @@ InstallMethod(UndirectedSpanningForest, "for a digraph by out-neighbours",
22642264
[IsDigraphByOutNeighboursRep],
22652265
function(D)
22662266
local C;
2267-
if DigraphNrVertices(D) = 0 then
2267+
if DigraphHasNoVertices(D) then
22682268
return fail;
22692269
fi;
22702270
C := MaximalSymmetricSubdigraph(D)!.OutNeighbours;
@@ -2293,9 +2293,9 @@ InstallMethod(UndirectedSpanningForestAttr, "for an immutable digraph",
22932293
InstallMethod(UndirectedSpanningTree, "for a mutable digraph",
22942294
[IsMutableDigraph],
22952295
function(D)
2296-
if DigraphNrVertices(D) = 0
2297-
or not IsStronglyConnectedDigraph(D)
2298-
or not IsConnectedDigraph(UndirectedSpanningForest(DigraphMutableCopy(D)))
2296+
if not (DigraphHasAVertex(D)
2297+
and IsStronglyConnectedDigraph(D)
2298+
and IsConnectedDigraph(UndirectedSpanningForest(DigraphMutableCopy(D))))
22992299
then
23002300
return fail;
23012301
fi;
@@ -2309,7 +2309,7 @@ InstallMethod(UndirectedSpanningTreeAttr, "for an immutable digraph",
23092309
[IsImmutableDigraph],
23102310
function(D)
23112311
local out;
2312-
if DigraphNrVertices(D) = 0
2312+
if DigraphHasNoVertices(D)
23132313
or not IsStronglyConnectedDigraph(D)
23142314
or (HasMaximalSymmetricSubdigraphAttr(D)
23152315
and not IsStronglyConnectedDigraph(MaximalSymmetricSubdigraph(D)))

gap/digraph.gi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1065,7 +1065,7 @@ p -> AsDigraph(AsTransformation(p)));
10651065
InstallMethod(AsBinaryRelation, "for a digraph", [IsDigraphByOutNeighboursRep],
10661066
function(D)
10671067
local rel;
1068-
if DigraphNrVertices(D) = 0 then
1068+
if DigraphHasNoVertices(D) then
10691069
ErrorNoReturn("the argument <D> must be a digraph with at least 1 ",
10701070
"vertex,");
10711071
elif IsMultiDigraph(D) then

gap/grahom.gi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ function(D, n)
109109

110110
# Only the null D with 0 vertices can be coloured with 0 colours
111111
if n = 0 then
112-
if DigraphNrVertices(D) = 0 then
112+
if DigraphHasNoVertices(D) then
113113
return IdentityTransformation;
114114
fi;
115115
return fail;

gap/isomorph.gi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ if DIGRAPHS_NautyAvailable then
142142
colors);
143143
colors := NautyColorData(colors);
144144
fi;
145-
if DigraphNrVertices(D) = 0 then
145+
if DigraphHasNoVertices(D) then
146146
# This circumvents Issue #17 in NautyTracesInterface, whereby a graph
147147
# with 0 vertices causes a seg fault.
148148
return [Group(()), ()];

gap/prop.gi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ D -> IsDirectedTree(D) and IsSubset([0, 1], OutDegreeSet(D)));
2727

2828
InstallMethod(IsCycleDigraph, "for a digraph", [IsDigraph],
2929
function(D)
30-
return DigraphNrVertices(D) > 0
30+
return DigraphHasAVertex(D)
3131
and DigraphNrEdges(D) = DigraphNrVertices(D)
3232
and IsStronglyConnectedDigraph(D);
3333
end);
@@ -393,8 +393,8 @@ D -> DigraphNrEdges(D) = 2 * (DigraphNrVertices(D) - 1)
393393

394394
InstallMethod(IsUndirectedForest, "for a digraph", [IsDigraph],
395395
function(D)
396-
if not IsSymmetricDigraph(D) or DigraphNrVertices(D) = 0
397-
or IsMultiDigraph(D) then
396+
if DigraphHasNoVertices(D) or not IsSymmetricDigraph(D) or IsMultiDigraph(D)
397+
then
398398
return false;
399399
fi;
400400
return ForAll(DigraphConnectedComponents(D).comps,

0 commit comments

Comments
 (0)