Warning

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

parse_gml

parse_gml(lines, label='label', destringizer=None)[source]

Parse GML graph from a string or iterable.

Parameters:
  • lines (string or iterable of strings) – Data in GML format.
  • label (string, optional) – If not None, the parsed nodes will be renamed according to node attributes indicated by label. Default value: 'label'.
  • destringizer (callable, optional) – A destringizer that recovers values stored as strings in GML. If it cannot convert a string to a value, a ValueError is raised. Default value : None.
Returns:

G – The parsed graph.

Return type:

NetworkX graph

Raises:

NetworkXError – If the input cannot be parsed.

Notes

This stores nested GML attributes as dictionaries in the NetworkX graph, node, and edge attribute structures.

References

GML specification: http://www.infosun.fim.uni-passau.de/Graphlet/GML/gml-tr.html