From b59602264cc9c06197fd88d1a5ce438e1d06df43 Mon Sep 17 00:00:00 2001 From: Anuj Thakur Date: Wed, 25 Mar 2026 14:28:00 +0000 Subject: [PATCH 1/5] Fix: faulty encoding without faithfulness --- gap/io.gi | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/gap/io.gi b/gap/io.gi index e29ba45f8..338c7b880 100644 --- a/gap/io.gi +++ b/gap/io.gi @@ -2281,6 +2281,15 @@ function(D) # matrix, and appends a '&' to the start. The old '+' format can be read by # DigraphFromDigraph6String, but can no longer be written by this function. + if IsMultiDigraph(D) then + if IsSymmetricDigraph(D) then + ErrorNoReturn("the argument must not have multiple edges ", + "consider encoding in Sparse6 or Disparse6, "); + fi; + ErrorNoReturn("the argument must not have multiple edges ", + "consider encoding in Disparse6, "); + fi; + list := []; adj := OutNeighbours(D); n := Length(DigraphVertices(D)); @@ -2338,7 +2347,11 @@ 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 must be a symmetric digraph,"); + if IsMultiDigraph(D) then + ErrorNoReturn("the argument must be a symmetric digraph consider encoding in Disparse6,"); + fi; + else + ErrorNoReturn("the argument must be a symmetric digraph consider encoding in Digraph6 or Disparse6,"); fi; list := []; From 1a1fc007d17b342f7b28f735210403bd6cfab2f4 Mon Sep 17 00:00:00 2001 From: Anuj Thakur Date: Wed, 25 Mar 2026 15:13:16 +0000 Subject: [PATCH 2/5] Fix: faulty encoding without faithfulness --- gap/io.gi | 29 ++++++++++++++++++++++++----- tst/standard/io.tst | 12 ++++++------ 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/gap/io.gi b/gap/io.gi index 338c7b880..c93c7502c 100644 --- a/gap/io.gi +++ b/gap/io.gi @@ -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 must be a symmetric digraph ", - "with no loops or multiple edges,"); - fi; + if IsMultiDigraph(D) then + ErrorNoReturn("the argument must not have multiple edges; consider encoding in Disparse6 or Digraph6"); +elif not IsSymmetricDigraph(D) then + ErrorNoReturn("the argument must be a symmetric digraph; consider encoding in Sparse6 or Disparse6"); +elif DigraphHasLoops(D) then + ErrorNoReturn("the argument must not have loops; consider encoding in Sparse6 or Disparse6"); +fi; list := []; adj := OutNeighbours(D); @@ -2294,6 +2296,15 @@ function(D) adj := OutNeighbours(D); n := Length(DigraphVertices(D)); + if IsMultiDigraph(D) then + if IsSymmetricDigraph(D) then + ErrorNoReturn("the argument must not have multiple edges ", + "consider encoding in Sparse6 or Disparse6, "); + fi; + ErrorNoReturn("the argument must not have multiple edges ", + "consider encoding in Disparse6, "); + fi; + # First write the special character '&' Add(list, -25); @@ -2354,6 +2365,14 @@ function(D) ErrorNoReturn("the argument must be a symmetric digraph consider encoding in Digraph6 or Disparse6,"); fi; + if not IsSymmetricDigraph(D) then + if IsMultiDigraph(D) then + ErrorNoReturn("the argument must be a symmetric digraph consider encoding in Disparse6,"); + else + ErrorNoReturn("the argument must be a symmetric digraph consider encoding in Digraph6 or Disparse6,"); + fi; + fi; + list := []; n := Length(DigraphVertices(D)); diff --git a/tst/standard/io.tst b/tst/standard/io.tst index 5c606a349..317bda82d 100644 --- a/tst/standard/io.tst +++ b/tst/standard/io.tst @@ -283,8 +283,8 @@ true gap> gr[3] := Digraph([[1, 2], [1, 2]]); gap> WriteDigraphs(filename, Digraph([[2], []]), Graph6String); -Error, the argument must be a symmetric digraph with no loops or multiple \ -edges, +Error, the argument 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");; @@ -320,8 +320,8 @@ gap> ReadDigraphs(f); gap> IO_Close(f);; gap> f := DigraphFile(filename, "a");; gap> WriteDigraphs(f, CycleDigraph(5)); -Error, the argument must be a symmetric digraph with no loops or multiple \ -edges, +Error, the argument must be a symmetric digraph; consider encoding in Spar\ +se6 or Disparse6 gap> WriteDigraphs(f, JohnsonDigraph(6, 3)); IO_OK gap> IO_Close(f);; @@ -659,8 +659,8 @@ Error, cannot open the file given as the 1st argument , # DigraphPlainTextLineDecoder: bad input gap> Graph6String(ChainDigraph(4)); -Error, the argument must be a symmetric digraph with no loops or multiple \ -edges, +Error, the argument must be a symmetric digraph; consider encoding in Spar\ +se6 or Disparse6 gap> DIGRAPHS_Graph6Length(-1); fail gap> DIGRAPHS_Graph6Length(68719476737); From 69fe761b0ab702e13b15f0e1cda25af3ba5f41eb Mon Sep 17 00:00:00 2001 From: Anuj Thakur Date: Wed, 25 Mar 2026 15:17:26 +0000 Subject: [PATCH 3/5] Fix: faulty encoding without faithfulness --- gap/io.gi | 16 ---------------- tst/standard/io.tst | 3 ++- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/gap/io.gi b/gap/io.gi index c93c7502c..90d7caa80 100644 --- a/gap/io.gi +++ b/gap/io.gi @@ -2283,15 +2283,6 @@ function(D) # matrix, and appends a '&' to the start. The old '+' format can be read by # DigraphFromDigraph6String, but can no longer be written by this function. - if IsMultiDigraph(D) then - if IsSymmetricDigraph(D) then - ErrorNoReturn("the argument must not have multiple edges ", - "consider encoding in Sparse6 or Disparse6, "); - fi; - ErrorNoReturn("the argument must not have multiple edges ", - "consider encoding in Disparse6, "); - fi; - list := []; adj := OutNeighbours(D); n := Length(DigraphVertices(D)); @@ -2357,13 +2348,6 @@ 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 - if IsMultiDigraph(D) then - ErrorNoReturn("the argument must be a symmetric digraph consider encoding in Disparse6,"); - fi; - else - ErrorNoReturn("the argument must be a symmetric digraph consider encoding in Digraph6 or Disparse6,"); - fi; if not IsSymmetricDigraph(D) then if IsMultiDigraph(D) then diff --git a/tst/standard/io.tst b/tst/standard/io.tst index 317bda82d..23be86e20 100644 --- a/tst/standard/io.tst +++ b/tst/standard/io.tst @@ -546,7 +546,8 @@ Error, the 2nd argument is not a valid disparse6 string, # Special format characters gap> Sparse6String(ChainDigraph(3)); -Error, the argument must be a symmetric digraph, +Error, the argument must be a symmetric digraph consider encoding in Digra\ +ph6 or Disparse6, gap> Sparse6String(CompleteDigraph(1)); ":@" gap> gr := Digraph([[1], []]);; From b4feb6223d267a60bd98921e07acfca85bd03f06 Mon Sep 17 00:00:00 2001 From: Anuj Thakur Date: Tue, 31 Mar 2026 17:32:33 +0100 Subject: [PATCH 4/5] Adding test coverage for new error catching --- gap/io.gi | 31 +++++++++++++++++++++++-------- tst/standard/io.tst | 22 ++++++++++++++++++++-- 2 files changed, 43 insertions(+), 10 deletions(-) diff --git a/gap/io.gi b/gap/io.gi index 90d7caa80..acaed0953 100644 --- a/gap/io.gi +++ b/gap/io.gi @@ -2223,12 +2223,21 @@ InstallMethod(Graph6String, "for a digraph by out-neighbours", function(D) local list, adj, n, lenlist, tablen, blist, i, j, pos, block; if IsMultiDigraph(D) then - ErrorNoReturn("the argument must not have multiple edges; consider encoding in Disparse6 or Digraph6"); -elif not IsSymmetricDigraph(D) then - ErrorNoReturn("the argument must be a symmetric digraph; consider encoding in Sparse6 or Disparse6"); -elif DigraphHasLoops(D) then - ErrorNoReturn("the argument must not have loops; consider encoding in Sparse6 or Disparse6"); -fi; + ErrorNoReturn( + "the argument must not have multiple edges; ", + "consider encoding in Disparse6 or Digraph6" + ); + elif not IsSymmetricDigraph(D) then + ErrorNoReturn( + "the argument must be a symmetric digraph; ", + "consider encoding in Sparse6 or Disparse6" + ); + elif DigraphHasLoops(D) then + ErrorNoReturn( + "the argument must not have loops; ", + "consider encoding in Sparse6 or Disparse6" + ); + fi; list := []; adj := OutNeighbours(D); @@ -2351,9 +2360,15 @@ function(D) if not IsSymmetricDigraph(D) then if IsMultiDigraph(D) then - ErrorNoReturn("the argument must be a symmetric digraph consider encoding in Disparse6,"); + ErrorNoReturn( + "the argument must be a symmetric digraph; ", + "consider encoding in Disparse6" + ); else - ErrorNoReturn("the argument must be a symmetric digraph consider encoding in Digraph6 or Disparse6,"); + ErrorNoReturn( + "the argument must be a symmetric digraph; ", + "consider encoding in Digraph6 or Disparse6" + ); fi; fi; diff --git a/tst/standard/io.tst b/tst/standard/io.tst index 23be86e20..e643e3085 100644 --- a/tst/standard/io.tst +++ b/tst/standard/io.tst @@ -546,8 +546,8 @@ Error, the 2nd argument is not a valid disparse6 string, # Special format characters gap> Sparse6String(ChainDigraph(3)); -Error, the argument must be a symmetric digraph consider encoding in Digra\ -ph6 or Disparse6, +Error, the argument must be a symmetric digraph; consider encoding in Digr\ +aph6 or Disparse6 gap> Sparse6String(CompleteDigraph(1)); ":@" gap> gr := Digraph([[1], []]);; @@ -560,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 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 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 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 From 2c5aa59ec5e9e2d841364466b08e125fc283a0ec Mon Sep 17 00:00:00 2001 From: Anuj Thakur Date: Tue, 31 Mar 2026 18:53:31 +0100 Subject: [PATCH 5/5] linting edits --- gap/io.gi | 30 ++++++++++-------------------- tst/standard/io.tst | 2 +- 2 files changed, 11 insertions(+), 21 deletions(-) diff --git a/gap/io.gi b/gap/io.gi index acaed0953..3aff5665e 100644 --- a/gap/io.gi +++ b/gap/io.gi @@ -2223,20 +2223,14 @@ InstallMethod(Graph6String, "for a digraph by out-neighbours", function(D) local list, adj, n, lenlist, tablen, blist, i, j, pos, block; if IsMultiDigraph(D) then - ErrorNoReturn( - "the argument must not have multiple edges; ", - "consider encoding in Disparse6 or Digraph6" - ); + ErrorNoReturn("the argument must not have multiple edges; ", + "consider encoding in Disparse6 or Digraph6"); elif not IsSymmetricDigraph(D) then - ErrorNoReturn( - "the argument must be a symmetric digraph; ", - "consider encoding in Sparse6 or Disparse6" - ); + ErrorNoReturn("the argument must be a symmetric digraph; ", + "consider encoding in Sparse6 or Disparse6"); elif DigraphHasLoops(D) then - ErrorNoReturn( - "the argument must not have loops; ", - "consider encoding in Sparse6 or Disparse6" - ); + ErrorNoReturn("the argument must not have loops; ", + "consider encoding in Sparse6 or Disparse6"); fi; list := []; @@ -2360,15 +2354,11 @@ function(D) if not IsSymmetricDigraph(D) then if IsMultiDigraph(D) then - ErrorNoReturn( - "the argument must be a symmetric digraph; ", - "consider encoding in Disparse6" - ); + ErrorNoReturn("the argument must be a symmetric digraph; ", + "consider encoding in Disparse6"); else - ErrorNoReturn( - "the argument must be a symmetric digraph; ", - "consider encoding in Digraph6 or Disparse6" - ); + ErrorNoReturn("the argument must be a symmetric digraph; ", + "consider encoding in Digraph6 or Disparse6"); fi; fi; diff --git a/tst/standard/io.tst b/tst/standard/io.tst index e643e3085..245465aa1 100644 --- a/tst/standard/io.tst +++ b/tst/standard/io.tst @@ -561,7 +561,7 @@ gap> Sparse6String(last); ":TdBkJ`Kq?" # Multiple Edges Digraph6 -gap> gr := Digraph([[1,1], [2]]);; +gap> gr := Digraph([[1, 1], [2]]);; gap> Digraph6String(gr); Error, the argument must not have multiple edges consider encoding in Spar\ se6 or Disparse6,