NetworkX

Previous topic

networkx.readwrite.gexf.read_gexf

Next topic

networkx.readwrite.gexf.relabel_gexf_graph

networkx.readwrite.gexf.write_gexf

networkx.readwrite.gexf.write_gexf(G, path, encoding='utf-8', prettyprint=True)

Write G in GEXF format to path.

“GEXF (Graph Exchange XML Format) is a language for describing complex networks structures, their associated data and dynamics” [R127].

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

The node id attribute is set to be the string of the node label. If you want to specify an id use set it as node data, e.g. node[‘a’][‘id’]=1 to set the id of node ‘a’ to 1.

References

[R127](1, 2) GEXF graph format, http://gexf.net/format/

Examples

>>> G=nx.path_graph(4)
>>> nx.write_gexf(G, "test.gexf")