How to save a list of graphs into a graph6 format file?
The following is the code for finding connected graphs with 8 vertices, 10 edges, and a matching number of 3.
gen = graphs.nauty_geng("8 10 -c ")
L=[]
for g in gen:
if len(g.matching()) ==3:
L.append(g)
I want to save these graphs in Graph6 format into a file. I know Mathematica has a convenient command for this.
Export["somefile.g6",graphList,"Graph6"]
Does SageMath have a similar command? I can currently only write it like following. I wonder if there is a simpler solution.
file_path = "matching_graphs.g6"
with open(file_path, 'w') as file:
for G in L:
file.write(G.graph6_string() + '\n')