Skip to content

Commit

Permalink
write out partition
Browse files Browse the repository at this point in the history
  • Loading branch information
pramothragavan committed May 27, 2024
1 parent f7b92fa commit 620e649
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions gap/io.gi
Original file line number Diff line number Diff line change
Expand Up @@ -1773,7 +1773,8 @@ end);

InstallMethod(WriteDreadnautGraph, "for a digraph", [IsString, IsDigraph],
function(name, D)
local file, n, verts, nbs, labels, i, degs, filteredVerts;
local file, n, verts, nbs, labels, i, degs, filteredVerts,
out, positions, joinedPositions;

file := IO_CompressedFile(UserHomeExpand(name), "w");
if file = fail then
Expand All @@ -1800,8 +1801,22 @@ function(name, D)
IO_WriteLine(file, Concatenation(String(i), " : ",
JoinStringsWithSeparator(labels, " "), ";"));
od;

IO_WriteLine(file, ".");

if DigraphVertexLabels(D) <> [1 .. n] then
labels := DuplicateFreeList(DigraphVertexLabels(D));
out := "f = [";

for i in labels do
positions := PositionsProperty(labels, x -> x = i);
joinedPositions := JoinStringsWithSeparator(positions, " ");
out := Concatenation(out, joinedPositions);
out := Concatenation(out, " ]");
od;

IO_WriteLine(file, out);
fi;

IO_Close(file);
return;
end);
Expand Down

0 comments on commit 620e649

Please sign in to comment.