Warning

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

networkx.readwrite.graphml.generate_graphml

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

Generate GraphML lines for G

Parameters
  • G (graph) – A networkx graph

  • encoding (string (optional)) – Encoding for text data.

  • prettyprint (bool (optional)) – If True use line breaks and indenting in output XML.

Examples

>>> G = nx.path_graph(4)
>>> linefeed = chr(10)  # linefeed =
>>> s = linefeed.join(nx.generate_graphml(G))  
>>> for line in nx.generate_graphml(G):  
...    print(line)

Notes

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