# HG changeset patch
# User Balazs Dezso <deba@inf.elte.hu>
# Date 1240084470 -7200
# Node ID a3402913cffe4d170e27dc6fa0a632da40bcf4f3
# Parent  37216ca5b9c610a335e9dcdb941115003d1f3769
Add more docs to LGF function interface (#109)

diff -r 37216ca5b9c6 -r a3402913cffe lemon/lgf_reader.h
--- a/lemon/lgf_reader.h	Tue Apr 07 14:50:20 2009 +0100
+++ b/lemon/lgf_reader.h	Sat Apr 18 21:54:30 2009 +0200
@@ -101,23 +101,23 @@
       }
     };
 
-    template <typename _Graph, bool _dir, typename _Map,
+    template <typename _GR, bool _dir, typename _Map,
               typename _Converter = DefaultConverter<typename _Map::Value> >
-    class GraphArcMapStorage : public MapStorageBase<typename _Graph::Edge> {
+    class GraphArcMapStorage : public MapStorageBase<typename _GR::Edge> {
     public:
       typedef _Map Map;
       typedef _Converter Converter;
-      typedef _Graph Graph;
-      typedef typename Graph::Edge Item;
+      typedef _GR GR;
+      typedef typename GR::Edge Item;
       static const bool dir = _dir;
 
     private:
-      const Graph& _graph;
+      const GR& _graph;
       Map& _map;
       Converter _converter;
 
     public:
-      GraphArcMapStorage(const Graph& graph, Map& map,
+      GraphArcMapStorage(const GR& graph, Map& map,
                          const Converter& converter = Converter())
         : _graph(graph), _map(map), _converter(converter) {}
       virtual ~GraphArcMapStorage() {}
@@ -173,21 +173,21 @@
       }
     };
 
-    template <typename Graph>
+    template <typename GR>
     struct GraphArcLookUpConverter {
-      const Graph& _graph;
-      const std::map<std::string, typename Graph::Edge>& _map;
-
-      GraphArcLookUpConverter(const Graph& graph,
+      const GR& _graph;
+      const std::map<std::string, typename GR::Edge>& _map;
+
+      GraphArcLookUpConverter(const GR& graph,
                               const std::map<std::string,
-                                             typename Graph::Edge>& map)
+                                             typename GR::Edge>& map)
         : _graph(graph), _map(map) {}
 
-      typename Graph::Arc operator()(const std::string& str) {
+      typename GR::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 Graph::Edge>
+        typename std::map<std::string, typename GR::Edge>
           ::const_iterator it = _map.find(str.substr(1));
         if (it == _map.end()) {
           throw FormatError("Item not found");
@@ -387,16 +387,15 @@
 
   }
 
-  template <typename Digraph>
+  template <typename DGR>
   class DigraphReader;
 
-  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);
+  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);
 
   /// \ingroup lemon_io
   ///
@@ -419,7 +418,7 @@
   /// rules.
   ///
   ///\code
-  /// DigraphReader<Digraph>(digraph, std::cin).
+  /// DigraphReader<DGR>(digraph, std::cin).
   ///   nodeMap("coordinates", coord_map).
   ///   arcMap("capacity", cap_map).
   ///   node("source", src).
@@ -448,21 +447,21 @@
   /// It is impossible to read this in
   /// a single pass, because the arcs are not constructed when the node
   /// maps are read.
-  template <typename GR>
+  template <typename DGR>
   class DigraphReader {
   public:
 
-    typedef GR Digraph;
+    typedef DGR Digraph;
 
   private:
 
-    TEMPLATE_DIGRAPH_TYPEDEFS(Digraph);
+    TEMPLATE_DIGRAPH_TYPEDEFS(DGR);
 
     std::istream* _is;
     bool local_is;
     std::string _filename;
 
-    Digraph& _digraph;
+    DGR& _digraph;
 
     std::string _nodes_caption;
     std::string _arcs_caption;
@@ -500,7 +499,7 @@
     ///
     /// Construct a directed graph reader, which reads from the given
     /// input stream.
-    DigraphReader(Digraph& digraph, std::istream& is = std::cin)
+    DigraphReader(DGR& digraph, std::istream& is = std::cin)
       : _is(&is), local_is(false), _digraph(digraph),
         _use_nodes(false), _use_arcs(false),
         _skip_nodes(false), _skip_arcs(false) {}
@@ -509,7 +508,7 @@
     ///
     /// Construct a directed graph reader, which reads from the given
     /// file.
-    DigraphReader(Digraph& digraph, const std::string& fn)
+    DigraphReader(DGR& digraph, const std::string& fn)
       : _is(new std::ifstream(fn.c_str())), local_is(true),
         _filename(fn), _digraph(digraph),
         _use_nodes(false), _use_arcs(false),
@@ -524,7 +523,7 @@
     ///
     /// Construct a directed graph reader, which reads from the given
     /// file.
-    DigraphReader(Digraph& digraph, const char* fn)
+    DigraphReader(DGR& digraph, const char* fn)
       : _is(new std::ifstream(fn)), local_is(true),
         _filename(fn), _digraph(digraph),
         _use_nodes(false), _use_arcs(false),
@@ -560,13 +559,13 @@
 
   private:
 
-    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);
+    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);
 
     DigraphReader(DigraphReader& other)
       : _is(other._is), local_is(other.local_is), _digraph(other._digraph),
