Skip to content
Open
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
31 changes: 26 additions & 5 deletions gap/io.gi
Original file line number Diff line number Diff line change
Expand Up @@ -2222,10 +2222,15 @@ 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,");
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");
Comment on lines +2227 to +2233
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think all three of these "consider" lines are wrong. Revise this with Wilf's summary from his issue:

Graph6: can encode any symmetric digraph without loops or multiple edges
Sparse6: can encode any symmetric digraph
Digraph6: can encode any digraph without multiple edges
Disparse6: can encode any digraph

fi;

list := [];
Expand Down Expand Up @@ -2285,6 +2290,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 +2351,15 @@ 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
33 changes: 26 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;;
Comment on lines -286 to 288
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fact these break across lines is probably an argument for putting \n after the semicolon. Could you do this in all cases?

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 Digr\
aph6 or Disparse6
gap> Sparse6String(CompleteDigraph(1));
":@"
gap> gr := Digraph([[1], []]);;
Expand All @@ -559,6 +560,24 @@ gap> DigraphFromSparse6String(":TdBkJ`Kq?x");
gap> Sparse6String(last);
":TdBkJ`Kq?"

# Multiple Edges Digraph6
gap> gr := Digraph([[1, 1], [2]]);;
gap> Digraph6String(gr);
Error, the argument <D> must not have multiple edges consider encoding in Spar\
se6 or Disparse6,

# Non-symmetric Digraph in Sparse6
gap> gr := Digraph([[2], []]);;
gap> Sparse6String(gr);
Error, the argument <D> must be a symmetric digraph; consider encoding in Digr\
aph6 or Disparse6

# Digraph with loops in Sparse6
gap> gr := Digraph([[1], [2]]);;
gap> Graph6String(gr);
Error, the argument <D> must not have loops; consider encoding in Sparse6 or D\
isparse6

# DigraphPlainTextLineDecoder: bad input
gap> DigraphPlainTextLineDecoder(" ", " ", 1, ".");
Error, no method found! For debugging hints type ?Recovery from NoMethodFound
Expand Down Expand Up @@ -659,8 +678,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