networkx.readwrite.gexf.generate_gexf¶
-
generate_gexf
(G, encoding='utf-8', prettyprint=True, version='1.2draft')[source]¶ Generate lines of GEXF format representation of G.
“GEXF (Graph Exchange XML Format) is a language for describing complex networks structures, their associated data and dynamics” [1].
Parameters: - G (graph) – A NetworkX graph
- encoding (string (optional, default: ‘utf-8’)) – Encoding for text data.
- prettyprint (bool (optional, default: True)) – If True use line breaks and indenting in output XML.
- version (string (default: 1.2draft)) – Version of GEFX File Format (see https://gephi.org/gexf/format/schema.html). Supported values: “1.1draft”, “1.2draft”
Examples
>>> G = nx.path_graph(4) >>> linefeed = chr(10) # linefeed=
>>> s = linefeed.join(nx.generate_gexf(G)) # doctest: +SKIP >>> for line in nx.generate_gexf(G): # doctest: +SKIP ... print line
Notes
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.
References
[1] GEXF File Format, https://gephi.org/gexf/format/