This documents an unmaintained version of NetworkX. Please upgrade to a maintained version and see the current NetworkX documentation.
write_gml(G, path, stringizer=None)¶
Write a graph
Gin GML format to the file or file handle
- G (NetworkX graph) – The graph to be converted to GML.
- path (filename or filehandle) – The filename or filehandle to write. Files whose names end with .gz or .bz2 will be compressed.
- stringizer (callable, optional) – A stringizer which converts non-int/non-float/non-dict values into
strings. If it cannot convert a value into a string, it should raise a
ValueErrorto indicate that. Default value:
stringizercannot convert a value into a string, or the value to convert is not a string while
Graph attributes named
'edge',node attributes named
'label', edge attributes named
Gis a multigraph) are ignored because these attribute names are used to encode the graph structure.
>>> 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")