NetworkX

Previous topic

networkx.read_gml

Next topic

networkx.parse_gml

networkx.write_gml

write_gml(G, path)

Write the graph G in GML format to the file or file handle path.

Parameters:

path : filename or filehandle

The filename or filehandle to write. Filenames ending in .gz or .gz2 will be compressed.

See also

read_gml, parse_gml

Notes

GML specifications indicate that the file should only use 7bit ASCII text encoding.iso8859-1 (latin-1).

For nested attributes for graphs, nodes, and edges you should use dicts for the value of the attribute.

Examples

>>> G=nx.path_graph(4)
>>> nx.write_gml(G,"test.gml")

Filenames ending in .gz or .bz2 will be compressed.

>>> nx.write_gml(G,"test.gml.gz")