Class Sparse6GraphReader
- All Implemented Interfaces:
GraphReader<Integer,
Integer>
'sparse6' 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 space-efficient for large sparse 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 sparse6 file contains the number of vertices, following by a list of edges, encoded in bytes, each in range 63..126 which are the printable ASCII characters. Each byte encode 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 it reads them.
Self edges and parallel edges are supported by the format. The full description of the format can be found
here, which also define the 'graph6' format, which
is used for dense graph. See Graph6GraphReader
for reading graphs in 'graph6' format.
File with a graph in 'sparse6' format usually have the extension .s6
.
- Author:
- Barak Ugav
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionRead a graph from a file.Read a graph from an I/O reader.Read a graph from a file, given a path to it.final IntGraphBuilder
readIntoBuilder
(Reader reader) Read a graph from an I/O reader into aGraphBuilder
.
-
Constructor Details
-
Sparse6GraphReader
public Sparse6GraphReader()Create a new reader.
-
-
Method Details
-
readGraph
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
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
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
-
readIntoBuilder
Description copied from interface:GraphReader
Read a graph from an I/O reader into aGraphBuilder
.- Specified by:
readIntoBuilder
in interfaceGraphReader<Integer,
Integer> - Parameters:
reader
- an I/O reader that contain a graph description- Returns:
- a graph builder containing the vertices and edge read from the reader
-