This documents an unmaintained version of NetworkX. Please upgrade to a maintained version and see the current NetworkX documentation.


generate_gml(G, stringizer=None)[source]

Generate a single entry of the graph G in GML format.

  • G (NetworkX graph) – The graph to be converted to GML.
  • stringizer (callable, optional) – A stringizer which converts non-int/float/dict values into strings. If it cannot convert a value into a string, it should raise a ValueError raised to indicate that. Default value: None.

lines – Lines of GML data. Newlines are not appended.

Return type:

generator of strings


NetworkXError – If stringizer cannot convert a value into a string, or the value to convert is not a string while stringizer is None.


Graph attributes named 'directed', 'multigraph', 'node' or 'edge',node attributes named 'id' or 'label', edge attributes named 'source' or 'target' (or 'key' if G is a multigraph) are ignored because these attribute names are used to encode the graph structure.