Note

This is the documentation for the current state of the development branch of rustworkx. The documentation or APIs here can change prior to being released.

rustworkx.write_graphml#

write_graphml(graph, path, /, keys=None, compression=None)[source]#

Write a graph to a file in GraphML format.

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.

For more information see: http://graphml.graphdrawing.org/

Note

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

Note

GraphML attributes with graph domain are written from the graph’s attrs field.

Parameters:
  • graph – The graph to write to the file. This can be a PyGraph or PyDiGraph.

  • path – The path of the output file to write.

  • keys – Optional list of key definitions for GraphML attributes. If not specified, keys will be inferred from the graph data.

  • compression – Optional compression format for the output file. If not specified, no compression is applied.

Raises:

RuntimeError – when an error is encountered while writing the GraphML file.