Ask Your Question
0

How to get a graph back from canonical_label graph6_string

asked 2012-12-04 15:46:46 +0100

dngraph gravatar image

updated 2012-12-04 16:31:40 +0100

I have a list of graphs that I take their canonical_label 's graph6_string and then I save that list to a file.

Now I want to open that file and get sage graphs from the list of canonical_label graph6_string

How can I do it?

Thank you!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2012-12-04 20:04:05 +0100

fidbc gravatar image

updated 2012-12-04 20:13:09 +0100

You could define the following function.

def get_graphs_from_file(filename):
    f = open( filename, 'r')
    graph_list=[ Graph( l[:-1] ) for l in f ]
    f.close()
    return graph_list

And now, assuming the file graphs.g6 contains a graph6 string per line, just run

sage: L=get_graphs_from_file( 'graphs.g6')

That should leave you with a list L of graphs.

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

Stats

Asked: 2012-12-04 15:46:46 +0100

Seen: 1,057 times

Last updated: Dec 04 '12