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

GraphReader Class Template Reference
[Input Output]

#include <lemon/graph_reader.h>

List of all members.


Detailed Description

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

The GraphReader 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 file to be read 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 GraphReader is very similar to the GraphWriter but the reading method does not depend on the order the given commands (i.e. you don't have to insist on the order in which the maps are given in the file).

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

      GraphReader<ListGraph> 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 readEdgeMap() member function you can give an edge map reading command similar to the NodeMaps.

      reader.readEdgeMap("weight", weightMap);
      reader.readEdgeMap("label", labelMap);

With readNode() and readEdge() functions you can read labeled Nodes and Edges.

      reader.readNode("source", sourceNode);
      reader.readNode("target", targetNode);
     
      reader.readEdge("observed", edge);

With the readAttribute() functions you can read an attribute into 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 executes all the commands.

      reader.run();

See also:
DefaultReaderTraits

QuotedStringReader

GraphWriter

Graph Input-Output

Author:
Balazs Dezso


Public Member Functions

 GraphReader (std::istream &_is, typename SmartParameter< Graph >::Type _graph, const DefaultSkipper &_skipper=DefaultSkipper())
 Construct a new GraphReader.
 GraphReader (const std::string &_filename, typename SmartParameter< Graph >::Type _graph, const DefaultSkipper &_skipper=DefaultSkipper())
 Construct a new GraphReader.
 GraphReader (LemonReader &_reader, typename SmartParameter< Graph >::Type _graph, const DefaultSkipper &_skipper=DefaultSkipper())
 Construct a new GraphReader.
 ~GraphReader ()
 Destruct the graph reader.
template<typename Map>
GraphReaderreadNodeMap (std::string name, Map &map)
 Give a new node map reading command to the reader.
template<typename Reader, typename Map>
GraphReaderreadNodeMap (std::string name, Map &map, const Reader &reader=Reader())
 Give a new node map reading command to the reader.
template<typename Reader>
GraphReaderskipNodeMap (std::string name, const Reader &reader=Reader())
 Give a new node map skipping command to the reader.
template<typename Map>
GraphReaderreadEdgeMap (std::string name, Map &map)
 Give a new edge map reading command to the reader.
template<typename Reader, typename Map>
GraphReaderreadEdgeMap (std::string name, Map &map, const Reader &reader=Reader())
 Give a new edge map reading command to the reader.
template<typename Reader>
GraphReaderskipEdgeMap (std::string name, const Reader &reader=Reader())
 Give a new edge map skipping command to the reader.
GraphReaderreadNode (std::string name, Node &node)
 Give a new labeled node reading command to the reader.
GraphReaderreadEdge (std::string name, Edge &edge)
 Give a new labeled edge reading command to the reader.
template<typename Value>
GraphReaderreadAttribute (std::string name, Value &value)
 Give a new attribute reading command.
template<typename Reader, typename Value>
GraphReaderreadAttribute (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.


Constructor & Destructor Documentation

GraphReader std::istream _is,
typename SmartParameter< Graph >::Type  _graph,
const DefaultSkipper _skipper = DefaultSkipper()
[inline]
 

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

GraphReader const std::string _filename,
typename SmartParameter< Graph >::Type  _graph,
const DefaultSkipper _skipper = DefaultSkipper()
[inline]
 

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

GraphReader LemonReader _reader,
typename SmartParameter< Graph >::Type  _graph,
const DefaultSkipper _skipper = DefaultSkipper()
[inline]
 

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

~GraphReader  )  [inline]
 

Destruct the graph reader.


Member Function Documentation

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

Give a new node map reading command to the reader.

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

Give a new node map reading command to the reader.

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

Give a new node map skipping command to the reader.

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

Give a new edge map reading command to the reader.

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

Give a new edge map reading command to the reader.

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

Give a new edge map skipping command to the reader.

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

Give a new labeled node reading command to the reader.

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

Give a new labeled edge reading command to the reader.

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

Give a new attribute reading command.

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

Give a new attribute reading command.

operator LemonReader &  )  [inline]
 

Conversion operator to LemonReader. It makes possible to access the encapsulated LemonReader, this way you can attach to this reader new instances of LemonReader::SectionReader. For more details see the Background of Reading and Writing.

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.


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