@@ -1188,14 +1187,52 @@
     /// @}
 
   };
+  
+  /// \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
-  template <typename Digraph>
-  DigraphReader<Digraph> digraphReader(Digraph& digraph, std::istream& is) {
-    DigraphReader<Digraph> tmp(digraph, is);
+  /// \sa digraphReader(TDGR& digraph, std::istream& is)
+  template <typename TDGR>
+  DigraphReader<TDGR> digraphReader(TDGR& digraph, const std::string& fn) {
+    DigraphReader<TDGR> tmp(digraph, fn);
     return tmp;
   }
 
@@ -1203,33 +1240,22 @@
   ///
   /// This function just returns a \ref DigraphReader class.
   /// \relates DigraphReader
-  template <typename Digraph>
-  DigraphReader<Digraph> digraphReader(Digraph& digraph,
-                                       const std::string& fn) {
-    DigraphReader<Digraph> tmp(digraph, fn);
+  /// \sa digraphReader(TDGR& digraph, std::istream& is)
+  template <typename TDGR>
+  DigraphReader<TDGR> digraphReader(TDGR& digraph, const char* fn) {
+    DigraphReader<TDGR> tmp(digraph, fn);
     return tmp;
   }
 
-  /// \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>
+  template <typename GR>
   class GraphReader;
  
-  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);
+  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);
 
   /// \ingroup lemon_io
   ///
@@ -1254,13 +1280,13 @@
 
   private:
 
-    TEMPLATE_GRAPH_TYPEDEFS(Graph);
+    TEMPLATE_GRAPH_TYPEDEFS(GR);
 
     std::istream* _is;
     bool local_is;
     std::string _filename;
 
-    Graph& _graph;
+    GR& _graph;
 
     std::string _nodes_caption;
     std::string _edges_caption;
@@ -1298,7 +1324,7 @@
     ///
     /// Construct an undirected graph reader, which reads from the given
     /// input stream.
-    GraphReader(Graph& graph, std::istream& is = std::cin)
+    GraphReader(GR& graph, std::istream& is = std::cin)
       : _is(&is), local_is(false), _graph(graph),
         _use_nodes(false), _use_edges(false),
         _skip_nodes(false), _skip_edges(false) {}
@@ -1307,7 +1333,7 @@
     ///
     /// Construct an undirected graph reader, which reads from the given
     /// file.
-    GraphReader(Graph& graph, const std::string& fn)
+    GraphReader(GR& graph, const std::string& fn)
       : _is(new std::ifstream(fn.c_str())), local_is(true),
         _filename(fn), _graph(graph),
         _use_nodes(false), _use_edges(false),
@@ -1322,7 +1348,7 @@
     ///
     /// Construct an undirected graph reader, which reads from the given
     /// file.
