Ask Your Question
0

How to get a graph back from canonical_label graph6_string

asked 12 years ago

dngraph gravatar image

updated 12 years ago

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!

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
2

answered 12 years ago

fidbc gravatar image

updated 12 years ago

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.

Preview: (hide)
link

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

Seen: 1,129 times

Last updated: Dec 04 '12