Warning

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

generate_gml

generate_gml(G, stringizer=None)[source]

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

Parameters:
  • 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.
Returns:

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

Return type:

generator of strings

Raises:

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

Notes

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.