Ask Your Question
1

Graph 6 string contains "\n"

asked 2011-10-21 13:52:15 +0100

G-Sage gravatar image

I found some graphs with graph 6 string containing "\n" as a substring. But, then

g=Graph('XZ|f|a\nvrMxUrw}~iuhZjV~fxg~s^X[~~XZqlyuT~^~n~nnT~h')

calls an error:

RuntimeError: The string (XZ|f|a) seems corrupt: for n = 25, the string is too short.

Any ideas?

Thanks

edit retag flag offensive close merge delete

Comments

Can you give an example of a graph whose graph6 string contains "\n"? It's easier to test it out and look for a solution if we have an example to work with.

John Palmieri gravatar imageJohn Palmieri ( 2011-10-21 14:30:40 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2011-10-21 14:37:17 +0100

I think that the problem is: the Graph constructor should treat "\n" as two characters, but "\n" in Python by default stands for a single character, a newline. If you preface the string with "r", it should work:

sage: Graph(r'XZ|f|a\nvrMxUrw}~iuhZjV~fxg~s^X[~~XZqlyuT~^~n~nnT~h')

(The "r" tells Python that it's a "raw" string and to treat backslashes as actual backslashes, not as a part of a special character like a newline "\n" or a tab "\t".)

Alternatively, if you double the backslash, that should work:

sage: Graph('XZ|f|a\\nvrMxUrw}~iuhZjV~fxg~s^X[~~XZqlyuT~^~n~nnT~h')
edit flag offensive delete link more

Comments

Perfect, you're the bomb.

G-Sage gravatar imageG-Sage ( 2011-10-21 15:01:26 +0100 )edit

@John Is this something that should be fixed then?

G-Sage gravatar imageG-Sage ( 2011-10-21 22:42:48 +0100 )edit

I don't know enough about the graph6 format to say. It looks like newlines are acceptable in that format: you could have several graphs, one line for each. So when you evaluate "Graph(string)", it truncates "string" at the first newline. So how do you tell apart a string containing "\" followed by "n" vs. a string containing an actual newline delimiting the strings for two different graphs?

John Palmieri gravatar imageJohn Palmieri ( 2011-10-22 00:23:17 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2011-10-21 13:52:15 +0100

Seen: 964 times

Last updated: Oct 21 '11