Warning

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

GraphML

GraphML

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.”

http://graphml.graphdrawing.org/

Format

GraphML is an XML format. See http://graphml.graphdrawing.org/specification.html for the specification and http://graphml.graphdrawing.org/primer/graphml-primer.html for examples.

read_graphml(path[, node_type, edge_key_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.