Class Graph6Sparse6Exporter<V,E>

java.lang.Object
org.jgrapht.nio.graph6.Graph6Sparse6Exporter<V,E>
Type Parameters:
V - graph vertex type
E - graph edge type
All Implemented Interfaces:
GraphExporter<V,E>

public class Graph6Sparse6Exporter<V,E> extends Object implements GraphExporter<V,E>
Exporter which exports graphs in graph6 or sparse6 format. A description of the format can be found here. graph6 and sparse6 are formats for storing undirected graphs in a compact manner, using only printable ASCII characters. Files in these formats have text format and contain one line per graph. graph6 is suitable for small graphs, or large dense graphs. sparse6 is more space-efficient for large sparse graphs. Typically, files storing graph6 graphs have the 'g6' extension. Similarly, files storing sparse6 graphs have a 's6' file extension. sparse6 graphs support loops and multiple edges, graph6 graphs do not.

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.

Author:
Joris Kinable
  • Field Details

    • DEFAULT_GRAPH6SPARSE6_FORMAT

      public static final Graph6Sparse6Exporter.Format DEFAULT_GRAPH6SPARSE6_FORMAT
      The default format used by the exporter.
  • Constructor Details

    • Graph6Sparse6Exporter

      public Graph6Sparse6Exporter()
      Constructs a new exporter with a given vertex ID provider.
    • Graph6Sparse6Exporter

      public Graph6Sparse6Exporter(Graph6Sparse6Exporter.Format format)
      Constructs a new exporter with a given vertex ID provider.
      Parameters:
      format - the format to use
  • Method Details

    • exportGraph

      public void exportGraph(Graph<V,E> g, Writer writer) throws ExportException
      Description copied from interface: GraphExporter
      Export a graph using the given Writer.

      It is the callers responsibility to ensure the Writer is closed after this method returned.

      Specified by:
      exportGraph in interface GraphExporter<V,E>
      Parameters:
      g - the graph to export
      writer - the output writer
      Throws:
      ExportException - in case any error occurs