Warning

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

write_sparse6

write_sparse6(G, path, nodes=None, header=True)[source]

Write graph G to given path in sparse6 format. :param G: :type G: Graph (undirected) :param path: File or filename to write :type path: file or string :param nodes: Nodes are labeled 0…n-1 in the order provided. If None the ordering

given by G.nodes() is used.
Parameters:header (bool) – If True add ‘>>sparse6<<’ string to head of data
Raises:NetworkXError – If the graph is directed

Examples

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

Notes

The format does not support edge or node labels.

References

Sparse6 specification: http://cs.anu.edu.au/~bdm/data/formats.txt for details.