networkx.readwrite.read_sparse6

networkx.readwrite.read_sparse6(path)[source]

Read an undirected graph in sparse6 format from path.

Parameters:

path : file or string

File or filename to write.

Returns:

G : Graph/Multigraph or list of Graphs/MultiGraphs

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

Raises:

NetworkXError

If the string is unable to be parsed in sparse6 format

References

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

Examples

>>> nx.write_sparse6(nx.Graph([(0,1),(0,1),(0,1)]), 'test.s6')
>>> G = nx.read_sparse6('test.s6')
>>> sorted(G.edges())
[(0, 1)]