Package com.jgalgo.io

Class LedaGraphWriter

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

    public final class LedaGraphWriter
    extends Object
    Write a graph in 'LEDA' format.

    The LEDA format is a simple format for both directed and undirected graphs, used by the LEDA library. Vertices are numbered from 1 to n, and edges are numbered from 1 to m. It support a single weight for vertices and a single weight for edges. The weights can be any primitive, or a string.

    By default, the writer will write the graph without any weights. Its possible to write one of the vertices weights and one of the edges weights in the format. Use the setVerticesWeightsKey(String) and setEdgesWeightsKey(String) methods to specify the keys of the weights to write.

    Author:
    Barak Ugav
    See Also:
    LedaGraphReader
    • Constructor Detail

      • LedaGraphWriter

        public LedaGraphWriter()
        Create a new writer.
    • Method Detail

      • setVerticesWeightsKey

        public void setVerticesWeightsKey​(String verticesWeightsKey)
        Set the key of the vertices weights to write.

        By default, the writer will write the graph without any weights. Use this method to specify the key of the vertices weights to write.

        Parameters:
        verticesWeightsKey - the key of the vertices weights to write, or null to write no vertices weights
        See Also:
        Graph.verticesWeights(String)
      • setEdgesWeightsKey

        public void setEdgesWeightsKey​(String edgesWeightsKey)
        Set the key of the edges weights to write.

        By default, the writer will write the graph without any weights. Use this method to specify the key of the edges weights to write.

        Parameters:
        edgesWeightsKey - the key of the edges weights to write, or null to write no edges weights
        See Also:
        Graph.edgesWeights(String)
      • writeGraph

        public final void writeGraph​(Graph<V,​E> graph,
                                     Writer writer)
        Description copied from interface: GraphWriter
        Write a graph to an I/O writer.
        Specified by:
        writeGraph in interface GraphWriter<V,​E>
        Parameters:
        graph - a graph
        writer - an I/O writer to which the graph description will be written to