networkx.read_gml

networkx.read_gml(path, label='label', destringizer=None)[source]

Read graph in GML format from path.

Parameters:

path : filename or filehandle

The filename or filehandle to read from.

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 : NetworkX graph

The parsed graph.

Raises:

NetworkXError

If the input cannot be parsed.

See also

write_gml, parse_gml

Notes

The GML specification says that files should be ASCII encoded, with any extended ASCII characters (iso8859-1) appearing as HTML character entities.

References

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

Examples

>>> G = nx.path_graph(4)
>>> nx.write_gml(G, 'test.gml')
>>> H = nx.read_gml('test.gml')