NetworkX

Previous topic

networkx.parse_gml

Next topic

networkx.write_gml

networkx.read_gml

read_gml(path)

Read graph in GML format from path.

Parameters:

path : filename or filehandle

The filename or filehandle to read from.

Returns:

G : MultiGraph or MultiDiGraph

Raises:

ImportError :

If the pyparsing module is not available.

See also

write_gml, parse_gml

Notes

This doesn’t implement the complete GML specification for nested attributes for graphs, edges, and nodes.

Requires pyparsing: http://pyparsing.wikispaces.com/

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')