Warning

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

read_gexf

read_gexf(path, node_type=None, relabel=False, version='1.1draft')[source]

Read graph in GEXF format from path.

“GEXF (Graph Exchange XML Format) is a language for describing complex networks structures, their associated data and dynamics” [1].

Parameters:
  • path (file or string) – File or file name to write. File names ending in .gz or .bz2 will be compressed.
  • node_type (Python type (default: None)) – Convert node ids to this type if not None.
  • relabel (bool (default: False)) – If True relabel the nodes to use the GEXF node “label” attribute instead of the node “id” attribute as the NetworkX node label.
Returns:

graph – If no parallel edges are found a Graph or DiGraph is returned. Otherwise a MultiGraph or MultiDiGraph is returned.

Return type:

NetworkX graph

Notes

This implementation does not support mixed graphs (directed and undirected edges together).

References

[1]GEXF graph format, http://gexf.net/format/