Warning

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

write_graphml

write_graphml(G, path, encoding='utf-8', prettyprint=True)[source]

Write G in GraphML XML format to path

Parameters :

G : graph

A networkx graph

path : file or string

File or filename to write. Filenames ending in .gz or .bz2 will be compressed.

encoding : string (optional)

Encoding for text data.

prettyprint : bool (optional)

If True use line breaks and indenting in output XML.

Notes

This implementation does not support mixed graphs (directed and unidirected edges together) hyperedges, nested graphs, or ports.

Examples

>>> G=nx.path_graph(4)
>>> nx.write_graphml(G, "test.graphml")