Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to save a list of graphs into graph6 format files?

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 this. 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')

How to save a list of graphs into graph6 format files?

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 this. 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')

How to save a list of graphs into a graph6 format files?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 this. 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')

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 this. 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')