Package com.jgalgo.io

Class Graph6GraphReader

  • All Implemented Interfaces:
    GraphReader<Integer,​Integer>

    public final class Graph6GraphReader
    extends Object
    Read a graph in 'graph6' format.

    'graph6' is a format for storing undirected graphs in a compact manner, using only printable ASCII characters. Files in these format have text type and contain one line per graph. It is suitable for small graphs, or large dense graphs. The format support graphs with vertices numbered 0..n-1 only, where n is the number of vertices, and edges numbered 0..m-1 only, where m is the number of edges. A graph6 file contains a bit vector with n (n - 1) / 2 bits representing the edges of the graph. All bytes of a graph6 file are in the range 63..126, which are the printable ASCII characters, therefore a bit vector is represented by a sequence of bytes in which each byte encode only 6 bits.

    The format does not support specifying the ids of the edges, therefore the reader will number them from 0 to m-1 in the order in the bit vector. The order, and the format details can be found here.

    The 'graph6' format is efficient for dense graph, for dense graphs the 'sparse6' format should be used.

    Self edges and parallel edges are not supported by the format.

    File with a graph in 'graph6' format usually have the extension .g6.

    Author:
    Barak Ugav
    See Also:
    Graph6GraphWriter
    • Constructor Detail

      • Graph6GraphReader

        public Graph6GraphReader()
        Create a new reader.
    • Method Detail

      • readGraph

        public IntGraph readGraph​(Reader reader)
        Description copied from interface: GraphReader
        Read a graph from an I/O reader.
        Parameters:
        reader - an I/O reader that contain a graph description
        Returns:
        a new graph read from the reader
      • readGraph

        public IntGraph readGraph​(File file)
        Description copied from interface: GraphReader
        Read a graph from a file.
        Parameters:
        file - a file that contain a graph description
        Returns:
        a new graph read from the file
      • readGraph

        public IntGraph readGraph​(String path)
        Description copied from interface: GraphReader
        Read a graph from a file, given a path to it.
        Parameters:
        path - a path to a file that contain a graph description
        Returns:
        a new graph read from the file