Package com.jgalgo.io

Class LedaGraphReader

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

    public final class LedaGraphReader
    extends Object
    Read 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.

    When the reader reads a graph from a file with weights, it will be added to the graph as a Weights object with key "weight", for both vertices and edges. The weights are later available view Graph.verticesWeights(String). To change the weights key, use setVerticesWeightsKey(String) and setEdgesWeightsKey(String).

    Author:
    Barak Ugav
    See Also:
    LedaGraphWriter
    • Constructor Detail

      • LedaGraphReader

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

      • setVerticesWeightsKey

        public void setVerticesWeightsKey​(String verticesWeightsKey)
        Sets the key of the vertices weights that will be read.

        When the reader reads a graph with vertices weights, Weights will be added to the built graph. By default, the weights will be added with key "weight". Use this method to specify a different key.

        Parameters:
        verticesWeightsKey - the key of the vertices weights that will be read
      • setEdgesWeightsKey

        public void setEdgesWeightsKey​(String edgesWeightsKey)
        Sets the key of the edges weights that will be read.

        When the reader reads a graph with edges weights, Weights will be added to the built graph. By default, the weights will be added with key "weight". Use this method to specify a different key.

        Parameters:
        edgesWeightsKey - the key of the edges weights that will be read
      • 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