networkx.readwrite.parse_graphml

networkx.readwrite.parse_graphml(graphml_string, node_type=<type 'str'>)[source]

Read graph in GraphML format from string.

Parameters:

graphml_string : string

String containing graphml information (e.g., contents of a graphml file).

node_type: Python type (default: str)

Convert node ids to this type

Returns:

graph: NetworkX graph

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

Notes

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

For multigraphs the GraphML edge “id” will be used as the edge key. If not specified then they “key” attribute will be used. If there is no “key” attribute a default NetworkX multigraph edge key will be provided.

Examples

>>> G=nx.path_graph(4)
>>> linefeed=chr(10) # linefeed=
>>> s=linefeed.join(nx.generate_graphml(G))
>>> H=nx.parse_graphml(s)