Skip to content

Commit

Permalink
Check attributes before making mutable copy
Browse files Browse the repository at this point in the history
  • Loading branch information
Joseph-Edwards committed Sep 2, 2024
1 parent 2ca273f commit 4e2bc04
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions gap/planar.gi
Original file line number Diff line number Diff line change
Expand Up @@ -33,27 +33,29 @@
InstallMethod(PlanarEmbedding, "for a digraph", [IsDigraph],
function(D)
local C;
if HasIsPlanarDigraph(D) and not IsPlanarDigraph(D) then
return fail;
fi;
C := DigraphMutableCopy(D);
DigraphRemoveAllMultipleEdges(C);
DigraphRemoveLoops(C);
if IsEmptyDigraph(C) or DigraphNrVertices(C) < 3 then
return OutNeighbors(C);
elif HasIsPlanarDigraph(C) and not IsPlanarDigraph(C) then
return fail;
fi;
return PLANAR_EMBEDDING(C);
end);

InstallMethod(OuterPlanarEmbedding, "for a digraph", [IsDigraph],
function(D)
local C;
if HasIsPlanarDigraph(D) and not IsPlanarDigraph(D) then
return fail;
fi;
C := DigraphMutableCopy(D);
DigraphRemoveAllMultipleEdges(C);
DigraphRemoveLoops(C);
if IsEmptyDigraph(C) or DigraphNrVertices(C) < 3 then
return OutNeighbors(C);
elif HasIsOuterPlanarDigraph(C) and not IsOuterPlanarDigraph(C) then
return fail;
fi;
return OUTER_PLANAR_EMBEDDING(C);
end);
Expand Down

0 comments on commit 4e2bc04

Please sign in to comment.