Skip to content

Commit

Permalink
Added copy in DigraphAllChordlessCycles (#702)
Browse files Browse the repository at this point in the history
  • Loading branch information
MeikeWeiss committed Sep 11, 2024
1 parent 702a4b4 commit b080f74
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
8 changes: 5 additions & 3 deletions gap/attr.gi
Original file line number Diff line number Diff line change
Expand Up @@ -1630,11 +1630,13 @@ function(D)
return [C, blocked];
end;

digraph := DigraphSymmetricClosure(DigraphRemoveLoops(
DigraphRemoveAllMultipleEdges(DigraphMutableCopyIfMutable(D))));

digraph := DigraphMutableCopy(D);
DigraphSymmetricClosure(DigraphRemoveLoops(
DigraphRemoveAllMultipleEdges(digraph)));
MakeImmutable(digraph);
SetDigraphVertexLabels(digraph,
Reversed(DigraphDegeneracyOrdering(digraph)));

temp := Triplets(digraph);
T := temp[1];
C := temp[2];
Expand Down
35 changes: 35 additions & 0 deletions tst/standard/attr.tst
Original file line number Diff line number Diff line change
Expand Up @@ -1036,6 +1036,41 @@ gap> DigraphAllChordlessCycles(D);
[ 1, 4, 8, 7, 6, 2 ], [ 1, 4, 3, 2 ], [ 1, 4, 3, 7, 6, 5 ], [ 3, 2, 6, 7 ],
[ 2, 1, 5, 6 ], [ 2, 1, 5, 8, 7, 3 ] ]

# check that DigraphAllChordlessCycles do not change the input graph
gap> g := Digraph([[2, 3, 7], [1, 4, 8], [1, 4, 9], [2, 3, 10], [6, 7, 9], [5, 8, 10],
> [8, 5, 1], [7, 6, 2], [5, 10, 3], [6, 9, 4]]);;
gap> DigraphAllChordlessCycles(g);
[ [ 7, 8, 6, 5 ], [ 6, 5, 9, 10 ], [ 3, 4, 10, 6, 5, 7, 1 ],
[ 3, 4, 10, 6, 8, 7, 1 ], [ 3, 4, 10, 9 ], [ 2, 4, 10, 6, 5, 7, 1 ],
[ 2, 4, 10, 6, 8 ], [ 2, 4, 10, 9, 5, 7, 8 ], [ 2, 4, 10, 9, 5, 7, 1 ],
[ 3, 4, 2, 1 ], [ 3, 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