GraphReader< _Graph, _ReaderTraits > Class Template Reference
[Lemon Input-Output]


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.

The file to be read may contain several maps and labeled (designated) 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 read 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.skipNodeMap("description", desc);
     
      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
#include <lemon/graph_reader.h>

List of all members.

Public Member Functions

 GraphReader (std::istream &_is, Graph &_graph, const DefaultSkipper &_skipper=DefaultSkipper())
 Construct a new GraphReader.
 GraphReader (const std::string &_filename, Graph &_graph, const DefaultSkipper &_skipper=DefaultSkipper())
 Construct a new GraphReader.
 GraphReader (LemonReader &_reader, Graph &_graph, const DefaultSkipper &_skipper=DefaultSkipper())
 Construct a new GraphReader.
 ~GraphReader ()
template<typename Map >
GraphReaderreadNodeMap (std::string name, Map &map)
template<typename ItemReader , typename Map >
GraphReaderreadNodeMap (std::string name, Map &map, const ItemReader &ir=ItemReader())
template<typename ItemReader >
GraphReaderskipNodeMap (std::string name, const ItemReader &ir=ItemReader())
template<typename Map >
GraphReaderreadEdgeMap (std::string name, Map &map)
template<typename ItemReader , typename Map >
GraphReaderreadEdgeMap (std::string name, Map &map, const ItemReader &ir=ItemReader())
template<typename ItemReader >
GraphReaderskipEdgeMap (std::string name, const ItemReader &ir=ItemReader())
GraphReaderreadNode (std::string name, Node &node)
GraphReaderreadEdge (std::string name, Edge &edge)
template<typename Value >
GraphReaderreadAttribute (std::string name, Value &value)
template<typename ItemReader , typename Value >
GraphReaderreadAttribute (std::string name, Value &value, const ItemReader &ir=ItemReader())
 operator LemonReader & ()
 Conversion operator to LemonReader.
void run ()
bool isLabelReader () const
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.


Constructor & Destructor Documentation

GraphReader ( std::istream &  _is,
Graph &  _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,
Graph &  _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,
Graph &  _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 ItemReader &  ir = ItemReader() 
) [inline]

Give a new node map reading command to the reader.

GraphReader& skipNodeMap ( std::string  name,
const ItemReader &  ir = ItemReader() 
) [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 ItemReader &  ir = ItemReader() 
) [inline]

Give a new edge map reading command to the reader.

GraphReader& skipEdgeMap ( std::string  name,
const ItemReader &  ir = ItemReader() 
) [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 ItemReader &  ir = ItemReader() 
) [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.

bool isLabelReader (  )  const [inline]

Returns true if the reader can give back the items by its label.

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.


Generated on Thu Jun 4 04:04:24 2009 for LEMON by  doxygen 1.5.9