networkx.read_graph6

networkx.read_graph6(path)[source]

Read simple undirected graphs in graph6 format from path.

Parameters:

path : file or string

File or filename to write.

Returns:

G : Graph or list of Graphs

If the file contains multiple lines then a list of graphs is returned

Raises:

NetworkXError

If the string is unable to be parsed in graph6 format

References

[R1237]Graph6 specification <http://users.cecs.anu.edu.au/~bdm/data/formats.html>

Examples

>>> nx.write_graph6(nx.Graph([(0,1)]), 'test.g6')
>>> G = nx.read_graph6('test.g6')
>>> sorted(G.edges())
[(0, 1)]