From b59602264cc9c06197fd88d1a5ce438e1d06df43 Mon Sep 17 00:00:00 2001 From: Anuj Thakur Date: Wed, 25 Mar 2026 14:28:00 +0000 Subject: [PATCH 1/3] 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/3] 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/3] 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], []]);;