-    GraphReader(Graph& graph, const char* fn)
+    GraphReader(GR& graph, const char* fn)
       : _is(new std::ifstream(fn)), local_is(true),
         _filename(fn), _graph(graph),
         _use_nodes(false), _use_edges(false),
@@ -1357,12 +1383,12 @@
     }
 
   private:
-    template <typename Graph>
-    friend GraphReader<Graph> graphReader(Graph& graph, std::istream& is);
-    template <typename Graph>
-    friend GraphReader<Graph> graphReader(Graph& graph, const std::string& fn); 
-    template <typename Graph>
-    friend GraphReader<Graph> graphReader(Graph& graph, const char *fn);
+    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);
 
     GraphReader(GraphReader& other)
       : _is(other._is), local_is(other.local_is), _graph(other._graph),
@@ -1454,7 +1480,7 @@
         new _reader_bits::GraphArcMapStorage<Graph, true, Map>(_graph, map);
       _edge_maps.push_back(std::make_pair('+' + caption, forward_storage));
       _reader_bits::MapStorageBase<Edge>* backward_storage =
-        new _reader_bits::GraphArcMapStorage<Graph, false, Map>(_graph, map);
+        new _reader_bits::GraphArcMapStorage<GR, false, Map>(_graph, map);
       _edge_maps.push_back(std::make_pair('-' + caption, backward_storage));
       return *this;
     }
@@ -1468,11 +1494,11 @@
                           const Converter& converter = Converter()) {
       checkConcept<concepts::WriteMap<Arc, typename Map::Value>, Map>();
       _reader_bits::MapStorageBase<Edge>* forward_storage =
-        new _reader_bits::GraphArcMapStorage<Graph, true, Map, Converter>
+        new _reader_bits::GraphArcMapStorage<GR, 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<Graph, false, Map, Converter>
+        new _reader_bits::GraphArcMapStorage<GR, false, Map, Converter>
         (_graph, map, converter);
       _edge_maps.push_back(std::make_pair('-' + caption, backward_storage));
       return *this;
@@ -1530,7 +1556,7 @@
     ///
     /// Add an arc reading rule to reader.
     GraphReader& arc(const std::string& caption, Arc& arc) {
-      typedef _reader_bits::GraphArcLookUpConverter<Graph> Converter;
+      typedef _reader_bits::GraphArcLookUpConverter<GR> Converter;
       Converter converter(_graph, _edge_index);
       _reader_bits::ValueStorageBase* storage =
         new _reader_bits::ValueStorage<Arc, Converter>(arc, converter);
@@ -2033,13 +2059,47 @@
 
   };
 
+  /// \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
-  template <typename Graph>
-  GraphReader<Graph> graphReader(Graph& graph, std::istream& is) {
-    GraphReader<Graph> tmp(graph, is);
+  /// \sa graphReader(TGR& graph, std::istream& is)
+  template <typename TGR>
+  GraphReader<TGR> graphReader(TGR& graph, const std::string& fn) {
+    GraphReader<TGR> tmp(graph, fn);
     return tmp;
   }
 
@@ -2047,19 +2107,10 @@
   ///
   /// This function just returns a \ref GraphReader class.
   /// \relates GraphReader
-  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);
+  /// \sa graphReader(TGR& graph, std::istream& is)
+  template <typename TGR>
+  GraphReader<TGR> graphReader(TGR& graph, const char* fn) {
+    GraphReader<TGR> tmp(graph, fn);
     return tmp;
   }
 
@@ -2316,12 +2367,30 @@
 
   };
 
+  /// \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);
+    return tmp;
+  }
+
   /// \brief Return a \ref SectionReader class
   ///
   /// This function just returns a \ref SectionReader class.
   /// \relates SectionReader
