Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

UndirGraphReader Class Template Reference
[Input Output]

#include <lemon/graph_reader.h>

List of all members.


Detailed Description

template<typename _Graph, typename _ReaderTraits = DefaultReaderTraits>
class lemon::UndirGraphReader< _Graph, _ReaderTraits >

The UndirGraphReader class provides the graph input. Before you read this documentation it might be useful to read the general description of Graph Input-Output.

If you don't need very sophisticated behaviour then you can use the versions of the public function readGraph() to read a graph (or a max flow instance etc).

The given file format may contain several maps and labeled nodes or edges.

If you read a graph you need not read all the maps and items just those that you need. The interface of the UndirGraphReader is very similar to the UndirGraphWriter but the reading method does not depend on the order of the given commands.

The reader object suppose that each not readed value does not contain whitespaces, therefore it has some extra possibilities to control how it should skip the values when the string representation contains spaces.

      UndirGraphReader<UndirListGraph> reader(std::cin, graph);

The readNodeMap() function reads a map from the @nodeset section. If there is a map that you do not want to read from the file and there is whitespace in the string represenation of the values then you should call the skipNodeMap() template member function with proper parameters.

      reader.readNodeMap("coords", coords);
     
      reader.readNodeMap<QuotedStringReader>("label", labelMap);
      reader.skipNodeMap<QuotedStringReader>("description");
     
      reader.readNodeMap("color", colorMap);

With the readUndirEdgeMap() member function you can give an undir edge map reading command similar to the NodeMaps.

      reader.readUndirEdgeMap("capacity", capacityMap);

The reading of the directed edge maps is just a syntactical sugar. It reads two undirected edgemaps into a directed edge map. The undirected edge maps' name should be start with the '+' and the '-' character and the same.

      reader.readEdgeMap("flow", flowMap);

With readNode() and readUndirEdge() functions you can read labeled Nodes and UndirEdges.

      reader.readNode("source", sourceNode);
      reader.readNode("target", targetNode);
     
      reader.readUndirEdge("observed", undirEdge);

With the readAttribute() functions you can read an attribute in a variable. You can specify the reader for the attribute as the nodemaps.

After you give all read commands you must call the run() member function, which execute all the commands.

      reader.run();

See also:
GraphReader

DefaultReaderTraits

UndirGraphWriter

Graph Input-Output

Author:
Balazs Dezso


Public Member Functions

 UndirGraphReader (std::istream &_is, Graph &_graph, const DefaultSkipper &_skipper=DefaultSkipper())
 Construct a new UndirGraphReader.
 UndirGraphReader (const std::string &_filename, Graph &_graph, const DefaultSkipper &_skipper=DefaultSkipper())
 Construct a new UndirGraphReader.
 UndirGraphReader (LemonReader &_reader, Graph &_graph, const DefaultSkipper &_skipper=DefaultSkipper())
 Construct a new UndirGraphReader.
 ~UndirGraphReader ()
 Destruct the graph reader.
template<typename Map>
UndirGraphReaderreadNodeMap (std::string name, Map &map)
 Give a new node map reading command to the reader.
template<typename Reader, typename Map>
UndirGraphReaderreadNodeMap (std::string name, Map &map, const Reader &reader=Reader())
 Give a new node map reading command to the reader.
template<typename Reader>
UndirGraphReaderskipNodeMap (std::string name, const Reader &reader=Reader())
 Give a new node map skipping command to the reader.
template<typename Map>
UndirGraphReaderreadUndirEdgeMap (std::string name, Map &map)
 Give a new undirected edge map reading command to the reader.
template<typename Reader, typename Map>
UndirGraphReaderreadUndirEdgeMap (std::string name, Map &map, const Reader &reader=Reader())
 Give a new undirected edge map reading command to the reader.
template<typename Reader>
UndirGraphReaderskipUndirEdgeMap (std::string name, const Reader &reader=Reader())
 Give a new undirected edge map skipping command to the reader.
template<typename Map>
UndirGraphReaderreadEdgeMap (std::string name, Map &map)
 Give a new edge map reading command to the reader.
template<typename Reader, typename Map>
UndirGraphReaderreadEdgeMap (std::string name, Map &map, const Reader &reader=Reader())
 Give a new edge map reading command to the reader.
template<typename Reader>
UndirGraphReaderskipEdgeMap (std::string name, const Reader &reader=Reader())
 Give a new edge map skipping command to the reader.
UndirGraphReaderreadNode (std::string name, Node &node)
 Give a new labeled node reading command to the reader.
UndirGraphReaderreadEdge (std::string name, Edge &edge)
 Give a new labeled edge reading command to the reader.
