Graph6
Convert from any graph formatto Graph6 Convert from Graph6to any other format
Graph::Graph6 is a Perl module by Kevin Ryde that reads and writes graphs in the graph6, sparse6, and digraph6 formats. These three compact, printable-ASCII encodings originate with Brendan McKay's nauty toolkit and are the customary interchange representation for the large collections of small graphs that nauty and companion tools generate and consume. The module is distributed on CPAN (current release version 9) under the GNU General Public License v3 or later.
The formats it targets encode a graph as a short string of bytes in the range 63-126. A leading N(n) field gives the vertex count, and the adjacency data is packed six bits per byte with 63 added to each group. The format:graph6 variant stores the upper triangle of the adjacency matrix and is compact for dense simple undirected graphs; format:sparse6 (prefixed with a colon) encodes an incremental edge list, tolerates loops and multiple edges, and is smaller for sparse graphs; and format:digraph6 (prefixed with &) stores the full n-by-n matrix for directed graphs. Because a whole graph becomes one line, files can hold millions of graphs one per line.
The API is small and deliberately format-native. Graph::Graph6::readgraph() accepts a filename, filehandle, or string and reports vertices and edges through references or callbacks, using integer vertex numbers 0 to n-1. Graph::Graph6::writegraph() emits any of the three formats from a supplied edge list, with the module handling nauty's specific edge orderings. This low-level core keeps no in-memory graph object of its own, which makes it fast and dependency-light but leaves higher-level modelling to the caller.
To bridge into richer ecosystems, the distribution ships adapter modules: Graph::Writer::Graph6 and a corresponding reader plug into the Graph.pm / Graph::ReadWrite family, a Graph::Easy::Parser::Graph6 feeds tool:graph-easy, and there is read support toward GraphViz2. Its main limitation is scope: graph6 and its siblings carry only structure, not vertex or edge labels, attributes, weights, or layout, so anything beyond bare topology must be attached externally. For workflows centred on enumeration, isomorphism, and canonical forms it is a precise, faithful implementation; for attributed or visual graph data, richer formats such as format:graphml or format:gml, or general tools like tool:networkx and tool:igraph (which also read graph6), are more appropriate. The R package tool:rgraph6 covers the same formats for that language.
Graph Formats(Input & Output)
Frequently Asked Questions
What graph file formats does Graph6 support?
See the list on this page — it shows every format Graph6 can read, write and display.
How do I import a graph into Graph6?
Convert your file to a format Graph6 can read, then open it in Graph6. Use GraphInOut to get a Graph6-compatible file in seconds.
How do I convert a file so Graph6 can open it?
Use the convert links above — upload or paste your graph, pick a format Graph6 accepts and download the result, right in your browser.