This documents the development version of NetworkX. Documentation for the current release can be found here.
read_gml(path, label='label', destringizer=None)¶
Read graph in GML format from
- pathfilename or filehandle
The filename or filehandle to read from.
- labelstring, optional
If not None, the parsed nodes will be renamed according to node attributes indicated by
label. Default value: ‘label’.
- destringizercallable, optional
destringizerthat recovers values stored as strings in GML. If it cannot convert a string to a value, a
ValueErroris raised. Default value : None.
- GNetworkX graph
The parsed graph.
If the input cannot be parsed.
GML files are stored using a 7-bit ASCII encoding with any extended ASCII characters (iso8859-1) appearing as HTML character entities. Without specifying a
destringizer, the code is capable of handling
listdata as required by the GML specification. For other data types, you need to explicitly supply a
For additional documentation on the GML file format, please see the GML url.
See the module docstring
networkx.readwrite.gmlfor more details.
>>> G = nx.path_graph(4) >>> nx.write_gml(G, "test.gml") >>> H = nx.read_gml("test.gml")