graph6 and sparse6 format

The graph6 format is a graph format devised by Brendan McKay. It uses only printable ASCII characters but otherwise it compresses the adjacency matrix into the last 6 bits of each character. The resulting graphs look like garbage or some sort of downloading error, but in fact they are all perfectly good printable characters (in particular safe for e-mail etc). Here is an example to show what they look like (this is the 6 snarks on 20 vertices).

SsP@PGWD?C?G?G?E?@??H?@??Ag?C_?AS
SsP@PGWC_G?G?G?E?@??H?@??Ag?C_?AS
SsP@PGWC?G_Q?O?G?@??G??g?AO?BG?Ao
SsP@PGWC?G?R?O?G?A??O??g?AO?BG?Ao
SsP@P?WC_I?_?O?I?A??K?@??Ag?AO?@c
SsP@P?OC?O?c@C?_?K?A_?B??I??BG?Ao

Obviously, this format is not human-readable so it is necessary to have a program to read it. For graph theory researchers who are serious computer users, the best thing to do is to invest the time necessary to set up the full nauty package available from Brendan McKay.

For sparse graphs, there is a related format called sparse6 which can be mixed with graph6 at will - the reader will figure out which format it is being asked to read. The sparse format is vital for storing things like large cubic graphs in a moderate amount of space.

However, for those without the time or inclination to install the full nauty package, there is a standalone graph reader, which is suitable for both graph6 and the new sparse6 format. The source code showg.c is written in C and (should) compile on almost any machine with a C compiler simply by using the command gcc -o showg showg.c. Please let either of us know if you have any problems compiling it, giving as much information about the computer, operating system and compiler as possible.

Help on showg is available by typing showg -help, and you will get the following screen

Usage: showg [-p#:#l#o#Ftq] [-a|-A|-c|-d|-e] [infile [outfile]]

 Write graphs in human-readable format.

   infile is the input file in graph6 or sparse6 format
   outfile is the output file
   Defaults are standard input and standard output.

    -p#, -p#:#, -p#-# : only display one graph or a sequence of
          graphs.  The first graph is number 1.  A second number
          which is empty or zero means infinity.

    -a  : write the adjacency matrix
    -A  : same as -a with a space between entries
    -d  : write output to satisfy dreadnaut
    -c  : write compact dreadnaut form with minimal line-breaks
    -e  : write a list of edges, preceded by the order and the
          number of edges

    -o# : specify number of first vertex (default is 0)
    -t  : write upper triangle only (affects -a, -A, -d and default)
    -F  : write a form-feed after each graph except the last
    -l# : specify screen width limit (default 78, 0 means no limit)
          This is not currently implemented with -a or -A.
    -q  : suppress auxiliary output

    -a, -A, -c, -d and -e are incompatible.

Examples of use

Suppose you have downloaded the file snark20_cyc4.g6 containing the 20 vertex snarks in g6 format. Here are some sample ways in which you can view the graphs, or prepare them for further computer processing in your preferred format.

The program showg was written by Brendan McKay.