Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions gap/io.gi
Original file line number Diff line number Diff line change
Expand Up @@ -2222,11 +2222,13 @@ InstallMethod(Graph6String, "for a digraph by out-neighbours",
[IsDigraphByOutNeighboursRep],
function(D)
local list, adj, n, lenlist, tablen, blist, i, j, pos, block;
if (IsMultiDigraph(D) or not IsSymmetricDigraph(D)
or DigraphHasLoops(D)) then
ErrorNoReturn("the argument <D> must be a symmetric digraph ",
"with no loops or multiple edges,");
fi;
if IsMultiDigraph(D) then
ErrorNoReturn("the argument <D> must not have multiple edges; consider encoding in Disparse6 or Digraph6");
elif not IsSymmetricDigraph(D) then
ErrorNoReturn("the argument <D> must be a symmetric digraph; consider encoding in Sparse6 or Disparse6");
elif DigraphHasLoops(D) then
ErrorNoReturn("the argument <D> must not have loops; consider encoding in Sparse6 or Disparse6");
fi;

list := [];
adj := OutNeighbours(D);
Expand Down Expand Up @@ -2285,6 +2287,15 @@ function(D)
adj := OutNeighbours(D);
n := Length(DigraphVertices(D));

if IsMultiDigraph(D) then
if IsSymmetricDigraph(D) then
ErrorNoReturn("the argument <D> must not have multiple edges ",
"consider encoding in Sparse6 or Disparse6, ");
fi;
ErrorNoReturn("the argument <D> must not have multiple edges ",
"consider encoding in Disparse6, ");
fi;

# First write the special character '&'
Add(list, -25);

Expand Down Expand Up @@ -2337,8 +2348,13 @@ InstallMethod(Sparse6String, "for a digraph by out-neighbours",
function(D)
local list, n, lenlist, adj, nredges, k, blist, v, nextbit, i, j,
bitstopad, pos, block;

if not IsSymmetricDigraph(D) then
ErrorNoReturn("the argument <D> must be a symmetric digraph,");
if IsMultiDigraph(D) then
ErrorNoReturn("the argument <D> must be a symmetric digraph consider encoding in Disparse6,");
else
ErrorNoReturn("the argument <D> must be a symmetric digraph consider encoding in Digraph6 or Disparse6,");
fi;
fi;

list := [];
Expand Down
15 changes: 8 additions & 7 deletions tst/standard/io.tst
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,8 @@ true
gap> gr[3] := Digraph([[1, 2], [1, 2]]);
<immutable digraph with 2 vertices, 4 edges>
gap> WriteDigraphs(filename, Digraph([[2], []]), Graph6String);
Error, the argument <D> must be a symmetric digraph with no loops or multiple \
edges,
Error, the argument <D> must be a symmetric digraph; consider encoding in Spar\
se6 or Disparse6
gap> OnBreak := oldOnBreak;;
gap> IO_Close(IO.OpenFiles[Length(IO.OpenFiles)]);;
gap> filename := Concatenation(DIGRAPHS_Dir(), "/tst/out/test.s6.bz2");;
Expand Down Expand Up @@ -320,8 +320,8 @@ gap> ReadDigraphs(f);
gap> IO_Close(f);;
gap> f := DigraphFile(filename, "a");;
gap> WriteDigraphs(f, CycleDigraph(5));
Error, the argument <D> must be a symmetric digraph with no loops or multiple \
edges,
Error, the argument <D> must be a symmetric digraph; consider encoding in Spar\
se6 or Disparse6
gap> WriteDigraphs(f, JohnsonDigraph(6, 3));
IO_OK
gap> IO_Close(f);;
Expand Down Expand Up @@ -546,7 +546,8 @@ Error, the 2nd argument <s> is not a valid disparse6 string,

# Special format characters
gap> Sparse6String(ChainDigraph(3));
Error, the argument <D> must be a symmetric digraph,
Error, the argument <D> must be a symmetric digraph consider encoding in Digra\
ph6 or Disparse6,
gap> Sparse6String(CompleteDigraph(1));
":@"
gap> gr := Digraph([[1], []]);;
Expand Down Expand Up @@ -659,8 +660,8 @@ Error, cannot open the file given as the 1st argument <name>,

# DigraphPlainTextLineDecoder: bad input
gap> Graph6String(ChainDigraph(4));
Error, the argument <D> must be a symmetric digraph with no loops or multiple \
edges,
Error, the argument <D> must be a symmetric digraph; consider encoding in Spar\
se6 or Disparse6
gap> DIGRAPHS_Graph6Length(-1);
fail
gap> DIGRAPHS_Graph6Length(68719476737);
Expand Down
Loading