Bug (weird behaviour) of graph6_string/sparse6_string

19 views
Skip to first unread message

Robert Samal

unread,
Nov 5, 2019, 4:43:23 AM11/5/19
to sage-support
I noticed the following strange behavior of graph6_string()/sparse6_string() functions of graphs:

sage: K2=graphs.CompleteGraph(2)
sage
: P=K2.cartesian_product(K2)

sage
: print(P.sparse6_string())
sage
: print(Graph(P.graph6_string()).sparse6_string())

:CoKN
:Cci

To explain: I understand, that Graph(P.graph6_string()) != P (as graph6_string does not preserve the original set of vertices).
On the other hand, I was expecting that the ordering of vertices would be the same, leading to the same sparse6_string().

I understand that the problem stems from having vertices not of form range(n).
However, even after looking at the documentation, I haven't been able to decide, if this is a bug or feature ...
If the latter is the case, I suggest adding a visible warning (or perhaps only give the string if the list of vertices is range(n)?).

Another observation, in the other direction I see the same behaviour:

sage: print(P.graph6_string())
sage
: print(Graph(P.sparse6_string(),loops=False, multiedges=False).graph6_string())

Cr
C
]

I am using sage 8.9 (python 3 and python 2 versions behave the same).
On the other hand, an older version of sage behaves in the expected way, that is returns the same string twice.
Also adding P.relabel() before the tests leads to the expected result.


Robert Samal

unread,
Nov 5, 2019, 1:04:28 PM11/5/19
to sage-support
OK, I nearly forgot about the following:

sage: K2=graphs.CompleteGraph(2)
sage
: P=K2.cartesian_product(K2)
sage
: print(P.graph6_string())
sage
: print(P.sparse6_string())

Cr
:CoKN

However, my installation of nauty (and older installation of sage) claims, that to graph6_string "Cr" corresponds sparse6_string ":Cci".
My running explanation is that graph6 and sparse6 use different ordering of the vertices, which is ... unfortunate.

Not sure, if this is related, but I noticed that P.relabel() creates a mapping of original vertices to range(n) that looks random (I would expect the order to be according to the list P.vertices()). It would be nice to know, if this is expected behavious (and if the order may change in between different versions of Sage). Sorry for tugging a different question to one post; I thought it might be related.
Reply all
Reply to author
Forward
0 new messages