write_gexf(G, path, encoding='utf-8', prettyprint=True, version='1.2draft')
"GEXF (Graph Exchange XML Format) is a language for describing complex networks structures, their associated data and dynamics" .
Node attributes are checked according to the version of the GEXF schemas used for parameters which are not user defined, e.g. visualization 'viz' . See example for usage.
This implementation does not support mixed graphs (directed and undirected 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.
A NetworkX graph
File or file name to write. File names ending in .gz or .bz2 will be compressed.
Encoding for text data.
If True use line breaks and indenting in output XML.
The version of GEXF to be used for nodes attributes checking
Write G in GEXF format to path.
>>> G = nx.path_graph(4)
... nx.write_gexf(G, "test.gexf")
# visualization data >>> G.nodes[0]["viz"] = {"size": 54} >>> G.nodes[0]["viz"]["position"] = {"x": 0, "y": 1} >>> G.nodes[0]["viz"]["color"] = {"r": 0, "g": 0, "b": 256}
See :The following pages refer to to this document either explicitly or contain code examples using this.
networkx.readwrite.gexf.write_gexf
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them