Class LedaGraphReader
- All Implemented Interfaces:
GraphReader<Integer,Integer>
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:
-
Constructor Summary
Constructors -
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 IntGraphBuilderreadIntoBuilder(Reader reader) Read a graph from an I/O reader into aGraphBuilder.voidsetEdgesWeightsKey(String edgesWeightsKey) Sets the key of the edges weights that will be read.voidsetVerticesWeightsKey(String verticesWeightsKey) Sets the key of the vertices weights that will be read.
-
Constructor Details
-
LedaGraphReader
public LedaGraphReader()Create a new reader.
-
-
Method Details
-
setVerticesWeightsKey
Sets the key of the vertices weights that will be read.When the reader reads a graph with vertices weights,
Weightswill 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
Sets the key of the edges weights that will be read.When the reader reads a graph with edges weights,
Weightswill 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
Description copied from interface:GraphReaderRead 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:GraphReaderRead 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:GraphReaderRead 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:GraphReaderRead a graph from an I/O reader into aGraphBuilder.- Specified by:
readIntoBuilderin 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
-