Skip to content

Commit

Permalink
attr: disable edge labels if not already set in some cases
Browse files Browse the repository at this point in the history
  • Loading branch information
james-d-mitchell committed Apr 6, 2022
1 parent ceb6c0d commit d504df9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 18 deletions.
28 changes: 11 additions & 17 deletions gap/attr.gi
Original file line number Diff line number Diff line change
Expand Up @@ -1787,30 +1787,24 @@ function(D)
return D;
end);

InstallMethod(DigraphAddAllLoops, "for a digraph by out-neighbours",
[IsDigraphByOutNeighboursRep],
InstallMethod(DigraphAddAllLoops, "for a digraph", [IsDigraph],
function(D)
local ismulti, C, list, v;
if HasIsReflexiveDigraph(D) and IsReflexiveDigraph(D) then
return D;
fi;
ismulti := IsMultiDigraph(D);
local C, v;
C := DigraphMutableCopyIfImmutable(D);
list := C!.OutNeighbours;
Assert(1, IsMutable(list));
for v in DigraphVertices(C) do
if not v in list[v] then
Add(list[v], v);
if not ismulti then
SetDigraphEdgeLabel(C, v, v, 1);

if not (HasIsReflexiveDigraph(D) and IsReflexiveDigraph(D)) then
for v in DigraphVertices(C) do
if not IsDigraphEdge(D, v, v) then
DigraphAddEdge(C, v, v);
fi;
fi;
od;
od;
fi;

if IsImmutableDigraph(D) then
MakeImmutable(C);
SetDigraphAddAllLoopsAttr(D, C);
SetIsReflexiveDigraph(C, true);
SetIsMultiDigraph(C, ismulti);
SetIsMultiDigraph(C, IsMultiDigraph(D));
SetDigraphHasLoops(C, DigraphNrVertices(C) > 0);
fi;
return C;
Expand Down
2 changes: 1 addition & 1 deletion tst/standard/attr.tst
Original file line number Diff line number Diff line change
Expand Up @@ -2741,7 +2741,7 @@ gap> D := Digraph(IsImmutableDigraph,
gap> IsReflexiveDigraph(D);
true
gap> IsIdenticalObj(D, DigraphAddAllLoops(D));
true
false

# DigraphAddAllLoops - mutable
gap> D := Digraph(IsMutableDigraph,
Expand Down

0 comments on commit d504df9

Please sign in to comment.