This documents the development version of NetworkX. Documentation for the current release can be found here.


Read and write graphs in GraphML format.

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

“GraphML is a comprehensive and easy-to-use file format for graphs. It consists of a language core to describe the structural properties of a graph and a flexible extension mechanism to add application-specific data. Its main features include support of

  • directed, undirected, and mixed graphs,

  • hypergraphs,

  • hierarchical graphs,

  • graphical representations,

  • references to external data,

  • application-specific attribute data, and

  • light-weight parsers.

Unlike many other file formats for graphs, GraphML does not use a custom syntax. Instead, it is based on XML and hence ideally suited as a common denominator for all kinds of services generating, archiving, or processing graphs.”


GraphML is an XML format. See for the specification and for examples.

read_graphml(path[, node_type, …])

Read graph in GraphML format from path.

write_graphml(G, path[, encoding, …])

Write G in GraphML XML format to path

generate_graphml(G[, encoding, prettyprint, …])

Generate GraphML lines for G

parse_graphml(graphml_string[, node_type, …])

Read graph in GraphML format from string.