Macaulay2 » Documentation
Packages » NautyGraphs :: Comparison of Graph6 and Sparse6 formats
next | previous | forward | backward | up | index | toc

Comparison of Graph6 and Sparse6 formats

The program nauty uses two string-based formats for storing graphs: Graph6 and Sparse6 format. Each format has benefits and drawbacks.

In particular, the length of a Graph6 string representation of a graph depends only on the number of vertices. However, this also means that graphs with few edges take as much space as graphs with many edges. On the other hand, Sparse6 is a variable length format which can use dramatically less space for sparse graphs but can have a much larger storage size for dense graphs.

Consider the 26-cycle, a rather sparse graph. Notice how Sparse6 format takes half the space of the Graph6 format.

i1 : C26 = graph append(apply(25, i -> {i, i+1}), {0, 25});
i2 : g6 = graphToString C26; #g6

o3 = 56
i4 : s6 = graph6ToSparse6 g6; #s6

o5 = 28

However, the complete graph, which is as dense as possible, on 26 vertices is the opposite: the Sparse6 format takes nearly six times the space of the Graph6 format.

i6 : K26 = graph flatten for i from 0 to 25 list for j from i+1 to 25 list {i,j};
i7 : g6 = graphToString K26; #g6

o8 = 56
i9 : s6 = graph6ToSparse6 g6; #s6

o10 = 327

See also