Class Digraph6GraphWriter
- All Implemented Interfaces:
GraphWriter<Integer,
Integer>
'digraph6' is a format for storing directed 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 digraph6 file contains a bit vector with n^2
bits
representing the edges of the graph. All bytes of a digraph6 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 writer will not write them. Nevertheless,
its possible to write and later read the graph using the Digraph6GraphReader
class while keeping the edges
ids: if the edges in the written graph are numbered 0..m-1, and when they are iterated from 0
to m-1
they are also ordered by the order of the bit vector, then the reader will assigned the same ids to the edges. The
order of the bit vector and the format details can be found
here. This way of keeping the edges ids is
enforced by the writer by default, but can be disabled by calling keepEdgesIds(boolean)
with false
.
The 'digraph6' format support directed graphs only, for undirected graphs the 'graph6' format should be used.
Parallel edges are not supported by the format.
File with a graph in 'digraph6' format usually have the extension .d6
.
- Author:
- Barak Ugav
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
keepEdgesIds
(boolean enable) Enable or disable keeping the edges ids.final void
writeGraph
(Graph<Integer, Integer> graph, Writer writer) Write a graph to an I/O writer.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.jgalgo.io.GraphWriter
writeGraph, writeGraph
-
Constructor Details
-
Digraph6GraphWriter
public Digraph6GraphWriter()Create a new writer.
-
-
Method Details
-
keepEdgesIds
public void keepEdgesIds(boolean enable) Enable or disable keeping the edges ids.The format does not support specifying the ids of the edges, therefore the writer will not write them. Nevertheless, its possible to write and later read the graph using the
Digraph6GraphReader
class while keeping the edges ids: if the edges in the written graph are numbered 0..m-1, and when they are iterated from0
tom-1
they are also ordered by the order of the bit vector, then the reader will assigned the same ids to the edges. The order of the bit vector and the format details can be found here.If this option is enabled, which is also the default, if a graph is written by the writer and the edges iterated from
0
tom-1
are not ordered by the order of the bit vector, then an exception will be thrown. If this option is disabled, the ids of the edges will be ignored and there is not guarantee that the reader will assign the same ids to the edges.- Parameters:
enable
-true
to enable keeping the edges ids,false
to disable it
-
writeGraph
Description copied from interface:GraphWriter
Write a graph to an I/O writer.- Specified by:
writeGraph
in interfaceGraphWriter<V,
E> - Parameters:
graph
- a graphwriter
- an I/O writer to which the graph description will be written to
-