Index: lemon/lgf_reader.h
===================================================================
--- lemon/lgf_reader.h	(revision 956)
+++ lemon/lgf_reader.h	(revision 1067)
@@ -3,5 +3,5 @@
  * This file is a part of LEMON, a generic C++ optimization library.
  *
- * Copyright (C) 2003-2010
+ * Copyright (C) 2003-2011
  * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
  * (Egervary Research Group on Combinatorial Optimization, EGRES).
@@ -102,21 +102,21 @@
     };
 
-    template <typename _GR, bool _dir, typename _Map,
+    template <typename _Graph, bool _dir, typename _Map,
               typename _Converter = DefaultConverter<typename _Map::Value> >
-    class GraphArcMapStorage : public MapStorageBase<typename _GR::Edge> {
+    class GraphArcMapStorage : public MapStorageBase<typename _Graph::Edge> {
     public:
       typedef _Map Map;
       typedef _Converter Converter;
-      typedef _GR GR;
-      typedef typename GR::Edge Item;
+      typedef _Graph Graph;
+      typedef typename Graph::Edge Item;
       static const bool dir = _dir;
 
     private:
-      const GR& _graph;
+      const Graph& _graph;
       Map& _map;
       Converter _converter;
 
     public:
-      GraphArcMapStorage(const GR& graph, Map& map,
+      GraphArcMapStorage(const Graph& graph, Map& map,
                          const Converter& converter = Converter())
         : _graph(graph), _map(map), _converter(converter) {}
@@ -174,19 +174,19 @@
     };
 
-    template <typename GR>
+    template <typename Graph>
     struct GraphArcLookUpConverter {
-      const GR& _graph;
-      const std::map<std::string, typename GR::Edge>& _map;
-
-      GraphArcLookUpConverter(const GR& graph,
+      const Graph& _graph;
+      const std::map<std::string, typename Graph::Edge>& _map;
+
+      GraphArcLookUpConverter(const Graph& graph,
                               const std::map<std::string,
-                                             typename GR::Edge>& map)
+                                             typename Graph::Edge>& map)
         : _graph(graph), _map(map) {}
 
-      typename GR::Arc operator()(const std::string& str) {
+      typename Graph::Arc operator()(const std::string& str) {
         if (str.empty() || (str[0] != '+' && str[0] != '-')) {
           throw FormatError("Item must start with '+' or '-'");
         }
-        typename std::map<std::string, typename GR::Edge>
+        typename std::map<std::string, typename Graph::Edge>
           ::const_iterator it = _map.find(str.substr(1));
         if (it == _map.end()) {
@@ -388,13 +388,14 @@
   }
 
-  template <typename DGR>
+  template <typename Digraph>
   class DigraphReader;
 
-  template <typename TDGR>
-  DigraphReader<TDGR> digraphReader(TDGR& digraph, std::istream& is = std::cin);
-  template <typename TDGR>
-  DigraphReader<TDGR> digraphReader(TDGR& digraph, const std::string& fn);
-  template <typename TDGR>
-  DigraphReader<TDGR> digraphReader(TDGR& digraph, const char *fn);
+  template <typename Digraph>
+  DigraphReader<Digraph> digraphReader(Digraph& digraph, 
+                                       std::istream& is = std::cin);
+  template <typename Digraph>
+  DigraphReader<Digraph> digraphReader(Digraph& digraph, const std::string& fn);
+  template <typename Digraph>
+  DigraphReader<Digraph> digraphReader(Digraph& digraph, const char *fn);
 
   /// \ingroup lemon_io
@@ -419,5 +420,5 @@
   ///
   ///\code
-  /// DigraphReader<DGR>(digraph, std::cin).
+  /// DigraphReader<Digraph>(digraph, std::cin).
   ///   nodeMap("coordinates", coord_map).
   ///   arcMap("capacity", cap_map).
@@ -428,5 +429,5 @@
   ///\endcode
   ///
-  /// By default, the reader uses the first section in the file of the
+  /// By default the reader uses the first section in the file of the
   /// proper type. If a section has an optional name, then it can be
   /// selected for reading by giving an optional name parameter to the
@@ -448,13 +449,13 @@
   /// a single pass, because the arcs are not constructed when the node
   /// maps are read.
-  template <typename DGR>
+  template <typename _Digraph>
   class DigraphReader {
   public:
 
-    typedef DGR Digraph;
+    typedef _Digraph Digraph;
+    TEMPLATE_DIGRAPH_TYPEDEFS(Digraph);
 
   private:
 
-    TEMPLATE_DIGRAPH_TYPEDEFS(DGR);
 
     std::istream* _is;
@@ -462,5 +463,5 @@
     std::string _filename;
 
-    DGR& _digraph;
+    Digraph& _digraph;
 
     std::string _nodes_caption;
@@ -500,5 +501,5 @@
     /// Construct a directed graph reader, which reads from the given
     /// input stream.
-    DigraphReader(DGR& digraph, std::istream& is = std::cin)
+    DigraphReader(Digraph& digraph, std::istream& is = std::cin)
       : _is(&is), local_is(false), _digraph(digraph),
         _use_nodes(false), _use_arcs(false),
@@ -509,5 +510,5 @@
     /// Construct a directed graph reader, which reads from the given
     /// file.
-    DigraphReader(DGR& digraph, const std::string& fn)
+    DigraphReader(Digraph& digraph, const std::string& fn)
       : _is(new std::ifstream(fn.c_str())), local_is(true),
         _filename(fn), _digraph(digraph),
@@ -524,5 +525,5 @@
     /// Construct a directed graph reader, which reads from the given
     /// file.
-    DigraphReader(DGR& digraph, const char* fn)
+    DigraphReader(Digraph& digraph, const char* fn)
       : _is(new std::ifstream(fn)), local_is(true),
         _filename(fn), _digraph(digraph),
@@ -560,11 +561,11 @@
   private:
 
-    template <typename TDGR>
-    friend DigraphReader<TDGR> digraphReader(TDGR& digraph, std::istream& is);
-    template <typename TDGR>
-    friend DigraphReader<TDGR> digraphReader(TDGR& digraph,
-                                             const std::string& fn);
-    template <typename TDGR>
-    friend DigraphReader<TDGR> digraphReader(TDGR& digraph, const char *fn);
+    template <typename DGR>
+    friend DigraphReader<DGR> digraphReader(DGR& digraph, std::istream& is);
+    template <typename DGR>
+    friend DigraphReader<DGR> digraphReader(DGR& digraph, 
+                                            const std::string& fn);
+    template <typename DGR>
+    friend DigraphReader<DGR> digraphReader(DGR& digraph, const char *fn);
 
     DigraphReader(DigraphReader& other)
@@ -593,5 +594,5 @@
   public:
 
-    /// \name Reading Rules
+    /// \name Reading rules
     /// @{
 
@@ -698,5 +699,5 @@
     /// @}
 
-    /// \name Select Section by Name
+    /// \name Select section by name
     /// @{
 
@@ -727,5 +728,5 @@
     /// @}
 
-    /// \name Using Previously Constructed Node or Arc Set
+    /// \name Using previously constructed node or arc set
     /// @{
 
@@ -847,7 +848,5 @@
         readLine();
       }
-      if (readSuccess()) {
-        line.putback(c);
-      }
+      line.putback(c);
     }
 
@@ -965,4 +964,11 @@
         int index = 0;
         while (_reader_bits::readToken(line, map)) {
+          if(map == "-") {
+              if(index!=0)
+                throw FormatError("'-' is not allowed as a map name");
+              else if (line >> std::ws >> c)
+                throw FormatError("Extra character at the end of line");
+              else break;
+            }
           if (maps.find(map) != maps.end()) {
             std::ostringstream msg;
@@ -1116,5 +1122,5 @@
   public:
 
-    /// \name Execution of the Reader
+    /// \name Execution of the reader
     /// @{
 
@@ -1189,49 +1195,11 @@
   };
 
-  /// \ingroup lemon_io
-  ///
-  /// \brief Return a \ref DigraphReader class
-  ///
-  /// This function just returns a \ref DigraphReader class.
-  ///
-  /// With this function a digraph can be read from an
-  /// \ref lgf-format "LGF" file or input stream with several maps and
-  /// attributes. For example, there is network flow problem on a
-  /// digraph, i.e. a digraph with a \e capacity map on the arcs and
-  /// \e source and \e target nodes. This digraph can be read with the
-  /// following code:
-  ///
-  ///\code
-  ///ListDigraph digraph;
-  ///ListDigraph::ArcMap<int> cm(digraph);
-  ///ListDigraph::Node src, trg;
-  ///digraphReader(digraph, std::cin).
-  ///  arcMap("capacity", cap).
-  ///  node("source", src).
-  ///  node("target", trg).
-  ///  run();
-  ///\endcode
-  ///
-  /// For a complete documentation, please see the \ref DigraphReader
-  /// class documentation.
-  /// \warning Don't forget to put the \ref DigraphReader::run() "run()"
-  /// to the end of the parameter list.
-  /// \relates DigraphReader
-  /// \sa digraphReader(TDGR& digraph, const std::string& fn)
-  /// \sa digraphReader(TDGR& digraph, const char* fn)
-  template <typename TDGR>
-  DigraphReader<TDGR> digraphReader(TDGR& digraph, std::istream& is) {
-    DigraphReader<TDGR> tmp(digraph, is);
-    return tmp;
-  }
-
   /// \brief Return a \ref DigraphReader class
   ///
   /// This function just returns a \ref DigraphReader class.
   /// \relates DigraphReader
-  /// \sa digraphReader(TDGR& digraph, std::istream& is)
-  template <typename TDGR>
-  DigraphReader<TDGR> digraphReader(TDGR& digraph, const std::string& fn) {
-    DigraphReader<TDGR> tmp(digraph, fn);
+  template <typename Digraph>
+  DigraphReader<Digraph> digraphReader(Digraph& digraph, std::istream& is) {
+    DigraphReader<Digraph> tmp(digraph, is);
     return tmp;
   }
@@ -1241,20 +1209,31 @@
   /// This function just returns a \ref DigraphReader class.
   /// \relates DigraphReader
-  /// \sa digraphReader(TDGR& digraph, std::istream& is)
-  template <typename TDGR>
-  DigraphReader<TDGR> digraphReader(TDGR& digraph, const char* fn) {
-    DigraphReader<TDGR> tmp(digraph, fn);
+  template <typename Digraph>
+  DigraphReader<Digraph> digraphReader(Digraph& digraph,
+                                       const std::string& fn) {
+    DigraphReader<Digraph> tmp(digraph, fn);
     return tmp;
   }
 
-  template <typename GR>
+  /// \brief Return a \ref DigraphReader class
+  ///
+  /// This function just returns a \ref DigraphReader class.
+  /// \relates DigraphReader
+  template <typename Digraph>
+  DigraphReader<Digraph> digraphReader(Digraph& digraph, const char* fn) {
+    DigraphReader<Digraph> tmp(digraph, fn);
+    return tmp;
+  }
+
+  template <typename Graph>
   class GraphReader;
-
-  template <typename TGR>
-  GraphReader<TGR> graphReader(TGR& graph, std::istream& is = std::cin);
-  template <typename TGR>
-  GraphReader<TGR> graphReader(TGR& graph, const std::string& fn);
-  template <typename TGR>
-  GraphReader<TGR> graphReader(TGR& graph, const char *fn);
+ 
+  template <typename Graph>
+  GraphReader<Graph> graphReader(Graph& graph, 
+                                 std::istream& is = std::cin);
+  template <typename Graph>
+  GraphReader<Graph> graphReader(Graph& graph, const std::string& fn);
+  template <typename Graph>
+  GraphReader<Graph> graphReader(Graph& graph, const char *fn);
 
   /// \ingroup lemon_io
@@ -1273,13 +1252,12 @@
   /// arc map.  Similarly, an attribute can be read into an arc, if
   /// it's value is an edge label prefixed with \c '+' or \c '-'.
-  template <typename GR>
+  template <typename _Graph>
   class GraphReader {
   public:
 
-    typedef GR Graph;
+    typedef _Graph Graph;
+    TEMPLATE_GRAPH_TYPEDEFS(Graph);
 
   private:
-
-    TEMPLATE_GRAPH_TYPEDEFS(GR);
 
     std::istream* _is;
@@ -1287,5 +1265,5 @@
     std::string _filename;
 
-    GR& _graph;
+    Graph& _graph;
 
     std::string _nodes_caption;
@@ -1325,5 +1303,5 @@
     /// Construct an undirected graph reader, which reads from the given
     /// input stream.
-    GraphReader(GR& graph, std::istream& is = std::cin)
+    GraphReader(Graph& graph, std::istream& is = std::cin)
       : _is(&is), local_is(false), _graph(graph),
         _use_nodes(false), _use_edges(false),
@@ -1334,5 +1312,5 @@
     /// Construct an undirected graph reader, which reads from the given
     /// file.
-    GraphReader(GR& graph, const std::string& fn)
+    GraphReader(Graph& graph, const std::string& fn)
       : _is(new std::ifstream(fn.c_str())), local_is(true),
         _filename(fn), _graph(graph),
@@ -1349,5 +1327,5 @@
     /// Construct an undirected graph reader, which reads from the given
     /// file.
-    GraphReader(GR& graph, const char* fn)
+    GraphReader(Graph& graph, const char* fn)
       : _is(new std::ifstream(fn)), local_is(true),
         _filename(fn), _graph(graph),
@@ -1384,10 +1362,10 @@
 
   private:
-    template <typename TGR>
-    friend GraphReader<TGR> graphReader(TGR& graph, std::istream& is);
-    template <typename TGR>
-    friend GraphReader<TGR> graphReader(TGR& graph, const std::string& fn);
-    template <typename TGR>
-    friend GraphReader<TGR> graphReader(TGR& graph, const char *fn);
+    template <typename GR>
+    friend GraphReader<GR> graphReader(GR& graph, std::istream& is);
+    template <typename GR>
+    friend GraphReader<GR> graphReader(GR& graph, const std::string& fn); 
+    template <typename GR>
+    friend GraphReader<GR> graphReader(GR& graph, const char *fn);
 
     GraphReader(GraphReader& other)
@@ -1416,5 +1394,5 @@
   public:
 
-    /// \name Reading Rules
+    /// \name Reading rules
     /// @{
 
@@ -1481,5 +1459,5 @@
       _edge_maps.push_back(std::make_pair('+' + caption, forward_storage));
       _reader_bits::MapStorageBase<Edge>* backward_storage =
-        new _reader_bits::GraphArcMapStorage<GR, false, Map>(_graph, map);
+        new _reader_bits::GraphArcMapStorage<Graph, false, Map>(_graph, map);
       _edge_maps.push_back(std::make_pair('-' + caption, backward_storage));
       return *this;
@@ -1495,9 +1473,9 @@
       checkConcept<concepts::WriteMap<Arc, typename Map::Value>, Map>();
       _reader_bits::MapStorageBase<Edge>* forward_storage =
-        new _reader_bits::GraphArcMapStorage<GR, true, Map, Converter>
+        new _reader_bits::GraphArcMapStorage<Graph, true, Map, Converter>
         (_graph, map, converter);
       _edge_maps.push_back(std::make_pair('+' + caption, forward_storage));
       _reader_bits::MapStorageBase<Edge>* backward_storage =
-        new _reader_bits::GraphArcMapStorage<GR, false, Map, Converter>
+        new _reader_bits::GraphArcMapStorage<Graph, false, Map, Converter>
         (_graph, map, converter);
       _edge_maps.push_back(std::make_pair('-' + caption, backward_storage));
@@ -1557,5 +1535,5 @@
     /// Add an arc reading rule to reader.
     GraphReader& arc(const std::string& caption, Arc& arc) {
-      typedef _reader_bits::GraphArcLookUpConverter<GR> Converter;
+      typedef _reader_bits::GraphArcLookUpConverter<Graph> Converter;
       Converter converter(_graph, _edge_index);
       _reader_bits::ValueStorageBase* storage =
@@ -1567,5 +1545,5 @@
     /// @}
 
-    /// \name Select Section by Name
+    /// \name Select section by name
     /// @{
 
@@ -1596,5 +1574,5 @@
     /// @}
 
-    /// \name Using Previously Constructed Node or Edge Set
+    /// \name Using previously constructed node or edge set
     /// @{
 
@@ -1717,7 +1695,5 @@
         readLine();
       }
-      if (readSuccess()) {
-        line.putback(c);
-      }
+      line.putback(c);
     }
 
@@ -1835,4 +1811,11 @@
         int index = 0;
         while (_reader_bits::readToken(line, map)) {
+          if(map == "-") {
+              if(index!=0)
+                throw FormatError("'-' is not allowed as a map name");
+              else if (line >> std::ws >> c)
+                throw FormatError("Extra character at the end of line");
+              else break;
+            }
           if (maps.find(map) != maps.end()) {
             std::ostringstream msg;
@@ -1986,5 +1969,5 @@
   public:
 
-    /// \name Execution of the Reader
+    /// \name Execution of the reader
     /// @{
 
@@ -2060,45 +2043,11 @@
   };
 
-  /// \ingroup lemon_io
-  ///
-  /// \brief Return a \ref GraphReader class
-  ///
-  /// This function just returns a \ref GraphReader class.
-  ///
-  /// With this function a graph can be read from an
-  /// \ref lgf-format "LGF" file or input stream with several maps and
-  /// attributes. For example, there is weighted matching problem on a
-  /// graph, i.e. a graph with a \e weight map on the edges. This
-  /// graph can be read with the following code:
-  ///
-  ///\code
-  ///ListGraph graph;
-  ///ListGraph::EdgeMap<int> weight(graph);
-  ///graphReader(graph, std::cin).
-  ///  edgeMap("weight", weight).
-  ///  run();
-  ///\endcode
-  ///
-  /// For a complete documentation, please see the \ref GraphReader
-  /// class documentation.
-  /// \warning Don't forget to put the \ref GraphReader::run() "run()"
-  /// to the end of the parameter list.
-  /// \relates GraphReader
-  /// \sa graphReader(TGR& graph, const std::string& fn)
-  /// \sa graphReader(TGR& graph, const char* fn)
-  template <typename TGR>
-  GraphReader<TGR> graphReader(TGR& graph, std::istream& is) {
-    GraphReader<TGR> tmp(graph, is);
-    return tmp;
-  }
-
   /// \brief Return a \ref GraphReader class
   ///
   /// This function just returns a \ref GraphReader class.
   /// \relates GraphReader
-  /// \sa graphReader(TGR& graph, std::istream& is)
-  template <typename TGR>
-  GraphReader<TGR> graphReader(TGR& graph, const std::string& fn) {
-    GraphReader<TGR> tmp(graph, fn);
+  template <typename Graph>
+  GraphReader<Graph> graphReader(Graph& graph, std::istream& is) {
+    GraphReader<Graph> tmp(graph, is);
     return tmp;
   }
@@ -2108,8 +2057,17 @@
   /// This function just returns a \ref GraphReader class.
   /// \relates GraphReader
-  /// \sa graphReader(TGR& graph, std::istream& is)
-  template <typename TGR>
-  GraphReader<TGR> graphReader(TGR& graph, const char* fn) {
-    GraphReader<TGR> tmp(graph, fn);
+  template <typename Graph>
+  GraphReader<Graph> graphReader(Graph& graph, const std::string& fn) {
+    GraphReader<Graph> tmp(graph, fn);
+    return tmp;
+  }
+
+  /// \brief Return a \ref GraphReader class
+  ///
+  /// This function just returns a \ref GraphReader class.
+  /// \relates GraphReader
+  template <typename Graph>
+  GraphReader<Graph> graphReader(Graph& graph, const char* fn) {
+    GraphReader<Graph> tmp(graph, fn);
     return tmp;
   }
@@ -2210,5 +2168,5 @@
   public:
 
-    /// \name Section Readers
+    /// \name Section readers
     /// @{
 
@@ -2222,5 +2180,5 @@
     /// whitespaces are trimmed from each processed string.
     ///
-    /// For example, let's see a section, which contain several
+    /// For example let's see a section, which contain several
     /// integers, which should be inserted into a vector.
     ///\code
@@ -2301,7 +2259,5 @@
         readLine();
       }
-      if (readSuccess()) {
-        line.putback(c);
-      }
+      line.putback(c);
     }
 
@@ -2309,5 +2265,5 @@
 
 
-    /// \name Execution of the Reader
+    /// \name Execution of the reader
     /// @{
 
@@ -2368,16 +2324,8 @@
   };
 
-  /// \ingroup lemon_io
-  ///
   /// \brief Return a \ref SectionReader class
   ///
   /// This function just returns a \ref SectionReader class.
-  ///
-  /// Please see SectionReader documentation about the custom section
-  /// input.
-  ///
   /// \relates SectionReader
-  /// \sa sectionReader(const std::string& fn)
-  /// \sa sectionReader(const char *fn)
   inline SectionReader sectionReader(std::istream& is) {
     SectionReader tmp(is);
@@ -2389,5 +2337,4 @@
   /// This function just returns a \ref SectionReader class.
   /// \relates SectionReader
-  /// \sa sectionReader(std::istream& is)
   inline SectionReader sectionReader(const std::string& fn) {
     SectionReader tmp(fn);
@@ -2399,5 +2346,4 @@
   /// This function just returns a \ref SectionReader class.
   /// \relates SectionReader
-  /// \sa sectionReader(std::istream& is)
   inline SectionReader sectionReader(const char* fn) {
     SectionReader tmp(fn);
@@ -2501,5 +2447,5 @@
 
 
-    /// \name Node Sections
+    /// \name Node sections
     /// @{
 
@@ -2527,5 +2473,5 @@
     /// @}
 
-    /// \name Arc/Edge Sections
+    /// \name Arc/Edge sections
     /// @{
 
@@ -2585,5 +2531,5 @@
     /// @}
 
-    /// \name Attribute Sections
+    /// \name Attribute sections
     /// @{
 
@@ -2611,5 +2557,5 @@
     /// @}
 
-    /// \name Extra Sections
+    /// \name Extra sections
     /// @{
 
@@ -2654,7 +2600,5 @@
         readLine();
       }
-      if (readSuccess()) {
-        line.putback(c);
-      }
+      line.putback(c);
     }
 
@@ -2687,5 +2631,5 @@
   public:
 
-    /// \name Execution of the Contents Reader
+    /// \name Execution of the contents reader
     /// @{
 
