lemon/graph_reader.h
changeset 1600 c421cc1b70ed
parent 1534 b86aad11f842
child 1705 3f63d9db307b
equal deleted inserted replaced
2:3b272d0d07e0 3:5904e8a90656
    34   /// \brief The graph reader class.
    34   /// \brief The graph reader class.
    35   ///
    35   ///
    36   /// The \c GraphReader class provides the graph input. 
    36   /// The \c GraphReader class provides the graph input. 
    37   /// Before you read this documentation it might be useful to read the general
    37   /// Before you read this documentation it might be useful to read the general
    38   /// description of  \ref graph-io-page "Graph Input-Output".
    38   /// description of  \ref graph-io-page "Graph Input-Output".
       
    39   ///
    39   /// If you don't need very sophisticated
    40   /// If you don't need very sophisticated
    40   /// behaviour then you can use the versions of the public function
    41   /// behaviour then you can use the versions of the public function
    41   /// \ref readGraph() to read a graph (or a max flow instance etc).
    42   /// \ref readGraph() to read a graph (or a max flow instance etc).
    42   ///
    43   ///
    43   /// The given file format may contain several maps and labeled nodes or 
    44   /// The file to be read may contain several maps and labeled nodes or 
    44   /// edges.
    45   /// edges.
    45   ///
    46   ///
    46   /// If you read a graph you need not read all the maps and items just those
    47   /// If you read a graph you need not read all the maps and items just those
    47   /// that you need. The interface of the \c GraphReader is very similar to
    48   /// that you need. The interface of the \c GraphReader is very similar to
    48   /// the GraphWriter but the reading method does not depend on the order the
    49   /// the GraphWriter but the reading method does not depend on the order the
    49   /// given commands.
    50   /// given commands (i.e. you don't have to insist on the order in which the
    50   ///
    51   /// maps are given in the file).
    51   /// The reader object suppose that each not readed value does not contain 
    52   ///
       
    53   /// The reader object assumes that not readed values do not contain 
    52   /// whitespaces, therefore it has some extra possibilities to control how
    54   /// whitespaces, therefore it has some extra possibilities to control how
    53   /// it should skip the values when the string representation contains spaces.
    55   /// it should skip the values when the string representation contains spaces.
    54   ///
    56   ///
    55   /// \code
    57   /// \code
    56   /// GraphReader<ListGraph> reader(std::cin, graph);
    58   /// GraphReader<ListGraph> reader(std::cin, graph);
    88   ///
    90   ///
    89   /// reader.readEdge("observed", edge);
    91   /// reader.readEdge("observed", edge);
    90   /// \endcode
    92   /// \endcode
    91   ///
    93   ///
    92   /// With the \c readAttribute() functions you can read an attribute
    94   /// With the \c readAttribute() functions you can read an attribute
    93   /// in a variable. You can specify the reader for the attribute as
    95   /// into a variable. You can specify the reader for the attribute as
    94   /// the nodemaps.
    96   /// the nodemaps.
    95   ///
    97   ///
    96   /// After you give all read commands you must call the \c run() member
    98   /// After you give all read commands you must call the \c run() member
    97   /// function, which execute all the commands.
    99   /// function, which executes all the commands.
    98   ///
   100   ///
    99   /// \code
   101   /// \code
   100   /// reader.run();
   102   /// reader.run();
   101   /// \endcode
   103   /// \endcode
   102   ///
   104   ///
   117     typedef typename ReaderTraits::Skipper DefaultSkipper;
   119     typedef typename ReaderTraits::Skipper DefaultSkipper;
   118 
   120 
   119     /// \brief Construct a new GraphReader.
   121     /// \brief Construct a new GraphReader.
   120     ///
   122     ///
   121     /// Construct a new GraphReader. It reads into the given graph
   123     /// Construct a new GraphReader. It reads into the given graph
   122     /// and it use the given reader as the default skipper.
   124     /// and it uses the given reader as the default skipper.
   123     GraphReader(std::istream& _is, 
   125     GraphReader(std::istream& _is, 
   124 		typename SmartParameter<Graph>::Type _graph, 
   126 		typename SmartParameter<Graph>::Type _graph, 
   125 		const DefaultSkipper& _skipper = DefaultSkipper()) 
   127 		const DefaultSkipper& _skipper = DefaultSkipper()) 
   126       : reader(new LemonReader(_is)), own_reader(true), skipper(_skipper),
   128       : reader(new LemonReader(_is)), own_reader(true), skipper(_skipper),
   127 	nodeset_reader(*reader, _graph, std::string(), skipper),
   129 	nodeset_reader(*reader, _graph, std::string(), skipper),
   132 	attribute_reader(*reader, std::string()) {}
   134 	attribute_reader(*reader, std::string()) {}
   133 
   135 
   134     /// \brief Construct a new GraphReader.
   136     /// \brief Construct a new GraphReader.
   135     ///
   137     ///
   136     /// Construct a new GraphReader. It reads into the given graph
   138     /// Construct a new GraphReader. It reads into the given graph
   137     /// and it use the given reader as the default skipper.
   139     /// and it uses the given reader as the default skipper.
   138     GraphReader(const std::string& _filename, 
   140     GraphReader(const std::string& _filename, 
   139 		typename SmartParameter<Graph>::Type _graph, 
   141 		typename SmartParameter<Graph>::Type _graph, 
   140 		const DefaultSkipper& _skipper = DefaultSkipper()) 
   142 		const DefaultSkipper& _skipper = DefaultSkipper()) 
   141       : reader(new LemonReader(_filename)), own_reader(true), 
   143       : reader(new LemonReader(_filename)), own_reader(true), 
   142 	skipper(_skipper),
   144 	skipper(_skipper),
   148 	attribute_reader(*reader, std::string()) {}
   150 	attribute_reader(*reader, std::string()) {}
   149 
   151 
   150     /// \brief Construct a new GraphReader.
   152     /// \brief Construct a new GraphReader.
   151     ///
   153     ///
   152     /// Construct a new GraphReader. It reads into the given graph
   154     /// Construct a new GraphReader. It reads into the given graph
   153     /// and it use the given reader as the default skipper.
   155     /// and it uses the given reader as the default skipper.
   154     GraphReader(LemonReader& _reader, 
   156     GraphReader(LemonReader& _reader, 
   155 		typename SmartParameter<Graph>::Type _graph, 
   157 		typename SmartParameter<Graph>::Type _graph, 
   156 		const DefaultSkipper& _skipper = DefaultSkipper()) 
   158 		const DefaultSkipper& _skipper = DefaultSkipper()) 
   157       : reader(_reader), own_reader(false), skipper(_skipper),
   159       : reader(_reader), own_reader(false), skipper(_skipper),
   158 	nodeset_reader(*reader, _graph, std::string(), skipper),
   160 	nodeset_reader(*reader, _graph, std::string(), skipper),
   168     ~GraphReader() {
   170     ~GraphReader() {
   169       if (own_reader) 
   171       if (own_reader) 
   170 	delete reader;
   172 	delete reader;
   171     }
   173     }
   172 
   174 
   173     /// \brief Add a new node map reader command for the reader.
   175     /// \brief Give a new node map reading command to the reader.
   174     ///
   176     ///
   175     /// Add a new node map reader command for the reader.
   177     /// Give a new node map reading command to the reader.
   176     template <typename Map>
   178     template <typename Map>
   177     GraphReader& readNodeMap(std::string name, Map& map) {
   179     GraphReader& readNodeMap(std::string name, Map& map) {
   178       nodeset_reader.readNodeMap(name, map);
   180       nodeset_reader.readNodeMap(name, map);
   179       return *this;
   181       return *this;
   180     }
   182     }
   183     GraphReader& readNodeMap(std::string name, const Map& map) {
   185     GraphReader& readNodeMap(std::string name, const Map& map) {
   184       nodeset_reader.readNodeMap(name, map);
   186       nodeset_reader.readNodeMap(name, map);
   185       return *this;
   187       return *this;
   186     }
   188     }
   187 
   189 
   188     /// \brief Add a new node map reader command for the reader.
   190     /// \brief Give a new node map reading command to the reader.
   189     ///
   191     ///
   190     /// Add a new node map reader command for the reader.
   192     /// Give a new node map reading command to the reader.
   191     template <typename Reader, typename Map>
   193     template <typename Reader, typename Map>
   192     GraphReader& readNodeMap(std::string name, Map& map, 
   194     GraphReader& readNodeMap(std::string name, Map& map, 
   193 			     const Reader& reader = Reader()) {
   195 			     const Reader& reader = Reader()) {
   194       nodeset_reader.readNodeMap(name, map, reader);
   196       nodeset_reader.readNodeMap(name, map, reader);
   195       return *this;
   197       return *this;
   200 			     const Reader& reader = Reader()) {
   202 			     const Reader& reader = Reader()) {
   201       nodeset_reader.readNodeMap(name, map, reader);
   203       nodeset_reader.readNodeMap(name, map, reader);
   202       return *this;
   204       return *this;
   203     }
   205     }
   204 
   206 
   205     /// \brief Add a new node map skipper command for the reader.
   207     /// \brief Give a new node map skipping command to the reader.
   206     ///
   208     ///
   207     /// Add a new node map skipper command for the reader.
   209     /// Give a new node map skipping command to the reader.
   208     template <typename Reader>
   210     template <typename Reader>
   209     GraphReader& skipNodeMap(std::string name, 
   211     GraphReader& skipNodeMap(std::string name, 
   210 			     const Reader& reader = Reader()) {
   212 			     const Reader& reader = Reader()) {
   211       nodeset_reader.skipNodeMap(name, reader);
   213       nodeset_reader.skipNodeMap(name, reader);
   212       return *this;
   214       return *this;
   213     }
   215     }
   214 
   216 
   215     /// \brief Add a new edge map reader command for the reader.
   217     /// \brief Give a new edge map reading command to the reader.
   216     ///
   218     ///
   217     /// Add a new edge map reader command for the reader.
   219     /// Give a new edge map reading command to the reader.
   218     template <typename Map>
   220     template <typename Map>
   219     GraphReader& readEdgeMap(std::string name, Map& map) { 
   221     GraphReader& readEdgeMap(std::string name, Map& map) { 
   220       edgeset_reader.readEdgeMap(name, map);
   222       edgeset_reader.readEdgeMap(name, map);
   221       return *this;
   223       return *this;
   222     }
   224     }
   226       edgeset_reader.readEdgeMap(name, map);
   228       edgeset_reader.readEdgeMap(name, map);
   227       return *this;
   229       return *this;
   228     }
   230     }
   229 
   231 
   230 
   232 
   231     /// \brief Add a new edge map reader command for the reader.
   233     /// \brief Give a new edge map reading command to the reader.
   232     ///
   234     ///
   233     /// Add a new edge map reader command for the reader.
   235     /// Give a new edge map reading command to the reader.
   234     template <typename Reader, typename Map>
   236     template <typename Reader, typename Map>
   235     GraphReader& readEdgeMap(std::string name, Map& map,
   237     GraphReader& readEdgeMap(std::string name, Map& map,
   236 			     const Reader& reader = Reader()) {
   238 			     const Reader& reader = Reader()) {
   237       edgeset_reader.readEdgeMap(name, map, reader);
   239       edgeset_reader.readEdgeMap(name, map, reader);
   238       return *this;
   240       return *this;
   243 			     const Reader& reader = Reader()) {
   245 			     const Reader& reader = Reader()) {
   244       edgeset_reader.readEdgeMap(name, map, reader);
   246       edgeset_reader.readEdgeMap(name, map, reader);
   245       return *this;
   247       return *this;
   246     }
   248     }
   247 
   249 
   248     /// \brief Add a new edge map skipper command for the reader.
   250     /// \brief Give a new edge map skipping command to the reader.
   249     ///
   251     ///
   250     /// Add a new edge map skipper command for the reader.
   252     /// Give a new edge map skipping command to the reader.
   251     template <typename Reader>
   253     template <typename Reader>
   252     GraphReader& skipEdgeMap(std::string name, 
   254     GraphReader& skipEdgeMap(std::string name, 
   253 			     const Reader& reader = Reader()) {
   255 			     const Reader& reader = Reader()) {
   254       edgeset_reader.skipEdgeMap(name, reader);
   256       edgeset_reader.skipEdgeMap(name, reader);
   255       return *this;
   257       return *this;
   256     }
   258     }
   257 
   259 
   258     /// \brief Add a new labeled node reader for the reader.
   260     /// \brief Give a new labeled node reading command to the reader.
   259     ///
   261     ///
   260     /// Add a new labeled node reader for the reader.
   262     /// Give a new labeled node reading command to the reader.
   261     GraphReader& readNode(std::string name, Node& node) {
   263     GraphReader& readNode(std::string name, Node& node) {
   262       node_reader.readNode(name, node);
   264       node_reader.readNode(name, node);
   263       return *this;
   265       return *this;
   264     }
   266     }
   265 
   267 
   266     /// \brief Add a new labeled edge reader for the reader.
   268     /// \brief Give a new labeled edge reading command to the reader.
   267     ///
   269     ///
   268     /// Add a new labeled edge reader for the reader.
   270     /// Give a new labeled edge reading command to the reader.
   269     GraphReader& readEdge(std::string name, Edge& edge) {
   271     GraphReader& readEdge(std::string name, Edge& edge) {
   270       edge_reader.readEdge(name, edge);
   272       edge_reader.readEdge(name, edge);
   271       return *this;
   273       return *this;
   272     }
   274     }
   273 
   275 
   274     /// \brief Add a new attribute reader command.
   276     /// \brief Give a new attribute reading command.
   275     ///
   277     ///
   276     ///  Add a new attribute reader command.
   278     ///  Give a new attribute reading command.
   277     template <typename Value>
   279     template <typename Value>
   278     GraphReader& readAttribute(std::string name, Value& value) {
   280     GraphReader& readAttribute(std::string name, Value& value) {
   279       attribute_reader.readAttribute(name, value);
   281       attribute_reader.readAttribute(name, value);
   280       return *this;
   282       return *this;
   281     }
   283     }
   282     
   284     
   283     /// \brief Add a new attribute reader command.
   285     /// \brief Give a new attribute reading command.
   284     ///
   286     ///
   285     ///  Add a new attribute reader command.
   287     ///  Give a new attribute reading command.
   286     template <typename Reader, typename Value>
   288     template <typename Reader, typename Value>
   287     GraphReader& readAttribute(std::string name, Value& value, 
   289     GraphReader& readAttribute(std::string name, Value& value, 
   288 			       const Reader& reader) {
   290 			       const Reader& reader) {
   289       attribute_reader.readAttribute<Reader>(name, value, reader);
   291       attribute_reader.readAttribute<Reader>(name, value, reader);
   290       return *this;
   292       return *this;
   291     }
   293     }
   292 
   294 
   293     /// \brief Conversion operator to LemonReader.
   295     /// \brief Conversion operator to LemonReader.
   294     ///
   296     ///
   295     /// Conversion operator to LemonReader. It make possible
   297     /// Conversion operator to LemonReader. It makes possible to access the
   296     /// to access the encapsulated \e LemonReader, this way
   298     /// encapsulated \e LemonReader, this way you can attach to this reader
   297     /// you can attach to this reader new instances of 
   299     /// new instances of \e LemonReader::SectionReader. For more details see
   298     /// \e LemonReader::SectionReader.
   300     /// the \ref rwbackground "Background of Reading and Writing".
   299     operator LemonReader&() {
   301     operator LemonReader&() {
   300       return *reader;
   302       return *reader;
   301     }
   303     }
   302 
   304 
   303     /// \brief Executes the reader commands.
   305     /// \brief Executes the reading commands.
   304     ///
   306     ///
   305     /// Executes the reader commands.
   307     /// Executes the reading commands.
   306     void run() {
   308     void run() {
   307       reader->run();
   309       reader->run();
   308     }
   310     }
   309 
   311 
   310     /// \brief Gives back the node by its id.
   312     /// \brief Gives back the node by its id.
   430   }
   432   }
   431 
   433 
   432 
   434 
   433   /// \brief The undir graph reader class.
   435   /// \brief The undir graph reader class.
   434   ///
   436   ///
       
   437   /// The \c UndirGraphReader class provides the graph input. 
       
   438   /// Before you read this documentation it might be useful to read the general
       
   439   /// description of  \ref graph-io-page "Graph Input-Output".
       
   440   ///
       
   441   /// If you don't need very sophisticated
       
   442   /// behaviour then you can use the versions of the public function
       
   443   /// \ref readGraph() to read a graph (or a max flow instance etc).
       
   444   ///
   435   /// The given file format may contain several maps and labeled nodes or 
   445   /// The given file format may contain several maps and labeled nodes or 
   436   /// edges.
   446   /// edges.
   437   ///
   447   ///
   438   /// If you read a graph you need not read all the maps and items just those
   448   /// If you read a graph you need not read all the maps and items just those
   439   /// that you need. The interface of the \c GraphReader is very similar to
   449   /// that you need. The interface of the \c UndirGraphReader is very similar
   440   /// the GraphWriter but the reading method does not depend on the order the
   450   /// to the UndirGraphWriter but the reading method does not depend on the
   441   /// given commands.
   451   /// order of the given commands.
   442   ///
   452   ///
   443   /// The reader object suppose that each not readed value does not contain 
   453   /// The reader object suppose that each not readed value does not contain 
   444   /// whitespaces, therefore it has some extra possibilities to control how
   454   /// whitespaces, therefore it has some extra possibilities to control how
   445   /// it should skip the values when the string representation contains spaces.
   455   /// it should skip the values when the string representation contains spaces.
   446   ///
   456   ///
   567     ~UndirGraphReader() {
   577     ~UndirGraphReader() {
   568       if (own_reader) 
   578       if (own_reader) 
   569 	delete reader;
   579 	delete reader;
   570     }
   580     }
   571 
   581 
   572     /// \brief Add a new node map reader command for the reader.
   582     /// \brief Give a new node map reading command to the reader.
   573     ///
   583     ///
   574     /// Add a new node map reader command for the reader.
   584     /// Give a new node map reading command to the reader.
   575     template <typename Map>
   585     template <typename Map>
   576     UndirGraphReader& readNodeMap(std::string name, Map& map) {
   586     UndirGraphReader& readNodeMap(std::string name, Map& map) {
   577       nodeset_reader.readNodeMap(name, map);
   587       nodeset_reader.readNodeMap(name, map);
   578       return *this;
   588       return *this;
   579     }
   589     }
   582     UndirGraphReader& readNodeMap(std::string name, const Map& map) {
   592     UndirGraphReader& readNodeMap(std::string name, const Map& map) {
   583       nodeset_reader.readNodeMap(name, map);
   593       nodeset_reader.readNodeMap(name, map);
   584       return *this;
   594       return *this;
   585     }
   595     }
   586 
   596 
   587     /// \brief Add a new node map reader command for the reader.
   597     /// \brief Give a new node map reading command to the reader.
   588     ///
   598     ///
   589     /// Add a new node map reader command for the reader.
   599     /// Give a new node map reading command to the reader.
   590     template <typename Reader, typename Map>
   600     template <typename Reader, typename Map>
   591     UndirGraphReader& readNodeMap(std::string name, Map& map, 
   601     UndirGraphReader& readNodeMap(std::string name, Map& map, 
   592 				  const Reader& reader = Reader()) {
   602 				  const Reader& reader = Reader()) {
   593       nodeset_reader.readNodeMap(name, map, reader);
   603       nodeset_reader.readNodeMap(name, map, reader);
   594       return *this;
   604       return *this;
   599 				  const Reader& reader = Reader()) {
   609 				  const Reader& reader = Reader()) {
   600       nodeset_reader.readNodeMap(name, map, reader);
   610       nodeset_reader.readNodeMap(name, map, reader);
   601       return *this;
   611       return *this;
   602     }
   612     }
   603 
   613 
   604     /// \brief Add a new node map skipper command for the reader.
   614     /// \brief Give a new node map skipping command to the reader.
   605     ///
   615     ///
   606     /// Add a new node map skipper command for the reader.
   616     /// Give a new node map skipping command to the reader.
   607     template <typename Reader>
   617     template <typename Reader>
   608     UndirGraphReader& skipNodeMap(std::string name, 
   618     UndirGraphReader& skipNodeMap(std::string name, 
   609 			     const Reader& reader = Reader()) {
   619 			     const Reader& reader = Reader()) {
   610       nodeset_reader.skipNodeMap(name, reader);
   620       nodeset_reader.skipNodeMap(name, reader);
   611       return *this;
   621       return *this;
   612     }
   622     }
   613 
   623 
   614     /// \brief Add a new undirected edge map reader command for the reader.
   624     /// \brief Give a new undirected edge map reading command to the reader.
   615     ///
   625     ///
   616     /// Add a new undirected edge map reader command for the reader.
   626     /// Give a new undirected edge map reading command to the reader.
   617     template <typename Map>
   627     template <typename Map>
   618     UndirGraphReader& readUndirEdgeMap(std::string name, Map& map) { 
   628     UndirGraphReader& readUndirEdgeMap(std::string name, Map& map) { 
   619       undir_edgeset_reader.readUndirEdgeMap(name, map);
   629       undir_edgeset_reader.readUndirEdgeMap(name, map);
   620       return *this;
   630       return *this;
   621     }
   631     }
   625       undir_edgeset_reader.readUndirEdgeMap(name, map);
   635       undir_edgeset_reader.readUndirEdgeMap(name, map);
   626       return *this;
   636       return *this;
   627     }
   637     }
   628 
   638 
   629 
   639 
   630     /// \brief Add a new undirected edge map reader command for the reader.
   640     /// \brief Give a new undirected edge map reading command to the reader.
   631     ///
   641     ///
   632     /// Add a new undirected edge map reader command for the reader.
   642     /// Give a new undirected edge map reading command to the reader.
   633     template <typename Reader, typename Map>
   643     template <typename Reader, typename Map>
   634     UndirGraphReader& readUndirEdgeMap(std::string name, Map& map,
   644     UndirGraphReader& readUndirEdgeMap(std::string name, Map& map,
   635 				       const Reader& reader = Reader()) {
   645 				       const Reader& reader = Reader()) {
   636       undir_edgeset_reader.readUndirEdgeMap(name, map, reader);
   646       undir_edgeset_reader.readUndirEdgeMap(name, map, reader);
   637       return *this;
   647       return *this;
   642 				       const Reader& reader = Reader()) {
   652 				       const Reader& reader = Reader()) {
   643       undir_edgeset_reader.readUndirEdgeMap(name, map, reader);
   653       undir_edgeset_reader.readUndirEdgeMap(name, map, reader);
   644       return *this;
   654       return *this;
   645     }
   655     }
   646 
   656 
   647     /// \brief Add a new undirected edge map skipper command for the reader.
   657     /// \brief Give a new undirected edge map skipping command to the reader.
   648     ///
   658     ///
   649     /// Add a new undirected edge map skipper command for the reader.
   659     /// Give a new undirected edge map skipping command to the reader.
   650     template <typename Reader>
   660     template <typename Reader>
   651     UndirGraphReader& skipUndirEdgeMap(std::string name,
   661     UndirGraphReader& skipUndirEdgeMap(std::string name,
   652 				       const Reader& reader = Reader()) {
   662 				       const Reader& reader = Reader()) {
   653       undir_edgeset_reader.skipUndirMap(name, reader);
   663       undir_edgeset_reader.skipUndirMap(name, reader);
   654       return *this;
   664       return *this;
   655     }
   665     }
   656 
   666 
   657 
   667 
   658     /// \brief Add a new edge map reader command for the reader.
   668     /// \brief Give a new edge map reading command to the reader.
   659     ///
   669     ///
   660     /// Add a new edge map reader command for the reader.
   670     /// Give a new edge map reading command to the reader.
   661     template <typename Map>
   671     template <typename Map>
   662     UndirGraphReader& readEdgeMap(std::string name, Map& map) { 
   672     UndirGraphReader& readEdgeMap(std::string name, Map& map) { 
   663       undir_edgeset_reader.readEdgeMap(name, map);
   673       undir_edgeset_reader.readEdgeMap(name, map);
   664       return *this;
   674       return *this;
   665     }
   675     }
   669       undir_edgeset_reader.readEdgeMap(name, map);
   679       undir_edgeset_reader.readEdgeMap(name, map);
   670       return *this;
   680       return *this;
   671     }
   681     }
   672 
   682 
   673 
   683 
   674     /// \brief Add a new edge map reader command for the reader.
   684     /// \brief Give a new edge map reading command to the reader.
   675     ///
   685     ///
   676     /// Add a new edge map reader command for the reader.
   686     /// Give a new edge map reading command to the reader.
   677     template <typename Reader, typename Map>
   687     template <typename Reader, typename Map>
   678     UndirGraphReader& readEdgeMap(std::string name, Map& map,
   688     UndirGraphReader& readEdgeMap(std::string name, Map& map,
   679 				       const Reader& reader = Reader()) {
   689 				       const Reader& reader = Reader()) {
   680       undir_edgeset_reader.readEdgeMap(name, map, reader);
   690       undir_edgeset_reader.readEdgeMap(name, map, reader);
   681       return *this;
   691       return *this;
   686 				       const Reader& reader = Reader()) {
   696 				       const Reader& reader = Reader()) {
   687       undir_edgeset_reader.readEdgeMap(name, map, reader);
   697       undir_edgeset_reader.readEdgeMap(name, map, reader);
   688       return *this;
   698       return *this;
   689     }
   699     }
   690 
   700 
   691     /// \brief Add a new edge map skipper command for the reader.
   701     /// \brief Give a new edge map skipping command to the reader.
   692     ///
   702     ///
   693     /// Add a new edge map skipper command for the reader.
   703     /// Give a new edge map skipping command to the reader.
   694     template <typename Reader>
   704     template <typename Reader>
   695     UndirGraphReader& skipEdgeMap(std::string name,
   705     UndirGraphReader& skipEdgeMap(std::string name,
   696 				       const Reader& reader = Reader()) {
   706 				       const Reader& reader = Reader()) {
   697       undir_edgeset_reader.skipEdgeMap(name, reader);
   707       undir_edgeset_reader.skipEdgeMap(name, reader);
   698       return *this;
   708       return *this;
   699     }
   709     }
   700 
   710 
   701     /// \brief Add a new labeled node reader for the reader.
   711     /// \brief Give a new labeled node reading command to the reader.
   702     ///
   712     ///
   703     /// Add a new labeled node reader for the reader.
   713     /// Give a new labeled node reading command to the reader.
   704     UndirGraphReader& readNode(std::string name, Node& node) {
   714     UndirGraphReader& readNode(std::string name, Node& node) {
   705       node_reader.readNode(name, node);
   715       node_reader.readNode(name, node);
   706       return *this;
   716       return *this;
   707     }
   717     }
   708 
   718 
   709     /// \brief Add a new labeled edge reader for the reader.
   719     /// \brief Give a new labeled edge reading command to the reader.
   710     ///
   720     ///
   711     /// Add a new labeled edge reader for the reader.
   721     /// Give a new labeled edge reading command to the reader.
   712     UndirGraphReader& readEdge(std::string name, Edge& edge) {
   722     UndirGraphReader& readEdge(std::string name, Edge& edge) {
   713       undir_edge_reader.readEdge(name, edge);
   723       undir_edge_reader.readEdge(name, edge);
   714     }
   724     }
   715 
   725 
   716     /// \brief Add a new labeled undirected edge reader for the reader.
   726     /// \brief Give a new labeled undirected edge reading command to the
   717     ///
   727     /// reader.
   718     /// Add a new labeled undirected edge reader for the reader.
   728     ///
       
   729     /// Give a new labeled undirected edge reading command to the reader.
   719     UndirGraphReader& readUndirEdge(std::string name, UndirEdge& edge) {
   730     UndirGraphReader& readUndirEdge(std::string name, UndirEdge& edge) {
   720       undir_edge_reader.readUndirEdge(name, edge);
   731       undir_edge_reader.readUndirEdge(name, edge);
   721     }
   732     }
   722 
   733 
   723     /// \brief Add a new attribute reader command.
   734     /// \brief Give a new attribute reading command.
   724     ///
   735     ///
   725     ///  Add a new attribute reader command.
   736     ///  Give a new attribute reading command.
   726     template <typename Value>
   737     template <typename Value>
   727     UndirGraphReader& readAttribute(std::string name, Value& value) {
   738     UndirGraphReader& readAttribute(std::string name, Value& value) {
   728       attribute_reader.readAttribute(name, value);
   739       attribute_reader.readAttribute(name, value);
   729       return *this;
   740       return *this;
   730     }
   741     }
   731     
   742     
   732     /// \brief Add a new attribute reader command.
   743     /// \brief Give a new attribute reading command.
   733     ///
   744     ///
   734     ///  Add a new attribute reader command.
   745     ///  Give a new attribute reading command.
   735     template <typename Reader, typename Value>
   746     template <typename Reader, typename Value>
   736     UndirGraphReader& readAttribute(std::string name, Value& value, 
   747     UndirGraphReader& readAttribute(std::string name, Value& value, 
   737 			       const Reader& reader) {
   748 			       const Reader& reader) {
   738       attribute_reader.readAttribute<Reader>(name, value, reader);
   749       attribute_reader.readAttribute<Reader>(name, value, reader);
   739       return *this;
   750       return *this;
   747     /// \e LemonReader::SectionReader.
   758     /// \e LemonReader::SectionReader.
   748     operator LemonReader&() {
   759     operator LemonReader&() {
   749       return *reader;
   760       return *reader;
   750     }
   761     }
   751 
   762 
   752     /// \brief Executes the reader commands.
   763     /// \brief Executes the reading commands.
   753     ///
   764     ///
   754     /// Executes the reader commands.
   765     /// Executes the reading commands.
   755     void run() {
   766     void run() {
   756       reader->run();
   767       reader->run();
   757     }
   768     }
   758 
   769 
   759     /// \brief Gives back the node by its id.
   770     /// \brief Gives back the node by its id.