This documents the development version of NetworkX. Documentation for the current release can be found here.
to_graph6_bytes(G, nodes=None, header=True)¶
Convert a simple undirected graph to bytes in graph6 format.
- GGraph (undirected)
- nodes: list or iterable
Nodes are labeled 0…n-1 in the order provided. If None the ordering given by
- header: bool
If True add ‘>>graph6<<’ bytes to head of data.
If the graph is directed or is a multigraph.
If the graph has at least
2 ** 36nodes; the graph6 format is only defined for graphs of order less than
2 ** 36.
The returned bytes end with a newline character.
The format does not support edge or node labels, parallel edges or self loops. If self loops are present they are silently ignored.
Graph6 specification <http://users.cecs.anu.edu.au/~bdm/data/formats.html>
>>> nx.to_graph6_bytes(nx.path_graph(2)) b'>>graph6<<A_\n'