UndirGraphReaderreadUndirEdge (std::string name, UndirEdge &edge)
 Give a new labeled undirected edge reading command to the reader.
template<typename Value>
UndirGraphReaderreadAttribute (std::string name, Value &value)
 Give a new attribute reading command.
template<typename Reader, typename Value>
UndirGraphReaderreadAttribute (std::string name, Value &value, const Reader &reader)
 Give a new attribute reading command.
 operator LemonReader & ()
 Conversion operator to LemonReader.
void run ()
 Executes the reading commands.
Node readId (std::istream &is, Node) const
 Gives back the node by its id.
Edge readId (std::istream &is, Edge) const
 Gives back the edge by its id.
UndirEdge readId (std::istream &is, UndirEdge) const
 Gives back the undirected edge by its id.


Constructor & Destructor Documentation

UndirGraphReader std::istream _is,
Graph &  _graph,
const DefaultSkipper _skipper = DefaultSkipper()
[inline]
 

Construct a new UndirGraphReader. It reads into the given graph and it use the given reader as the default skipper.

UndirGraphReader const std::string _filename,
Graph &  _graph,
const DefaultSkipper _skipper = DefaultSkipper()
[inline]
 

Construct a new UndirGraphReader. It reads into the given graph and it use the given reader as the default skipper.

UndirGraphReader LemonReader _reader,
Graph &  _graph,
const DefaultSkipper _skipper = DefaultSkipper()
[inline]
 

Construct a new UndirGraphReader. It reads into the given graph and it use the given reader as the default skipper.

~UndirGraphReader  )  [inline]
 

Destruct the graph reader.


Member Function Documentation

UndirGraphReader& readNodeMap std::string  name,
Map &  map
[inline]
 

Give a new node map reading command to the reader.

UndirGraphReader& readNodeMap std::string  name,
Map &  map,
const Reader &  reader = Reader()
[inline]
 

Give a new node map reading command to the reader.

UndirGraphReader& skipNodeMap std::string  name,
const Reader &  reader = Reader()
[inline]
 

Give a new node map skipping command to the reader.

UndirGraphReader& readUndirEdgeMap std::string  name,
Map &  map
[inline]
 

Give a new undirected edge map reading command to the reader.

UndirGraphReader& readUndirEdgeMap std::string  name,
Map &  map,
const Reader &  reader = Reader()
[inline]
 

Give a new undirected edge map reading command to the reader.

UndirGraphReader& skipUndirEdgeMap std::string  name,
const Reader &  reader = Reader()
[inline]
 

Give a new undirected edge map skipping command to the reader.

UndirGraphReader& readEdgeMap std::string  name,
Map &  map
[inline]
 

Give a new edge map reading command to the reader.

UndirGraphReader& readEdgeMap std::string  name,
Map &  map,
const Reader &  reader = Reader()
[inline]
 

Give a new edge map reading command to the reader.

UndirGraphReader& skipEdgeMap std::string  name,
const Reader &  reader = Reader()
[inline]
 

Give a new edge map skipping command to the reader.

UndirGraphReader& readNode std::string  name,
Node &  node
[inline]
 

Give a new labeled node reading command to the reader.

UndirGraphReader& readEdge std::string  name,
Edge &  edge
[inline]
 

Give a new labeled edge reading command to the reader.

UndirGraphReader& readUndirEdge std::string  name,
UndirEdge &  edge
[inline]
 

Give a new labeled undirected edge reading command to the reader.

UndirGraphReader& readAttribute std::string  name,
Value &  value
[inline]
 

Give a new attribute reading command.

UndirGraphReader& readAttribute std::string  name,
Value &  value,
const Reader &  reader
[inline]
 

Give a new attribute reading command.

operator LemonReader &  )  [inline]
 

Conversion operator to LemonReader. It make possible to access the encapsulated LemonReader, this way you can attach to this reader new instances of LemonReader::SectionReader.

void run  )  [inline]
 

Executes the reading commands.

Node readId std::istream is,
Node 
const [inline]
 

It reads an id from the stream and gives back which node belongs to it. It is possible only if there was read an "id" named node map.

Edge readId std::istream is,
Edge 
const [inline]
 

It reads an id from the stream and gives back which edge belongs to it. It is possible only if there was read an "id" named edge map.

UndirEdge readId std::istream is,
UndirEdge 
const [inline]
 

It reads an id from the stream and gives back which undirected edge belongs to it. It is possible only if there was read an "id" named edge map.


The documentation for this class was generated from the following file:
Generated on Sat Aug 27 14:15:35 2005 for LEMON by  doxygen 1.4.4