-  inline SectionReader sectionReader(std::istream& is) {
-    SectionReader tmp(is);
+  /// \sa sectionReader(std::istream& is)
+  inline SectionReader sectionReader(const std::string& fn) {
+    SectionReader tmp(fn);
     return tmp;
   }
 
@@ -2329,15 +2398,7 @@
   ///
   /// This function just returns a \ref SectionReader class.
   /// \relates SectionReader
-  inline SectionReader sectionReader(const std::string& fn) {
-    SectionReader tmp(fn);
-    return tmp;
-  }
-
-  /// \brief Return a \ref SectionReader class
-  ///
-  /// This function just returns a \ref SectionReader class.
-  /// \relates SectionReader
+  /// \sa sectionReader(std::istream& is)
   inline SectionReader sectionReader(const char* fn) {
     SectionReader tmp(fn);
     return tmp;
diff -r 37216ca5b9c6 -r a3402913cffe lemon/lgf_writer.h
--- a/lemon/lgf_writer.h	Tue Apr 07 14:50:20 2009 +0100
+++ b/lemon/lgf_writer.h	Sat Apr 18 21:54:30 2009 +0200
@@ -347,19 +347,17 @@
 
   }
 
-  template <typename Digraph>
+  template <typename DGR>
   class DigraphWriter;
 
-  template <typename Digraph>
-  DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
-                                       std::ostream& os = std::cout);
-  template <typename Digraph>
-  DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
-                                       const std::string& fn);
+  template <typename TDGR>
+  DigraphWriter<TDGR> digraphWriter(const TDGR& digraph, 
+                                   std::ostream& os = std::cout);
+  template <typename TDGR>
+  DigraphWriter<TDGR> digraphWriter(const TDGR& digraph, const std::string& fn);
 
-  template <typename Digraph>
-  DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
-                                       const char* fn);
+  template <typename TDGR>
+  DigraphWriter<TDGR> digraphWriter(const TDGR& digraph, const char* fn);
 
 
   /// \ingroup lemon_io
@@ -381,7 +379,7 @@
   /// arc() functions are used to add attribute writing rules.
   ///
   ///\code
-  /// DigraphWriter<Digraph>(digraph, std::cout).
+  /// DigraphWriter<DGR>(digraph, std::cout).
   ///   nodeMap("coordinates", coord_map).
   ///   nodeMap("size", size).
   ///   nodeMap("title", title).
@@ -406,12 +404,12 @@
   /// section to the stream. The output stream can be retrieved with
   /// the \c ostream() function, hence the second pass can append its
   /// output to the output of the first pass.
