First time here? Check out the FAQ!

Ask Your Question
1

Graph 6 string contains "\n"

asked 13 years ago

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

Preview: (hide)

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 ( 13 years ago )

1 Answer

Sort by » oldest newest most voted
2

answered 13 years ago

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')
Preview: (hide)
link

Comments

Perfect, you're the bomb.

G-Sage gravatar imageG-Sage ( 13 years ago )

@John Is this something that should be fixed then?

G-Sage gravatar imageG-Sage ( 13 years ago )

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 ( 13 years ago )

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: 13 years ago

Seen: 972 times

Last updated: Oct 21 '11