UGraphReader Class Template Reference
[Lemon Input-Output]

#include <lemon/graph_reader.h>

List of all members.


Detailed Description

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

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

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 UGraphReader is very similar to the UGraphWriter but the reading method does not depend on the order of the given commands.

The reader object suppose that each not read 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.

      UGraphReader<ListUGraph> 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.skipNodeMap("description", desc);
     
      reader.readNodeMap("color", colorMap);

With the readUEdgeMap() member function you can give an uedge map reading command similar to the NodeMaps.

      reader.readUEdgeMap("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 readUEdge() functions you can read labeled Nodes and UEdges.

      reader.readNode("source", sourceNode);
      reader.readNode("target", targetNode);
     
      reader.readUEdge("observed", uEdge);

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

UGraphWriter

Graph Input-Output

Author:
Balazs Dezso


Public Member Functions

 UGraphReader (std::istream &_is, Graph &_graph, const DefaultSkipper &_skipper=DefaultSkipper())
 Construct a new UGraphReader.
 UGraphReader (const std::string &_filename, Graph &_graph, const DefaultSkipper &_skipper=DefaultSkipper())
 Construct a new UGraphReader.
 UGraphReader (LemonReader &_reader, Graph &_graph, const DefaultSkipper &_skipper=DefaultSkipper())
 Construct a new UGraphReader.
 ~UGraphReader ()
 Destruct the graph reader.
template<typename Map>
UGraphReaderreadNodeMap (std::string name, Map &map)
 Give a new node map reading command to the reader.
template<typename Reader, typename Map>
UGraphReaderreadNodeMap (std::string name, Map &map, const Reader &reader=Reader())
 Give a new node map reading command to the reader.
template<typename Reader>
UGraphReaderskipNodeMap (std::string name, const Reader &reader=Reader())
 Give a new node map skipping command to the reader.
template<typename Map>
UGraphReaderreadUEdgeMap (std::string name, Map &map)
 Give a new undirected edge map reading command to the reader.
template<typename Reader, typename Map>
UGraphReaderreadUEdgeMap (std::string name, Map &map, const Reader &reader=Reader())
 Give a new undirected edge map reading command to the reader.
template<typename Reader>
UGraphReaderskipUEdgeMap (std::string name, const Reader &reader=Reader())
 Give a new undirected edge map skipping command to the reader.
template<typename Map>
UGraphReaderreadEdgeMap (std::string name, Map &map)
 Give a new edge map reading command to the reader.
template<typename Reader, typename Map>
UGraphReaderreadEdgeMap (std::string name, Map &map, const Reader &reader=Reader())
 Give a new edge map reading command to the reader.
template<typename Reader>
UGraphReaderskipEdgeMap (std::string name, const Reader &reader=Reader())
 Give a new edge map skipping command to the reader.
UGraphReaderreadNode (std::string name, Node &node)
 Give a new labeled node reading command to the reader.
UGraphReaderreadEdge (std::string name, Edge &edge)
 Give a new labeled edge reading command to the reader.
UGraphReaderreadUEdge (std::string name, UEdge &edge)
 Give a new labeled undirected edge reading command to the reader.
template<typename Value>
UGraphReaderreadAttribute (std::string name, Value &value)
 Give a new attribute reading command.
template<typename Reader, typename Value>
UGraphReaderreadAttribute (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.
bool isLabelReader () const
 Returns true if the reader can give back the items by its label.Returns true if the reader can give back the items by its label.
void readLabel (std::istream &is, Node &node) const
 Gives back the node by its label.
void readLabel (std::istream &is, Edge &edge) const
 Gives back the edge by its label.
void readLabel (std::istream &is, UEdge &uedge) const
 Gives back the undirected edge by its label.


Constructor & Destructor Documentation

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

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

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

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

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

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

~UGraphReader (  )  [inline]

Destruct the graph reader.


Member Function Documentation

UGraphReader& readNodeMap ( std::string  name,
Map &  map 
) [inline]

Give a new node map reading command to the reader.

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

Give a new node map reading command to the reader.

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

Give a new node map skipping command to the reader.

UGraphReader& readUEdgeMap ( std::string  name,
Map &  map 
) [inline]

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

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

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

UGraphReader& skipUEdgeMap ( std::string  name,
const Reader &  reader = Reader() 
) [inline]

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

UGraphReader& readEdgeMap ( std::string  name,
Map &  map 
) [inline]

Give a new edge map reading command to the reader.

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

Give a new edge map reading command to the reader.

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

Give a new edge map skipping command to the reader.

UGraphReader& readNode ( std::string  name,
Node &  node 
) [inline]

Give a new labeled node reading command to the reader.

UGraphReader& readEdge ( std::string  name,
Edge &  edge 
) [inline]

Give a new labeled edge reading command to the reader.

UGraphReader& readUEdge ( std::string  name,
UEdge &  edge 
) [inline]

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

UGraphReader& readAttribute ( std::string  name,
Value &  value 
) [inline]

Give a new attribute reading command.

UGraphReader& 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.

void readLabel ( std::istream &  is,
Node &  node 
) const [inline]

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

void readLabel ( std::istream &  is,
Edge &  edge 
) const [inline]

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

void readLabel ( std::istream &  is,
UEdge &  uedge 
) const [inline]

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


The documentation for this class was generated from the following file:
Generated on Tue Oct 31 09:50:32 2006 for LEMON by  doxygen 1.5.1