-  template <typename GR>
+  template <typename DGR>
   class DigraphWriter {
   public:
 
-    typedef GR Digraph;
-    TEMPLATE_DIGRAPH_TYPEDEFS(Digraph);
+    typedef DGR Digraph;
+    TEMPLATE_DIGRAPH_TYPEDEFS(DGR);
 
   private:
 
@@ -419,7 +417,7 @@
     std::ostream* _os;
     bool local_os;
 
-    const Digraph& _digraph;
+    const DGR& _digraph;
 
     std::string _nodes_caption;
     std::string _arcs_caption;
@@ -451,7 +449,7 @@
     ///
     /// Construct a directed graph writer, which writes to the given
     /// output stream.
-    DigraphWriter(const Digraph& digraph, std::ostream& os = std::cout)
+    DigraphWriter(const DGR& digraph, std::ostream& os = std::cout)
       : _os(&os), local_os(false), _digraph(digraph),
         _skip_nodes(false), _skip_arcs(false) {}
 
@@ -459,7 +457,7 @@
     ///
     /// Construct a directed graph writer, which writes to the given
     /// output file.
-    DigraphWriter(const Digraph& digraph, const std::string& fn)
+    DigraphWriter(const DGR& digraph, const std::string& fn)
       : _os(new std::ofstream(fn.c_str())), local_os(true), _digraph(digraph),
         _skip_nodes(false), _skip_arcs(false) {
       if (!(*_os)) {
@@ -472,7 +470,7 @@
     ///
     /// Construct a directed graph writer, which writes to the given
     /// output file.
-    DigraphWriter(const Digraph& digraph, const char* fn)
+    DigraphWriter(const DGR& digraph, const char* fn)
       : _os(new std::ofstream(fn)), local_os(true), _digraph(digraph),
         _skip_nodes(false), _skip_arcs(false) {
       if (!(*_os)) {
@@ -505,15 +503,15 @@
 
   private:
 
-    template <typename DGR>
-    friend DigraphWriter<DGR> digraphWriter(const DGR& digraph, 
-                                            std::ostream& os);
-    template <typename DGR>
-    friend DigraphWriter<DGR> digraphWriter(const DGR& digraph,
-                                            const std::string& fn);
-    template <typename DGR>
-    friend DigraphWriter<DGR> digraphWriter(const DGR& digraph,
-                                            const char *fn);
+    template <typename TDGR>
+    friend DigraphWriter<TDGR> digraphWriter(const TDGR& digraph, 
+                                             std::ostream& os);
+    template <typename TDGR>
+    friend DigraphWriter<TDGR> digraphWriter(const TDGR& digraph,
+                                             const std::string& fn);
+    template <typename TDGR>
+    friend DigraphWriter<TDGR> digraphWriter(const TDGR& digraph,
+                                             const char *fn);
 
     DigraphWriter(DigraphWriter& other)
       : _os(other._os), local_os(other.local_os), _digraph(other._digraph),
@@ -724,8 +722,8 @@
       }
 
       if (label == 0) {
-        IdMap<Digraph, Node> id_map(_digraph);
-        _writer_bits::MapLess<IdMap<Digraph, Node> > id_less(id_map);
+        IdMap<DGR, Node> id_map(_digraph);
+        _writer_bits::MapLess<IdMap<DGR, Node> > id_less(id_map);
         std::sort(nodes.begin(), nodes.end(), id_less);
       } else {
         label->sort(nodes);
@@ -809,8 +807,8 @@
       }
 
       if (label == 0) {
-        IdMap<Digraph, Arc> id_map(_digraph);
-        _writer_bits::MapLess<IdMap<Digraph, Arc> > id_less(id_map);
+        IdMap<DGR, Arc> id_map(_digraph);
+        _writer_bits::MapLess<IdMap<DGR, Arc> > id_less(id_map);
         std::sort(arcs.begin(), arcs.end(), id_less);
       } else {
         label->sort(arcs);
@@ -915,14 +913,41 @@
     /// @}
   };
 
+  /// \ingroup lemon_io
+  ///
   /// \brief Return a \ref DigraphWriter class
   ///
-  /// This function just returns a \ref DigraphWriter class.
+  /// This function just returns a \ref DigraphWriter class. 
+  ///
+  /// With this function a digraph can be write to a file or output
+  /// stream in \ref lgf-format "LGF" format with several maps and
+  /// attributes. For example, with the following code a network flow
+  /// problem can be written to the standard output, i.e. a digraph
+  /// with a \e capacity map on the arcs and \e source and \e target
+  /// nodes:
+  ///
+  ///\code
+  ///ListDigraph digraph;
+  ///ListDigraph::ArcMap<int> cap(digraph);
+  ///ListDigraph::Node src, trg;
+  ///  // Setting the capacity map and source and target nodes
+  ///digraphWriter(digraph, std::cout).
+  ///  arcMap("capacity", cap).
+  ///  node("source", src).
+  ///  node("target", trg).
+  ///  run();
+  ///\endcode
+  ///
+  /// For a complete documentation, please see the \ref DigraphWriter
+  /// class documentation.
+  /// \warning Don't forget to put the \ref DigraphWriter::run() "run()"
+  /// to the end of the parameter list.
   /// \relates DigraphWriter
-  template <typename Digraph>
-  DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
-                                       std::ostream& os) {
-    DigraphWriter<Digraph> tmp(digraph, os);
+  /// \sa digraphWriter(const TDGR& digraph, const std::string& fn)
+  /// \sa digraphWriter(const TDGR& digraph, const char* fn)
+  template <typename TDGR>
+  DigraphWriter<TDGR> digraphWriter(const TDGR& digraph, std::ostream& os) {
+    DigraphWriter<TDGR> tmp(digraph, os);
     return tmp;
   }
 
@@ -930,10 +955,11 @@
   ///
   /// This function just returns a \ref DigraphWriter class.
   /// \relates DigraphWriter
-  template <typename Digraph>
-  DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
-                                       const std::string& fn) {
-    DigraphWriter<Digraph> tmp(digraph, fn);
+  /// \sa digraphWriter(const TDGR& digraph, std::ostream& os)
+  template <typename TDGR>
+  DigraphWriter<TDGR> digraphWriter(const TDGR& digraph, 
+                                    const std::string& fn) {
+    DigraphWriter<TDGR> tmp(digraph, fn);
     return tmp;
   }
 
@@ -941,23 +967,22 @@
   ///
   /// This function just returns a \ref DigraphWriter class.
   /// \relates DigraphWriter
-  template <typename Digraph>
-  DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
-                                       const char* fn) {
-    DigraphWriter<Digraph> tmp(digraph, fn);
+  /// \sa digraphWriter(const TDGR& digraph, std::ostream& os)
+  template <typename TDGR>
+  DigraphWriter<TDGR> digraphWriter(const TDGR& digraph, const char* fn) {
+    DigraphWriter<TDGR> tmp(digraph, fn);
     return tmp;
   }
 
-  template <typename Graph>
+  template <typename GR>
   class GraphWriter;
 
-  template <typename Graph>
-  GraphWriter<Graph> graphWriter(const Graph& graph,
-                                 std::ostream& os = std::cout);
-  template <typename Graph>
-  GraphWriter<Graph> graphWriter(const Graph& graph, const std::string& fn);
-  template <typename Graph>
-  GraphWriter<Graph> graphWriter(const Graph& graph, const char* fn);
+  template <typename TGR>
+  GraphWriter<TGR> graphWriter(const TGR& graph, std::ostream& os = std::cout);
+  template <typename TGR>
+  GraphWriter<TGR> graphWriter(const TGR& graph, const std::string& fn);
+  template <typename TGR>
+  GraphWriter<TGR> graphWriter(const TGR& graph, const char* fn);
 
   /// \ingroup lemon_io
   ///
@@ -979,7 +1004,7 @@
   public:
 
     typedef GR Graph;
-    TEMPLATE_GRAPH_TYPEDEFS(Graph);
+    TEMPLATE_GRAPH_TYPEDEFS(GR);
 
   private:
 
@@ -987,7 +1012,7 @@
     std::ostream* _os;
     bool local_os;
 
-    const Graph& _graph;
+    const GR& _graph;
 
     std::string _nodes_caption;
     std::string _edges_caption;
@@ -1019,7 +1044,7 @@
     ///
     /// Construct a directed graph writer, which writes to the given
     /// output stream.
-    GraphWriter(const Graph& graph, std::ostream& os = std::cout)
+    GraphWriter(const GR& graph, std::ostream& os = std::cout)
       : _os(&os), local_os(false), _graph(graph),
         _skip_nodes(false), _skip_edges(false) {}
 
@@ -1027,7 +1052,7 @@
     ///
     /// Construct a directed graph writer, which writes to the given
     /// output file.
-    GraphWriter(const Graph& graph, const std::string& fn)
+    GraphWriter(const GR& graph, const std::string& fn)
       : _os(new std::ofstream(fn.c_str())), local_os(true), _graph(graph),
         _skip_nodes(false), _skip_edges(false) {
       if (!(*_os)) {
@@ -1040,7 +1065,7 @@
     ///
     /// Construct a directed graph writer, which writes to the given
     /// output file.
-    GraphWriter(const Graph& graph, const char* fn)
+    GraphWriter(const GR& graph, const char* fn)
       : _os(new std::ofstream(fn)), local_os(true), _graph(graph),
         _skip_nodes(false), _skip_edges(false) {
       if (!(*_os)) {
@@ -1073,15 +1098,13 @@
 
   private:
 
-    template <typename Graph>
-    friend GraphWriter<Graph> graphWriter(const Graph& graph,
-                                          std::ostream& os);
-    template <typename Graph>
-    friend GraphWriter<Graph> graphWriter(const Graph& graph,
-                                          const std::string& fn);
-    template <typename Graph>
-    friend GraphWriter<Graph> graphWriter(const Graph& graph,
-                                          const char *fn);
+    template <typename TGR>
+    friend GraphWriter<TGR> graphWriter(const TGR& graph, std::ostream& os);
+    template <typename TGR>
+    friend GraphWriter<TGR> graphWriter(const TGR& graph, 
+                                        const std::string& fn);
+    template <typename TGR>
+    friend GraphWriter<TGR> graphWriter(const TGR& graph, const char *fn);
     
     GraphWriter(GraphWriter& other)
       : _os(other._os), local_os(other.local_os), _graph(other._graph),
@@ -1168,10 +1191,10 @@
     GraphWriter& arcMap(const std::string& caption, const Map& map) {
       checkConcept<concepts::ReadMap<Arc, typename Map::Value>, Map>();
       _writer_bits::MapStorageBase<Edge>* forward_storage =
-        new _writer_bits::GraphArcMapStorage<Graph, true, Map>(_graph, map);
+        new _writer_bits::GraphArcMapStorage<GR, true, Map>(_graph, map);
       _edge_maps.push_back(std::make_pair('+' + caption, forward_storage));
       _writer_bits::MapStorageBase<Edge>* backward_storage =
-        new _writer_bits::GraphArcMapStorage<Graph, false, Map>(_graph, map);
+        new _writer_bits::GraphArcMapStorage<GR, false, Map>(_graph, map);
       _edge_maps.push_back(std::make_pair('-' + caption, backward_storage));
       return *this;
     }
@@ -1185,11 +1208,11 @@
                           const Converter& converter = Converter()) {
       checkConcept<concepts::ReadMap<Arc, typename Map::Value>, Map>();
       _writer_bits::MapStorageBase<Edge>* forward_storage =
-        new _writer_bits::GraphArcMapStorage<Graph, true, Map, Converter>
+        new _writer_bits::GraphArcMapStorage<GR, true, Map, Converter>
         (_graph, map, converter);
       _edge_maps.push_back(std::make_pair('+' + caption, forward_storage));
       _writer_bits::MapStorageBase<Edge>* backward_storage =
-        new _writer_bits::GraphArcMapStorage<Graph, false, Map, Converter>
+        new _writer_bits::GraphArcMapStorage<GR, false, Map, Converter>
         (_graph, map, converter);
       _edge_maps.push_back(std::make_pair('-' + caption, backward_storage));
       return *this;
@@ -1247,7 +1270,7 @@
     ///
     /// Add an arc writing rule to writer.
     GraphWriter& arc(const std::string& caption, const Arc& arc) {
-      typedef _writer_bits::GraphArcLookUpConverter<Graph> Converter;
+      typedef _writer_bits::GraphArcLookUpConverter<GR> Converter;
       Converter converter(_graph, _edge_index);
       _writer_bits::ValueStorageBase* storage =
         new _writer_bits::ValueStorage<Arc, Converter>(arc, converter);
@@ -1338,8 +1361,8 @@
       }
 
       if (label == 0) {
-        IdMap<Graph, Node> id_map(_graph);
-        _writer_bits::MapLess<IdMap<Graph, Node> > id_less(id_map);
+        IdMap<GR, Node> id_map(_graph);
+        _writer_bits::MapLess<IdMap<GR, Node> > id_less(id_map);
         std::sort(nodes.begin(), nodes.end(), id_less);
       } else {
         label->sort(nodes);
@@ -1423,8 +1446,8 @@
       }
 
       if (label == 0) {
-        IdMap<Graph, Edge> id_map(_graph);
-        _writer_bits::MapLess<IdMap<Graph, Edge> > id_less(id_map);
+        IdMap<GR, Edge> id_map(_graph);
+        _writer_bits::MapLess<IdMap<GR, Edge> > id_less(id_map);
         std::sort(edges.begin(), edges.end(), id_less);
       } else {
         label->sort(edges);
@@ -1529,14 +1552,37 @@
     /// @}
   };
 
+  /// \ingroup lemon_io
+  ///
   /// \brief Return a \ref GraphWriter class
   ///
-  /// This function just returns a \ref GraphWriter class.
+  /// This function just returns a \ref GraphWriter class. 
+  ///
+  /// With this function a graph can be write to a file or output
+  /// stream in \ref lgf-format "LGF" format with several maps and
+  /// attributes. For example, with the following code a weighted
+  /// matching problem can be written to the standard output, i.e. a
+  /// graph with a \e weight map on the edges:
+  ///
+  ///\code
+  ///ListGraph graph;
+  ///ListGraph::EdgeMap<int> weight(graph);
+  ///  // Setting the weight map
+  ///graphWriter(graph, std::cout).
+  ///  edgeMap("weight", weight).
+  ///  run();
+  ///\endcode
+  ///
+  /// For a complete documentation, please see the \ref GraphWriter
+  /// class documentation.
+  /// \warning Don't forget to put the \ref GraphWriter::run() "run()"
+  /// to the end of the parameter list.
   /// \relates GraphWriter
-  template <typename Graph>
-  GraphWriter<Graph> graphWriter(const Graph& graph,
-                                 std::ostream& os) {
-    GraphWriter<Graph> tmp(graph, os);
+  /// \sa graphWriter(const TGR& graph, const std::string& fn)
+  /// \sa graphWriter(const TGR& graph, const char* fn)
+  template <typename TGR>
+  GraphWriter<TGR> graphWriter(const TGR& graph, std::ostream& os) {
+    GraphWriter<TGR> tmp(graph, os);
     return tmp;
   }
 
@@ -1544,9 +1590,10 @@
   ///
   /// This function just returns a \ref GraphWriter class.
   /// \relates GraphWriter
-  template <typename Graph>
-  GraphWriter<Graph> graphWriter(const Graph& graph, const std::string& fn) {
-    GraphWriter<Graph> tmp(graph, fn);
+  /// \sa graphWriter(const TGR& graph, std::ostream& os)
+  template <typename TGR>
+  GraphWriter<TGR> graphWriter(const TGR& graph, const std::string& fn) {
+    GraphWriter<TGR> tmp(graph, fn);
     return tmp;
   }
 
@@ -1554,9 +1601,10 @@
   ///
   /// This function just returns a \ref GraphWriter class.
   /// \relates GraphWriter
-  template <typename Graph>
-  GraphWriter<Graph> graphWriter(const Graph& graph, const char* fn) {
-    GraphWriter<Graph> tmp(graph, fn);
+  /// \sa graphWriter(const TGR& graph, std::ostream& os)
+  template <typename TGR>
+  GraphWriter<TGR> graphWriter(const TGR& graph, const char* fn) {
+    GraphWriter<TGR> tmp(graph, fn);
     return tmp;
   }
 
@@ -1746,10 +1794,18 @@
 
   };
 
+  /// \ingroup lemon_io
+  ///
   /// \brief Return a \ref SectionWriter class
   ///
   /// This function just returns a \ref SectionWriter class.
+  ///
+  /// Please see SectionWriter documentation about the custom section
+  /// output.
+  ///
   /// \relates SectionWriter
+  /// \sa sectionWriter(const std::string& fn)
+  /// \sa sectionWriter(const char *fn)
   inline SectionWriter sectionWriter(std::ostream& os) {
     SectionWriter tmp(os);
     return tmp;
@@ -1759,6 +1815,7 @@
   ///
   /// This function just returns a \ref SectionWriter class.
   /// \relates SectionWriter
+  /// \sa sectionWriter(std::ostream& os)
   inline SectionWriter sectionWriter(const std::string& fn) {
     SectionWriter tmp(fn);
     return tmp;
@@ -1768,6 +1825,7 @@
   ///
   /// This function just returns a \ref SectionWriter class.
   /// \relates SectionWriter
+  /// \sa sectionWriter(std::ostream& os)
   inline SectionWriter sectionWriter(const char* fn) {
     SectionWriter tmp(fn);
     return tmp;