networkx.readwrite.graphml.write_graphml¶
-
write_graphml(G, path, encoding='utf-8', prettyprint=True, infer_numeric_types=False)¶ Write G in GraphML XML format to path
- Parameters
G (
graph) – A networkx graphpath (
fileorstring) – 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.infer_numeric_types (
boolean) – Determine if numeric types should be generalized. For example, if edges have both int and float ‘weight’ attributes, we infer in GraphML that both are floats.
Examples
>>> G = nx.path_graph(4) >>> nx.write_graphml(G, "test.graphml")
Notes
It may be a good idea in Python2 to convert strings to unicode before giving the graph to write_gml. At least the strings with either many characters to escape.
This implementation does not support mixed graphs (directed and unidirected edges together) hyperedges, nested graphs, or ports.