Index: lemon/Makefile.am
===================================================================
--- lemon/Makefile.am	(revision 85)
+++ lemon/Makefile.am	(revision 89)
@@ -18,8 +18,11 @@
 lemon_HEADERS += \
         lemon/arg_parser.h \
+        lemon/concept_check.h \
         lemon/dim2.h \
+	lemon/error.h \
+	lemon/list_graph.h \
 	lemon/maps.h \
+	lemon/math.h \
         lemon/random.h \
-	lemon/list_graph.h \
         lemon/tolerance.h
 
Index: lemon/bits/graph_extender.h
===================================================================
--- lemon/bits/graph_extender.h	(revision 57)
+++ lemon/bits/graph_extender.h	(revision 78)
@@ -21,4 +21,5 @@
 
 #include <lemon/bits/invalid.h>
+#include <lemon/bits/utility.h>
 
 #include <lemon/bits/map_extender.h>
@@ -64,9 +65,9 @@
     }
 
-    Node oppositeNode(const Node &n, const Arc &e) const {
-      if (n == Parent::source(e))
-	return Parent::target(e);
-      else if(n==Parent::target(e))
-	return Parent::source(e);
+    Node oppositeNode(const Node &node, const Arc &arc) const {
+      if (node == Parent::source(arc))
+	return Parent::target(arc);
+      else if(node == Parent::target(arc))
+	return Parent::source(arc);
       else
 	return INVALID;
@@ -95,5 +96,5 @@
 
     class NodeIt : public Node { 
-      const Digraph* digraph;
+      const Digraph* _digraph;
     public:
 
@@ -102,13 +103,13 @@
       NodeIt(Invalid i) : Node(i) { }
 
-      explicit NodeIt(const Digraph& _digraph) : digraph(&_digraph) {
-	_digraph.first(static_cast<Node&>(*this));
-      }
-
-      NodeIt(const Digraph& _digraph, const Node& node) 
-	: Node(node), digraph(&_digraph) {}
+      explicit NodeIt(const Digraph& digraph) : _digraph(&digraph) {
+	_digraph->first(static_cast<Node&>(*this));
+      }
+
+      NodeIt(const Digraph& digraph, const Node& node) 
+	: Node(node), _digraph(&digraph) {}
 
       NodeIt& operator++() { 
-	digraph->next(*this);
+	_digraph->next(*this);
 	return *this; 
       }
@@ -118,5 +119,5 @@
 
     class ArcIt : public Arc { 
-      const Digraph* digraph;
+      const Digraph* _digraph;
     public:
 
@@ -125,13 +126,13 @@
       ArcIt(Invalid i) : Arc(i) { }
 
-      explicit ArcIt(const Digraph& _digraph) : digraph(&_digraph) {
-	_digraph.first(static_cast<Arc&>(*this));
-      }
-
-      ArcIt(const Digraph& _digraph, const Arc& e) : 
-	Arc(e), digraph(&_digraph) { }
+      explicit ArcIt(const Digraph& digraph) : _digraph(&digraph) {
+	_digraph->first(static_cast<Arc&>(*this));
+      }
+
+      ArcIt(const Digraph& digraph, const Arc& arc) : 
+	Arc(arc), _digraph(&digraph) { }
 
       ArcIt& operator++() { 
-	digraph->next(*this);
+	_digraph->next(*this);
 	return *this; 
       }
@@ -141,5 +142,5 @@
 
     class OutArcIt : public Arc { 
-      const Digraph* digraph;
+      const Digraph* _digraph;
     public:
 
@@ -148,14 +149,14 @@
       OutArcIt(Invalid i) : Arc(i) { }
 
-      OutArcIt(const Digraph& _digraph, const Node& node) 
-	: digraph(&_digraph) {
-	_digraph.firstOut(*this, node);
-      }
-
-      OutArcIt(const Digraph& _digraph, const Arc& arc) 
-	: Arc(arc), digraph(&_digraph) {}
+      OutArcIt(const Digraph& digraph, const Node& node) 
+	: _digraph(&digraph) {
+	_digraph->firstOut(*this, node);
+      }
+
+      OutArcIt(const Digraph& digraph, const Arc& arc) 
+	: Arc(arc), _digraph(&digraph) {}
 
       OutArcIt& operator++() { 
-	digraph->nextOut(*this);
+	_digraph->nextOut(*this);
 	return *this; 
       }
@@ -165,5 +166,5 @@
 
     class InArcIt : public Arc { 
-      const Digraph* digraph;
+      const Digraph* _digraph;
     public:
 
@@ -172,14 +173,14 @@
       InArcIt(Invalid i) : Arc(i) { }
 
-      InArcIt(const Digraph& _digraph, const Node& node) 
-	: digraph(&_digraph) {
-	_digraph.firstIn(*this, node);
-      }
-
-      InArcIt(const Digraph& _digraph, const Arc& arc) : 
-	Arc(arc), digraph(&_digraph) {}
+      InArcIt(const Digraph& digraph, const Node& node) 
+	: _digraph(&digraph) {
+	_digraph->firstIn(*this, node);
+      }
+
+      InArcIt(const Digraph& digraph, const Arc& arc) : 
+	Arc(arc), _digraph(&digraph) {}
 
       InArcIt& operator++() { 
-	digraph->nextIn(*this);
+	_digraph->nextIn(*this);
 	return *this; 
       }
@@ -190,6 +191,6 @@
     ///
     /// Returns the base node (i.e. the source in this case) of the iterator
-    Node baseNode(const OutArcIt &e) const {
-      return Parent::source(e);
+    Node baseNode(const OutArcIt &arc) const {
+      return Parent::source(arc);
     }
     /// \brief Running node of the iterator
@@ -197,6 +198,6 @@
     /// Returns the running node (i.e. the target in this case) of the
     /// iterator
-    Node runningNode(const OutArcIt &e) const {
-      return Parent::target(e);
+    Node runningNode(const OutArcIt &arc) const {
+      return Parent::target(arc);
     }
 
@@ -204,6 +205,6 @@
     ///
     /// Returns the base node (i.e. the target in this case) of the iterator
-    Node baseNode(const InArcIt &e) const {
-      return Parent::target(e);
+    Node baseNode(const InArcIt &arc) const {
+      return Parent::target(arc);
     }
     /// \brief Running node of the iterator
@@ -211,6 +212,6 @@
     /// Returns the running node (i.e. the source in this case) of the
     /// iterator
-    Node runningNode(const InArcIt &e) const {
-      return Parent::source(e);
+    Node runningNode(const InArcIt &arc) const {
+      return Parent::source(arc);
     }
 
@@ -324,5 +325,5 @@
   };
 
-  /// \ingroup graphbits
+  /// \ingroup _graphbits
   ///
   /// \brief Extender for the Graphs
@@ -332,5 +333,7 @@
     
     typedef Base Parent;
-    typedef GraphExtender Digraph;
+    typedef GraphExtender Graph;
+
+    typedef True UndirectedTag;
 
     typedef typename Parent::Node Node;
@@ -373,11 +376,11 @@
     }
 
-    Arc oppositeArc(const Arc &e) const {
-      return Parent::direct(e, !Parent::direction(e));
+    Arc oppositeArc(const Arc &arc) const {
+      return Parent::direct(arc, !Parent::direction(arc));
     }
 
     using Parent::direct;
-    Arc direct(const Edge &ue, const Node &s) const {
-      return Parent::direct(ue, Parent::source(ue) == s);
+    Arc direct(const Edge &edge, const Node &node) const {
+      return Parent::direct(edge, Parent::source(edge) == node);
     }
 
@@ -412,5 +415,5 @@
 
     class NodeIt : public Node { 
-      const Digraph* digraph;
+      const Graph* _graph;
     public:
 
@@ -419,13 +422,13 @@
       NodeIt(Invalid i) : Node(i) { }
 
-      explicit NodeIt(const Digraph& _digraph) : digraph(&_digraph) {
-	_digraph.first(static_cast<Node&>(*this));
-      }
-
-      NodeIt(const Digraph& _digraph, const Node& node) 
-	: Node(node), digraph(&_digraph) {}
+      explicit NodeIt(const Graph& graph) : _graph(&graph) {
+	_graph->first(static_cast<Node&>(*this));
+      }
+
+      NodeIt(const Graph& graph, const Node& node) 
+	: Node(node), _graph(&graph) {}
 
       NodeIt& operator++() { 
-	digraph->next(*this);
+	_graph->next(*this);
 	return *this; 
       }
@@ -435,5 +438,5 @@
 
     class ArcIt : public Arc { 
-      const Digraph* digraph;
+      const Graph* _graph;
     public:
 
@@ -442,13 +445,13 @@
       ArcIt(Invalid i) : Arc(i) { }
 
-      explicit ArcIt(const Digraph& _digraph) : digraph(&_digraph) {
-	_digraph.first(static_cast<Arc&>(*this));
-      }
-
-      ArcIt(const Digraph& _digraph, const Arc& e) : 
-	Arc(e), digraph(&_digraph) { }
+      explicit ArcIt(const Graph& graph) : _graph(&graph) {
+	_graph->first(static_cast<Arc&>(*this));
+      }
+
+      ArcIt(const Graph& graph, const Arc& arc) : 
+	Arc(arc), _graph(&graph) { }
 
       ArcIt& operator++() { 
-	digraph->next(*this);
+	_graph->next(*this);
 	return *this; 
       }
@@ -458,5 +461,5 @@
 
     class OutArcIt : public Arc { 
-      const Digraph* digraph;
+      const Graph* _graph;
     public:
 
@@ -465,14 +468,14 @@
       OutArcIt(Invalid i) : Arc(i) { }
 
-      OutArcIt(const Digraph& _digraph, const Node& node) 
-	: digraph(&_digraph) {
-	_digraph.firstOut(*this, node);
-      }
-
-      OutArcIt(const Digraph& _digraph, const Arc& arc) 
-	: Arc(arc), digraph(&_digraph) {}
+      OutArcIt(const Graph& graph, const Node& node) 
+	: _graph(&graph) {
+	_graph->firstOut(*this, node);
+      }
+
+      OutArcIt(const Graph& graph, const Arc& arc) 
+	: Arc(arc), _graph(&graph) {}
 
       OutArcIt& operator++() { 
-	digraph->nextOut(*this);
+	_graph->nextOut(*this);
 	return *this; 
       }
@@ -482,5 +485,5 @@
 
     class InArcIt : public Arc { 
-      const Digraph* digraph;
+      const Graph* _graph;
     public:
 
@@ -489,14 +492,14 @@
       InArcIt(Invalid i) : Arc(i) { }
 
-      InArcIt(const Digraph& _digraph, const Node& node) 
-	: digraph(&_digraph) {
-	_digraph.firstIn(*this, node);
-      }
-
-      InArcIt(const Digraph& _digraph, const Arc& arc) : 
-	Arc(arc), digraph(&_digraph) {}
+      InArcIt(const Graph& graph, const Node& node) 
+	: _graph(&graph) {
+	_graph->firstIn(*this, node);
+      }
+
+      InArcIt(const Graph& graph, const Arc& arc) : 
+	Arc(arc), _graph(&graph) {}
 
       InArcIt& operator++() { 
-	digraph->nextIn(*this);
+	_graph->nextIn(*this);
 	return *this; 
       }
@@ -506,5 +509,5 @@
 
     class EdgeIt : public Parent::Edge { 
-      const Digraph* digraph;
+      const Graph* _graph;
     public:
 
@@ -513,39 +516,39 @@
       EdgeIt(Invalid i) : Edge(i) { }
 
-      explicit EdgeIt(const Digraph& _digraph) : digraph(&_digraph) {
-	_digraph.first(static_cast<Edge&>(*this));
-      }
-
-      EdgeIt(const Digraph& _digraph, const Edge& e) : 
-	Edge(e), digraph(&_digraph) { }
+      explicit EdgeIt(const Graph& graph) : _graph(&graph) {
+	_graph->first(static_cast<Edge&>(*this));
+      }
+
+      EdgeIt(const Graph& graph, const Edge& edge) : 
+	Edge(edge), _graph(&graph) { }
 
       EdgeIt& operator++() { 
-	digraph->next(*this);
-	return *this; 
-      }
-
-    };
-
-    class IncArcIt : public Parent::Edge {
+	_graph->next(*this);
+	return *this; 
+      }
+
+    };
+
+    class IncEdgeIt : public Parent::Edge {
       friend class GraphExtender;
-      const Digraph* digraph;
-      bool direction;
-    public:
-
-      IncArcIt() { }
-
-      IncArcIt(Invalid i) : Edge(i), direction(false) { }
-
-      IncArcIt(const Digraph& _digraph, const Node &n) : digraph(&_digraph) {
-	_digraph.firstInc(*this, direction, n);
-      }
-
-      IncArcIt(const Digraph& _digraph, const Edge &ue, const Node &n)
-	: digraph(&_digraph), Edge(ue) {
-	direction = (_digraph.source(ue) == n);
-      }
-
-      IncArcIt& operator++() {
-	digraph->nextInc(*this, direction);
+      const Graph* _graph;
+      bool _direction;
+    public:
+
+      IncEdgeIt() { }
+
+      IncEdgeIt(Invalid i) : Edge(i), _direction(false) { }
+
+      IncEdgeIt(const Graph& graph, const Node &node) : _graph(&graph) {
+	_graph->firstInc(*this, _direction, node);
+      }
+
+      IncEdgeIt(const Graph& graph, const Edge &edge, const Node &node)
+	: _graph(&graph), Edge(edge) {
+	_direction = (_graph->source(edge) == node);
+      }
+
+      IncEdgeIt& operator++() {
+	_graph->nextInc(*this, _direction);
 	return *this; 
       }
@@ -555,6 +558,6 @@
     ///
     /// Returns the base node (ie. the source in this case) of the iterator
-    Node baseNode(const OutArcIt &e) const {
-      return Parent::source(static_cast<const Arc&>(e));
+    Node baseNode(const OutArcIt &arc) const {
+      return Parent::source(static_cast<const Arc&>(arc));
     }
     /// \brief Running node of the iterator
@@ -562,6 +565,6 @@
     /// Returns the running node (ie. the target in this case) of the
     /// iterator
-    Node runningNode(const OutArcIt &e) const {
-      return Parent::target(static_cast<const Arc&>(e));
+    Node runningNode(const OutArcIt &arc) const {
+      return Parent::target(static_cast<const Arc&>(arc));
     }
 
@@ -569,6 +572,6 @@
     ///
     /// Returns the base node (ie. the target in this case) of the iterator
-    Node baseNode(const InArcIt &e) const {
-      return Parent::target(static_cast<const Arc&>(e));
+    Node baseNode(const InArcIt &arc) const {
+      return Parent::target(static_cast<const Arc&>(arc));
     }
     /// \brief Running node of the iterator
@@ -576,6 +579,6 @@
     /// Returns the running node (ie. the source in this case) of the
     /// iterator
-    Node runningNode(const InArcIt &e) const {
-      return Parent::source(static_cast<const Arc&>(e));
+    Node runningNode(const InArcIt &arc) const {
+      return Parent::source(static_cast<const Arc&>(arc));
     }
 
@@ -583,12 +586,12 @@
     ///
     /// Returns the base node of the iterator
-    Node baseNode(const IncArcIt &e) const {
-      return e.direction ? source(e) : target(e);
+    Node baseNode(const IncEdgeIt &edge) const {
+      return edge._direction ? source(edge) : target(edge);
     }
     /// Running node of the iterator
     ///
     /// Returns the running node of the iterator
-    Node runningNode(const IncArcIt &e) const {
-      return e.direction ? target(e) : source(e);
+    Node runningNode(const IncEdgeIt &edge) const {
+      return edge._direction ? target(edge) : source(edge);
     }
 
@@ -597,13 +600,13 @@
     template <typename _Value>
     class NodeMap 
-      : public MapExtender<DefaultMap<Digraph, Node, _Value> > {
-    public:
-      typedef GraphExtender Digraph;
-      typedef MapExtender<DefaultMap<Digraph, Node, _Value> > Parent;
-
-      NodeMap(const Digraph& digraph) 
-	: Parent(digraph) {}
-      NodeMap(const Digraph& digraph, const _Value& value) 
-	: Parent(digraph, value) {}
+      : public MapExtender<DefaultMap<Graph, Node, _Value> > {
+    public:
+      typedef GraphExtender Graph;
+      typedef MapExtender<DefaultMap<Graph, Node, _Value> > Parent;
+
+      NodeMap(const Graph& graph) 
+	: Parent(graph) {}
+      NodeMap(const Graph& graph, const _Value& value) 
+	: Parent(graph, value) {}
 
       NodeMap& operator=(const NodeMap& cmap) {
@@ -621,13 +624,13 @@
     template <typename _Value>
     class ArcMap 
-      : public MapExtender<DefaultMap<Digraph, Arc, _Value> > {
-    public:
-      typedef GraphExtender Digraph;
-      typedef MapExtender<DefaultMap<Digraph, Arc, _Value> > Parent;
-
-      ArcMap(const Digraph& digraph) 
-	: Parent(digraph) {}
-      ArcMap(const Digraph& digraph, const _Value& value) 
-	: Parent(digraph, value) {}
+      : public MapExtender<DefaultMap<Graph, Arc, _Value> > {
+    public:
+      typedef GraphExtender Graph;
+      typedef MapExtender<DefaultMap<Graph, Arc, _Value> > Parent;
+
+      ArcMap(const Graph& graph) 
+	: Parent(graph) {}
+      ArcMap(const Graph& graph, const _Value& value) 
+	: Parent(graph, value) {}
 
       ArcMap& operator=(const ArcMap& cmap) {
@@ -645,14 +648,14 @@
     template <typename _Value>
     class EdgeMap 
-      : public MapExtender<DefaultMap<Digraph, Edge, _Value> > {
-    public:
-      typedef GraphExtender Digraph;
-      typedef MapExtender<DefaultMap<Digraph, Edge, _Value> > Parent;
-
-      EdgeMap(const Digraph& digraph) 
-	: Parent(digraph) {}
-
-      EdgeMap(const Digraph& digraph, const _Value& value) 
-	: Parent(digraph, value) {}
+      : public MapExtender<DefaultMap<Graph, Edge, _Value> > {
+    public:
+      typedef GraphExtender Graph;
+      typedef MapExtender<DefaultMap<Graph, Edge, _Value> > Parent;
+
+      EdgeMap(const Graph& graph) 
+	: Parent(graph) {}
+
+      EdgeMap(const Graph& graph, const _Value& value) 
+	: Parent(graph, value) {}
 
       EdgeMap& operator=(const EdgeMap& cmap) {
@@ -693,8 +696,8 @@
     }
 
-    template <typename Digraph, typename NodeRefMap, typename EdgeRefMap>
-    void build(const Digraph& digraph, NodeRefMap& nodeRef, 
+    template <typename Graph, typename NodeRefMap, typename EdgeRefMap>
+    void build(const Graph& graph, NodeRefMap& nodeRef, 
                EdgeRefMap& edgeRef) {
-      Parent::build(digraph, nodeRef, edgeRef);
+      Parent::build(graph, nodeRef, edgeRef);
       notifier(Node()).build();
       notifier(Edge()).build();
@@ -721,8 +724,8 @@
 
     void erase(const Edge& edge) {
-      std::vector<Arc> ev;
-      ev.push_back(Parent::direct(edge, true));
-      ev.push_back(Parent::direct(edge, false));      
-      notifier(Arc()).erase(ev);
+      std::vector<Arc> av;
+      av.push_back(Parent::direct(edge, true));
+      av.push_back(Parent::direct(edge, false));      
+      notifier(Arc()).erase(av);
       notifier(Edge()).erase(edge);
       Parent::erase(edge);
Index: lemon/concepts/digraph.h
===================================================================
--- lemon/concepts/digraph.h	(revision 57)
+++ lemon/concepts/digraph.h	(revision 61)
@@ -349,4 +349,26 @@
       Node source(Arc) const { return INVALID; }
 
+      /// \brief Returns the ID of the node.
+      int id(Node) const { return -1; } 
+
+      /// \brief Returns the ID of the arc.
+      int id(Arc) const { return -1; } 
+
+      /// \brief Returns the node with the given ID.
+      ///
+      /// \pre The argument should be a valid node ID in the graph.
+      Node nodeFromId(int) const { return INVALID; } 
+
+      /// \brief Returns the arc with the given ID.
+      ///
+      /// \pre The argument should be a valid arc ID in the graph.
+      Arc arcFromId(int) const { return INVALID; } 
+
+      /// \brief Returns an upper bound on the node IDs.
+      int maxNodeId() const { return -1; } 
+
+      /// \brief Returns an upper bound on the arc IDs.
+      int maxArcId() const { return -1; } 
+
       void first(Node&) const {}
       void next(Node&) const {}
@@ -361,4 +383,14 @@
       void firstOut(Arc&, const Node&) const {}
       void nextOut(Arc&) const {}
+
+      // The second parameter is dummy.
+      Node fromId(int, Node) const { return INVALID; }
+      // The second parameter is dummy.
+      Arc fromId(int, Arc) const { return INVALID; }
+
+      // Dummy parameter.
+      int maxId(Node) const { return -1; } 
+      // Dummy parameter.
+      int maxId(Arc) const { return -1; } 
 
       /// \brief The base node of the iterator.
@@ -440,4 +472,5 @@
         void constraints() {
           checkConcept<IterableDigraphComponent<>, Digraph>();
+	  checkConcept<IDableDigraphComponent<>, Digraph>();
           checkConcept<MappableDigraphComponent<>, Digraph>();
         }
Index: lemon/concepts/graph.h
===================================================================
--- lemon/concepts/graph.h	(revision 57)
+++ lemon/concepts/graph.h	(revision 78)
@@ -64,5 +64,5 @@
     /// the EdgeMap to map values for the edges. The InArcIt and
     /// OutArcIt iterates on the same edges but with opposite
-    /// direction. The IncArcIt iterates also on the same edges
+    /// direction. The IncEdgeIt iterates also on the same edges
     /// as the OutArcIt and InArcIt but it is not convertible to Arc just
     /// to Edge.  
@@ -271,39 +271,39 @@
       ///\code
       /// int count=0;
-      /// for(Graph::IncArcIt e(g, n); e!=INVALID; ++e) ++count;
+      /// for(Graph::IncEdgeIt e(g, n); e!=INVALID; ++e) ++count;
       ///\endcode
-      class IncArcIt : public Edge {
-      public:
-        /// Default constructor
-
-        /// @warning The default constructor sets the iterator
-        /// to an undefined value.
-        IncArcIt() { }
-        /// Copy constructor.
-
-        /// Copy constructor.
-        ///
-        IncArcIt(const IncArcIt& e) : Edge(e) { }
-        /// Initialize the iterator to be invalid.
-
-        /// Initialize the iterator to be invalid.
-        ///
-        IncArcIt(Invalid) { }
+      class IncEdgeIt : public Edge {
+      public:
+        /// Default constructor
+
+        /// @warning The default constructor sets the iterator
+        /// to an undefined value.
+        IncEdgeIt() { }
+        /// Copy constructor.
+
+        /// Copy constructor.
+        ///
+        IncEdgeIt(const IncEdgeIt& e) : Edge(e) { }
+        /// Initialize the iterator to be invalid.
+
+        /// Initialize the iterator to be invalid.
+        ///
+        IncEdgeIt(Invalid) { }
         /// This constructor sets the iterator to first incident arc.
     
         /// This constructor set the iterator to the first incident arc of
         /// the node.
-        IncArcIt(const Graph&, const Node&) { }
-        /// Edge -> IncArcIt conversion
+        IncEdgeIt(const Graph&, const Node&) { }
+        /// Edge -> IncEdgeIt conversion
 
         /// Sets the iterator to the value of the trivial iterator \c e.
         /// This feature necessitates that each time we 
         /// iterate the arc-set, the iteration order is the same.
-        IncArcIt(const Graph&, const Edge&) { }
+        IncEdgeIt(const Graph&, const Edge&) { }
         /// Next incident arc
 
         /// Assign the iterator to the next incident arc
 	/// of the corresponding node.
-        IncArcIt& operator++() { return *this; }
+        IncEdgeIt& operator++() { return *this; }
       };
 
@@ -625,4 +625,37 @@
       Node target(Arc) const { return INVALID; }
 
+      /// \brief Returns the id of the node.
+      int id(Node) const { return -1; } 
+
+      /// \brief Returns the id of the edge.
+      int id(Edge) const { return -1; } 
+
+      /// \brief Returns the id of the arc.
+      int id(Arc) const { return -1; } 
+
+      /// \brief Returns the node with the given id.
+      ///
+      /// \pre The argument should be a valid node id in the graph.
+      Node nodeFromId(int) const { return INVALID; } 
+
+      /// \brief Returns the edge with the given id.
+      ///
+      /// \pre The argument should be a valid edge id in the graph.
+      Edge edgeFromId(int) const { return INVALID; } 
+
+      /// \brief Returns the arc with the given id.
+      ///
+      /// \pre The argument should be a valid arc id in the graph.
+      Arc arcFromId(int) const { return INVALID; } 
+
+      /// \brief Returns an upper bound on the node IDs.
+      int maxNodeId() const { return -1; } 
+
+      /// \brief Returns an upper bound on the edge IDs.
+      int maxEdgeId() const { return -1; } 
+
+      /// \brief Returns an upper bound on the arc IDs.
+      int maxArcId() const { return -1; } 
+
       void first(Node&) const {}
       void next(Node&) const {}
@@ -640,7 +673,20 @@
       void nextIn(Arc&) const {}
 
-
       void firstInc(Edge &, bool &, const Node &) const {}
       void nextInc(Edge &, bool &) const {}
+
+      // The second parameter is dummy.
+      Node fromId(int, Node) const { return INVALID; }
+      // The second parameter is dummy.
+      Edge fromId(int, Edge) const { return INVALID; }
+      // The second parameter is dummy.
+      Arc fromId(int, Arc) const { return INVALID; }
+
+      // Dummy parameter.
+      int maxId(Node) const { return -1; } 
+      // Dummy parameter.
+      int maxId(Edge) const { return -1; } 
+      // Dummy parameter.
+      int maxId(Arc) const { return -1; } 
 
       /// \brief Base node of the iterator
@@ -675,5 +721,5 @@
       ///
       /// Returns the base node of the iterator
-      Node baseNode(IncArcIt) const {
+      Node baseNode(IncEdgeIt) const {
 	return INVALID;
       }
@@ -682,5 +728,5 @@
       ///
       /// Returns the running node of the iterator
-      Node runningNode(IncArcIt) const {
+      Node runningNode(IncEdgeIt) const {
 	return INVALID;
       }
@@ -690,4 +736,5 @@
 	void constraints() {
 	  checkConcept<IterableGraphComponent<>, Graph>();
+	  checkConcept<IDableGraphComponent<>, Graph>();
 	  checkConcept<MappableGraphComponent<>, Graph>();
 	}
Index: lemon/concepts/graph_components.h
===================================================================
--- lemon/concepts/graph_components.h	(revision 57)
+++ lemon/concepts/graph_components.h	(revision 78)
@@ -829,14 +829,14 @@
       /// This iterator goes trough the incident arcs of a certain
       /// node of a graph.
-      typedef GraphIncIt<Graph, Edge, Node, 'u'> IncArcIt;
+      typedef GraphIncIt<Graph, Edge, Node, 'u'> IncEdgeIt;
       /// \brief The base node of the iterator.
       ///
       /// Gives back the base node of the iterator.
-      Node baseNode(const IncArcIt&) const { return INVALID; }
+      Node baseNode(const IncEdgeIt&) const { return INVALID; }
 
       /// \brief The running node of the iterator.
       ///
       /// Gives back the running node of the iterator.
-      Node runningNode(const IncArcIt&) const { return INVALID; }
+      Node runningNode(const IncEdgeIt&) const { return INVALID; }
 
       /// @}
@@ -866,8 +866,8 @@
               typename _Graph::EdgeIt >();
             checkConcept<GraphIncIt<_Graph, typename _Graph::Edge, 
-              typename _Graph::Node, 'u'>, typename _Graph::IncArcIt>();
+              typename _Graph::Node, 'u'>, typename _Graph::IncEdgeIt>();
             
             typename _Graph::Node n;
-            typename _Graph::IncArcIt ueit(INVALID);
+            typename _Graph::IncEdgeIt ueit(INVALID);
             n = graph.baseNode(ueit);
             n = graph.runningNode(ueit);
Index: lemon/concepts/maps.h
===================================================================
--- lemon/concepts/maps.h	(revision 51)
+++ lemon/concepts/maps.h	(revision 79)
@@ -30,5 +30,5 @@
 
   namespace concepts {
-  
+
     /// \addtogroup concept
     /// @{
@@ -43,61 +43,22 @@
     public:
       /// The key type of the map.
-      typedef K Key;    
-      /// The value type of the map. (The type of objects associated with the keys).
-      typedef T Value;
-
-      /// Returns the value associated with a key.
-
-      /// Returns the value associated with a key.
-      /// \bug Value shouldn't need to be default constructible.
-      ///
-      Value operator[](const Key &) const {return Value();}
+      typedef K Key;
+      /// The value type of the map. (The type of objects associated with the keys).
+      typedef T Value;
+
+      /// Returns the value associated with the given key.
+
+      /// Returns the value associated with the given key.
+      /// \bug Value shouldn't need to be default constructible. 
+      Value operator[](const Key &) const { return Value(); }
 
       template<typename _ReadMap>
       struct Constraints {
-
 	void constraints() {
 	  Value val = m[key];
 	  val = m[key];
-	  typename _ReadMap::Value own_val = m[own_key]; 
-	  own_val = m[own_key]; 
-
-	  ignore_unused_variable_warning(val);
-	  ignore_unused_variable_warning(own_val);
-	  ignore_unused_variable_warning(key);
-	}
-	Key& key;
-	typename _ReadMap::Key& own_key;
-	_ReadMap& m;
-      };
-      
-    };
-
-
-    /// Writable map concept
-    
-    /// Writable map concept.
-    ///
-    template<typename K, typename T>
-    class WriteMap
-    {
-    public:
-      /// The key type of the map.
-      typedef K Key;    
-      /// The value type of the map. (The type of objects associated with the keys).
-      typedef T Value;
-
-      /// Sets the value associated with a key.
-      void set(const Key &,const Value &) {}
-
-      ///Default constructor
-      WriteMap() {}
-
-      template <typename _WriteMap>
-      struct Constraints {
-	void constraints() {
-	  // No constraints for constructor.
-	  m.set(key, val);
-	  m.set(own_key, own_val);
+	  typename _ReadMap::Value own_val = m[own_key];
+	  own_val = m[own_key];
+
 	  ignore_unused_variable_warning(key);
 	  ignore_unused_variable_warning(val);
@@ -105,16 +66,52 @@
 	  ignore_unused_variable_warning(own_val);
 	}
-
-	Value& val;
-	typename _WriteMap::Value own_val;
-	Key& key;
-	typename _WriteMap::Key& own_key;
+	const Key& key;
+	const typename _ReadMap::Key& own_key;
+	const _ReadMap& m;
+      };
+
+    };
+
+
+    /// Writable map concept
+
+    /// Writable map concept.
+    ///
+    template<typename K, typename T>
+    class WriteMap
+    {
+    public:
+      /// The key type of the map.
+      typedef K Key;
+      /// The value type of the map. (The type of objects associated with the keys).
+      typedef T Value;
+
+      /// Sets the value associated with the given key.
+      void set(const Key &, const Value &) {}
+
+      /// Default constructor.
+      WriteMap() {}
+
+      template <typename _WriteMap>
+      struct Constraints {
+	void constraints() {
+	  m.set(key, val);
+	  m.set(own_key, own_val);
+
+	  ignore_unused_variable_warning(key);
+	  ignore_unused_variable_warning(val);
+	  ignore_unused_variable_warning(own_key);
+	  ignore_unused_variable_warning(own_val);
+	}
+	const Key& key;
+	const Value& val;
+	const typename _WriteMap::Key& own_key;
+	const typename _WriteMap::Value own_val;
 	_WriteMap& m;
-
       };
     };
 
     /// Read/writable map concept
-    
+
     /// Read/writable map concept.
     ///
@@ -125,12 +122,13 @@
     public:
       /// The key type of the map.
-      typedef K Key;    
-      /// The value type of the map. (The type of objects associated with the keys).
-      typedef T Value;
-
-      /// Returns the value associated with a key.
-      Value operator[](const Key &) const {return Value();}
-      /// Sets the value associated with a key.
-      void set(const Key & ,const Value &) {}
+      typedef K Key;
+      /// The value type of the map. (The type of objects associated with the keys).
+      typedef T Value;
+
+      /// Returns the value associated with the given key.
+      Value operator[](const Key &) const { return Value(); }
+
+      /// Sets the value associated with the given key.
+      void set(const Key &, const Value &) {}
 
       template<typename _ReadWriteMap>
@@ -142,11 +140,10 @@
       };
     };
-  
-  
+
+
     /// Dereferable map concept
-    
+
     /// Dereferable map concept.
     ///
-    /// \todo Rethink this concept.
     template<typename K, typename T, typename R, typename CR>
     class ReferenceMap : public ReadWriteMap<K,T>
@@ -156,5 +153,5 @@
       typedef True ReferenceMapTag;
       /// The key type of the map.
-      typedef K Key;    
+      typedef K Key;
       /// The value type of the map. (The type of objects associated with the keys).
       typedef T Value;
@@ -168,32 +165,36 @@
     public:
 
-      ///Returns a reference to the value associated with a key.
+      /// Returns a reference to the value associated with the given key.
       Reference operator[](const Key &) { return tmp; }
-      ///Returns a const reference to the value associated with a key.
+
+      /// Returns a const reference to the value associated with the given key.
       ConstReference operator[](const Key &) const { return tmp; }
-      /// Sets the value associated with a key.
+
+      /// Sets the value associated with the given key.
       void set(const Key &k,const Value &t) { operator[](k)=t; }
 
       template<typename _ReferenceMap>
-      struct ReferenceMapConcept {
-
-	void constraints() {
-	  checkConcept<ReadWriteMap, _ReferenceMap >();
+      struct Constraints {
+	void constraints() {
+	  checkConcept<ReadWriteMap<K, T>, _ReferenceMap >();
+	  ref = m[key];
 	  m[key] = val;
-	  val  = m[key];
 	  m[key] = ref;
-	  ref = m[key];
+	  m[key] = cref;
+	  own_ref = m[own_key];
 	  m[own_key] = own_val;
-	  own_val  = m[own_key];
 	  m[own_key] = own_ref;
-	  own_ref = m[own_key];	  	  
-	}
-
-	typename _ReferenceMap::Key& own_key;
+	  m[own_key] = own_cref;
+	  m[key] = m[own_key];
+	  m[own_key] = m[key];
+	}
+	const Key& key;
+	Value& val;
+	Reference ref;
+	ConstReference cref;
+	const typename _ReferenceMap::Key& own_key;
 	typename _ReferenceMap::Value& own_val;
-	typename _ReferenceMap::Reference& own_ref;
-	Key& key;
-	Value& val;
-	Reference& ref;
+	typename _ReferenceMap::Reference own_ref;
+	typename _ReferenceMap::ConstReference own_cref;
 	_ReferenceMap& m;
       };
Index: lemon/error.h
===================================================================
--- lemon/error.h	(revision 66)
+++ lemon/error.h	(revision 66)
@@ -0,0 +1,675 @@
+/* -*- C++ -*-
+ *
+ * This file is a part of LEMON, a generic C++ optimization library
+ *
+ * Copyright (C) 2003-2008
+ * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
+ * (Egervary Research Group on Combinatorial Optimization, EGRES).
+ *
+ * Permission to use, modify and distribute this software is granted
+ * provided that this copyright notice appears in all copies. For
+ * precise terms see the accompanying LICENSE file.
+ *
+ * This software is provided "AS IS" with no warranty of any kind,
+ * express or implied, and with no claim as to its suitability for any
+ * purpose.
+ *
+ */
+
+#ifndef LEMON_ERROR_H
+#define LEMON_ERROR_H
+
+/// \ingroup exceptions
+/// \file
+/// \brief Basic exception classes and error handling.
+
+#include <exception>
+#include <string>
+#include <sstream>
+#include <iostream>
+#include <cstdlib>
+#include <memory>
+
+namespace lemon {
+
+  /// \addtogroup exceptions
+  /// @{
+
+  /// \brief Exception safe wrapper class.
+  ///
+  /// Exception safe wrapper class to implement the members of exceptions.
+  template <typename _Type>
+  class ExceptionMember {
+  public:
+    typedef _Type Type;
+
+    ExceptionMember() throw() {
+      try {
+	ptr.reset(new Type());
+      } catch (...) {}
+    }
+
+    ExceptionMember(const Type& type) throw() {
+      try {
+	ptr.reset(new Type());
+	if (ptr.get() == 0) return;
+	*ptr = type;
+      } catch (...) {}
+    }
+
+    ExceptionMember(const ExceptionMember& copy) throw() {
+      try {
+	if (!copy.valid()) return;
+	ptr.reset(new Type());
+	if (ptr.get() == 0) return;
+	*ptr = copy.get();
+      } catch (...) {}
+    }
+
+    ExceptionMember& operator=(const ExceptionMember& copy) throw() {
+      if (ptr.get() == 0) return;
+      try {
+	if (!copy.valid()) return;
+ 	*ptr = copy.get();
+      } catch (...) {}
+    }
+
+    void set(const Type& type) throw() {
+      if (ptr.get() == 0) return;
+      try {
+	*ptr = type;
+      } catch (...) {}
+    }
+
+    const Type& get() const {
+      return *ptr;
+    }
+
+    bool valid() const throw() {
+      return ptr.get() != 0;
+    }
+
+  private:
+    std::auto_ptr<_Type> ptr;
+  };
+
+  /// Exception-safe convenient "error message" class.
+
+  /// Helper class which provides a convenient ostream-like (operator <<
+  /// based) interface to create a string message. Mostly useful in
+  /// exception classes (therefore the name).
+  class ErrorMessage {
+  protected:
+    ///\e
+
+    ///\todo The good solution is boost::shared_ptr...
+    ///
+    mutable std::auto_ptr<std::ostringstream> buf;
+
+    ///\e
+    bool init() throw() {
+      try {
+	buf.reset(new std::ostringstream);
+      }
+      catch(...) {
+	buf.reset();
+      }
+      return buf.get();
+    }
+
+  public:
+
+    ///\e
+    ErrorMessage() throw() { init(); }
+
+    ErrorMessage(const ErrorMessage& em) throw() : buf(em.buf) { }
+
+    ///\e
+    ErrorMessage(const char *msg) throw() {
+      init();
+      *this << msg;
+    }
+
+    ///\e
+    ErrorMessage(const std::string &msg) throw() {
+      init();
+      *this << msg;
+    }
+
+    ///\e
+    template <typename T>
+    ErrorMessage& operator<<(const T &t) throw() {
+      if( ! buf.get() ) return *this;
+
+      try {
+	*buf << t;
+      }
+      catch(...) {
+	buf.reset();
+      }
+      return *this;
+    }
+
+    ///\e
+    const char* message() throw() {
+      if( ! buf.get() ) return 0;
+
+      const char* mes = 0;
+      try {
+	mes = buf->str().c_str();
+      }
+      catch(...) {}
+      return mes;
+    }
+
+  };
+
+  /// Generic exception class.
+
+  /// Base class for exceptions used in LEMON.
+  ///
+  class Exception : public std::exception {
+  public:
+    ///\e
+    Exception() {}
+    ///\e
+    virtual ~Exception() throw() {}
+    ///\e
+    virtual const char* what() const throw() {
+      return "lemon::Exception";
+    }
+  };
+
+  /// One of the two main subclasses of \ref Exception.
+
+  /// Logic errors represent problems in the internal logic of a program;
+  /// in theory, these are preventable, and even detectable before the
+  /// program runs (e.g. violations of class invariants).
+  ///
+  /// A typical example for this is \ref UninitializedParameter.
+  class LogicError : public Exception {
+  public:
+    virtual const char* what() const throw() {
+      return "lemon::LogicError";
+    }
+  };
+
+  /// \ref Exception for uninitialized parameters.
+
+  /// This error represents problems in the initialization
+  /// of the parameters of the algorithms.
+  class UninitializedParameter : public LogicError {
+  public:
+    virtual const char* what() const throw() {
+      return "lemon::UninitializedParameter";
+    }
+  };
+
+
+  /// One of the two main subclasses of \ref Exception.
+
+  /// Runtime errors represent problems outside the scope of a program;
+  /// they cannot be easily predicted and can generally only be caught
+  /// as the program executes.
+  class RuntimeError : public Exception {
+  public:
+    virtual const char* what() const throw() {
+      return "lemon::RuntimeError";
+    }
+  };
+
+  ///\e
+  class RangeError : public RuntimeError {
+  public:
+    virtual const char* what() const throw() {
+      return "lemon::RangeError";
+    }
+  };
+
+  ///\e
+  class IoError : public RuntimeError {
+  public:
+    virtual const char* what() const throw() {
+      return "lemon::IoError";
+    }
+  };
+
+  ///\e
+  class DataFormatError : public IoError {
+  protected:
+    ExceptionMember<std::string> _message;
+    ExceptionMember<std::string> _file;
+    int _line;
+
+    mutable ExceptionMember<std::string> _message_holder;
+  public:
+
+    DataFormatError(const DataFormatError &dfe) :
+      IoError(dfe), _message(dfe._message), _file(dfe._file),
+      _line(dfe._line) {}
+
+    ///\e
+    explicit DataFormatError(const char *the_message)
+      : _message(the_message), _line(0) {}
+
+    ///\e
+    DataFormatError(const std::string &file_name, int line_num,
+		    const char *the_message)
+      : _message(the_message), _line(line_num) { file(file_name); }
+
+    ///\e
+    void line(int ln) { _line = ln; }
+    ///\e
+    void message(const std::string& msg) { _message.set(msg); }
+    ///\e
+    void file(const std::string &fl) { _file.set(fl); }
+
+    ///\e
+    int line() const { return _line; }
+    ///\e
+    const char* message() const {
+      if (_message.valid() && !_message.get().empty()) {
+	return _message.get().c_str();
+      } else {
+	return 0;
+      }
+    }
+
+    /// \brief Returns the filename.
+    ///
+    /// Returns \e null if the filename was not specified.
+    const char* file() const {
+      if (_file.valid() && !_file.get().empty()) {
+	return _file.get().c_str();
+      } else {
+	return 0;
+      }
+    }
+
+    ///\e
+    virtual const char* what() const throw() {
+      try {
+	std::ostringstream ostr;
+	ostr << "lemon:DataFormatError" << ": ";
+	if (message()) ostr << message();
+	if( file() || line() != 0 ) {
+	  ostr << " (";
+	  if( file() ) ostr << "in file '" << file() << "'";
+	  if( file() && line() != 0 ) ostr << " ";
+	  if( line() != 0 ) ostr << "at line " << line();
+	  ostr << ")";
+	}
+	_message_holder.set(ostr.str());
+      }
+      catch (...) {}
+      if( _message_holder.valid()) return _message_holder.get().c_str();
+      return "lemon:DataFormatError";
+    }
+
+    virtual ~DataFormatError() throw() {}
+  };
+
+  ///\e
+  class FileOpenError : public IoError {
+  protected:
+    ExceptionMember<std::string> _file;
+
+    mutable ExceptionMember<std::string> _message_holder;
+  public:
+
+    FileOpenError(const FileOpenError &foe) :
+      IoError(foe), _file(foe._file) {}
+
+    ///\e
+    explicit FileOpenError(const std::string& fl)
+      : _file(fl) {}
+
+
+    ///\e
+    void file(const std::string &fl) { _file.set(fl); }
+
+    /// \brief Returns the filename.
+    ///
+    /// Returns \e null if the filename was not specified.
+    const char* file() const {
+      if (_file.valid() && !_file.get().empty()) {
+	return _file.get().c_str();
+      } else {
+	return 0;
+      }
+    }
+
+    ///\e
+    virtual const char* what() const throw() {
+      try {
+	std::ostringstream ostr;
+	ostr << "lemon::FileOpenError" << ": ";
+	ostr << "Cannot open file - " << file();
+	_message_holder.set(ostr.str());
+      }
+      catch (...) {}
+      if( _message_holder.valid()) return _message_holder.get().c_str();
+      return "lemon::FileOpenError";
+    }
+    virtual ~FileOpenError() throw() {}
+  };
+
+  class IoParameterError : public IoError {
+  protected:
+    ExceptionMember<std::string> _message;
+    ExceptionMember<std::string> _file;
+
+    mutable ExceptionMember<std::string> _message_holder;
+  public:
+
+    IoParameterError(const IoParameterError &ile) :
+      IoError(ile), _message(ile._message), _file(ile._file) {}
+
+    ///\e
+    explicit IoParameterError(const char *the_message)
+      : _message(the_message) {}
+
+    ///\e
+    IoParameterError(const char *file_name, const char *the_message)
+      : _message(the_message), _file(file_name) {}
+
+     ///\e
+    void message(const std::string& msg) { _message.set(msg); }
+    ///\e
+    void file(const std::string &fl) { _file.set(fl); }
+
+     ///\e
+    const char* message() const {
+      if (_message.valid()) {
+	return _message.get().c_str();
+      } else {
+	return 0;
+      }
+    }
+
+    /// \brief Returns the filename.
+    ///
+    /// Returns \c 0 if the filename was not specified.
+    const char* file() const {
+      if (_file.valid()) {
+	return _file.get().c_str();
+      } else {
+	return 0;
+      }
+    }
+
+    ///\e
+    virtual const char* what() const throw() {
+      try {
+	std::ostringstream ostr;
+	if (message()) ostr << message();
+	if (file()) ostr << "(when reading file '" << file() << "')";
+	_message_holder.set(ostr.str());
+      }
+      catch (...) {}
+      if( _message_holder.valid() ) return _message_holder.get().c_str();
+      return "lemon:IoParameterError";
+    }
+    virtual ~IoParameterError() throw() {}
+  };
+
+
+  ///\e
+  class AssertionFailedError : public LogicError {
+  protected:
+    const char *assertion;
+    const char *file;
+    int line;
+    const char *function;
+    const char *message;
+
+    mutable ExceptionMember<std::string> _message_holder;
+  public:
+    ///\e
+    AssertionFailedError(const char *_file, int _line, const char *func,
+			 const char *msg, const char *_assertion = 0) :
+      assertion(_assertion), file(_file), line(_line), function(func),
+      message(msg) {}
+
+    ///\e
+    const char* get_assertion() const { return assertion; }
+    ///\e
+    const char* get_message() const { return message; }
+    ///\e
+    const char* get_file() const { return file; }
+    ///\e
+    const char* get_function() const { return function; }
+    ///\e
+    int get_line() const { return line; }
+
+
+    virtual const char* what() const throw() {
+      try {
+	std::ostringstream ostr;
+	ostr << file << ":" << line << ": ";
+	if( function )
+	  ostr << function << ": ";
+	ostr << message;
+	if( assertion )
+	   ostr << " (assertion '" << assertion << "' failed)";
+	_message_holder.set(ostr.str());
+	return ostr.str().c_str();
+      }
+      catch(...) {}
+      if( _message_holder.valid() ) return _message_holder.get().c_str();
+      return "lemon::AssertionFailedError";
+    }
+   virtual ~AssertionFailedError() throw() {}
+  };
+
+
+  /****************  Macros  ****************/
+
+
+  template <typename Exception>
+  inline void assert_fail(const char *file, int line,
+                          const char *func,
+                          Exception exception,
+                          const char *assertion = 0,
+                          bool do_abort=true)
+  {
+    using namespace std;
+    cerr << file << ":" << line << ": ";
+    if (func)
+      cerr << func << ": ";
+    cerr << exception.what();
+    if (assertion)
+      cerr << " (assertion '" << assertion << "' failed)";
+    cerr << endl;
+    if (do_abort)
+      abort();
+  }
+
+  template <>
+  inline void assert_fail<const char *>(const char *file, int line,
+                                        const char *func,
+                                        const char *message,
+                                        const char *assertion,
+                                        bool do_abort)
+  {
+    using namespace std;
+    cerr << file << ":" << line << ": ";
+    if (func)
+      cerr << func << ": ";
+    cerr << message;
+    if (assertion)
+      cerr << " (assertion '" << assertion << "' failed)";
+    cerr << endl;
+    if (do_abort)
+      abort();
+  }
+
+  template <>
+  inline void assert_fail<std::string>(const char *file, int line,
+                                       const char *func,
+                                       std::string message,
+                                       const char *assertion,
+                                       bool do_abort)
+  {
+    assert_fail(file, line, func, message.c_str(), assertion, do_abort);
+  }
+
+  template <typename Exception>
+  inline void assert_fail_failure(const char *file, int line, const char *func,
+			   Exception exception,
+			   const char *assertion = 0,
+			   bool = true)
+  {
+    throw AssertionFailedError(file, line, func, exception.what(), assertion);
+  }
+
+  template <>
+  inline void assert_fail_failure<const char *>(const char *file, int line,
+                                                const char *func,
+                                                const char *message,
+                                                const char *assertion,
+                                                bool)
+  {
+    throw AssertionFailedError(file, line, func, message, assertion);
+  }
+
+  template <>
+  inline void assert_fail_failure<std::string>(const char *file, int line,
+                                               const char *func,
+                                               std::string message,
+                                               const char *assertion,
+                                               bool)
+  {
+    assert_fail_failure(file, line, func, message.c_str(), assertion, true);
+  }
+
+  template <typename Exception>
+  inline void assert_fail_exception(const char *file, int line, const char *func,
+			     Exception exception,
+			     const char *assertion = 0, bool = true)
+  {
+    throw exception;
+  }
+
+  template <>
+  inline void assert_fail_exception<const char *>(const char *file, int line,
+					   const char *func,
+					   const char *message,
+					   const char *assertion,
+					   bool)
+  {
+    throw AssertionFailedError(file, line, func, message, assertion);
+  }
+
+  template <>
+  inline void assert_fail_exception<std::string>(const char *file, int line,
+                                                 const char *func,
+                                                 std::string message,
+                                                 const char *assertion,
+                                                 bool)
+  {
+    assert_fail_exception(file, line, func, message.c_str(), assertion, true);
+  }
+
+/// @}
+
+}
+#endif // LEMON_ERROR_H
+
+#undef LEMON_ASSERT
+#undef LEMON_FIXME
+
+#ifdef LEMON_ENABLE_ASSERTS
+#  define LEMON_ASSERT_ABORT
+#endif
+
+#ifndef LEMON_ASSERT_DO_ABORT
+#  define LEMON_ASSERT_DO_ABORT 1
+#endif
+
+#ifndef LEMON_ASSERT_HANDLER
+#  if defined LEMON_ASSERT_EXCEPTION
+#    define LEMON_ASSERT_HANDLER ::lemon::assert_fail_exception
+#  elif defined LEMON_ASSERT_FAILURE
+#    define LEMON_ASSERT_HANDLER ::lemon::assert_fail_failure
+#  elif defined LEMON_ASSERT_ABORT
+#    define LEMON_ASSERT_HANDLER ::lemon::assert_fail
+#  else
+#    define LEMON_DISABLE_ASSERTS
+#  endif
+#endif
+
+#ifdef DOXYGEN
+
+/// \brief Macro for assertions with customizable message
+///
+/// Macro for assertions with customizable message.
+///
+/// The assertions are disabled in the default behaviour. You can
+/// enable the assertions with the
+/// \code
+/// #define LEMON_ENABLE_ASSERTS
+/// \endcode
+/// Then an assert
+/// provides a log on the standard error about the assertion and aborts
+/// the program if LEMON_ASSERT_DO_ABORT is also defined (otherwise the
+/// program keeps on running).
+/// By defining LEMON_ASSERT_FAILURE or
+/// LEMON_ASSERT_EXCEPTION, you can set other behaviour to the
+/// assertions. In case LEMON_ASSERT_FAILURE is given, LEMON_ASSERT
+/// will always throw an \c AssertionFailedError exception with
+/// the \c msg error message. By using
+/// LEMON_ASSERT_EXCEPTION, one can define an arbitrary exception to be thrown.
+///
+/// The LEMON_ASSERT macro should be called with the \c exp parameter
+/// which should be an expression convertible to bool. If the given
+/// parameter is false the assertion is raised and one of the assertion
+/// behaviour will be activated. The \c msg should be either a const
+/// char* message or an exception. When the \c msg is an exception the
+/// \ref lemon::Exception::what() "what()" function is called to retrieve and
+/// display the error message.
+///
+/// \todo We should provide some way to reset to the default behaviour,
+/// shouldn't we?
+///
+/// \todo This whole 'assert' business should be placed in a separate
+/// include file. The boost assert is not guarded by header sentries
+/// which may help to change the behaviour of the assertions in
+/// the files.
+///
+/// \todo __PRETTY_FUNCTION__ should be replaced by something
+/// compiler-independent, like BOOST_CURRENT_FUNCTION
+
+#  define LEMON_ASSERT(exp, msg)                 \
+     (static_cast<void> (!!(exp) ? 0 : (         \
+       LEMON_ASSERT_HANDLER(__FILE__, __LINE__,  \
+                            __PRETTY_FUNCTION__, \
+                            msg, #exp, LEMON_ASSERT_DO_ABORT), 0)))
+
+#else
+#  if defined LEMON_DISABLE_ASSERTS
+
+#    define LEMON_ASSERT(exp, msg)  (static_cast<void> (0))
+
+#  else
+#    define LEMON_ASSERT(exp, msg)                 \
+       (static_cast<void> (!!(exp) ? 0 : (         \
+         LEMON_ASSERT_HANDLER(__FILE__, __LINE__,  \
+                              __PRETTY_FUNCTION__, \
+                              msg, #exp, LEMON_ASSERT_DO_ABORT), 0)))
+#  endif
+#endif
+
+/**
+ * \brief Macro for mark not yet implemented features.
+ *
+ * \todo Is this the right place for this? It should be used only in
+ * modules under development.
+ *
+ * \todo __PRETTY_FUNCTION__ should be replaced by something
+ * compiler-independent, like BOOST_CURRENT_FUNCTION
+ */
+
+#define LEMON_FIXME(msg) \
+    (LEMON_ASSERT_HANDLER(__FILE__, __LINE__, __PRETTY_FUNCTION__, \
+			  "FIXME: " msg))
Index: lemon/list_graph.h
===================================================================
--- lemon/list_graph.h	(revision 57)
+++ lemon/list_graph.h	(revision 73)
@@ -112,10 +112,10 @@
 
 
-    void first(Arc& e) const { 
+    void first(Arc& arc) const { 
       int n;
       for(n = first_node; 
 	  n!=-1 && nodes[n].first_in == -1; 
 	  n = nodes[n].next);
-      e.id = (n == -1) ? -1 : nodes[n].first_in;
+      arc.id = (n == -1) ? -1 : nodes[n].first_in;
     }
 
@@ -294,33 +294,35 @@
   typedef DigraphExtender<ListDigraphBase> ExtendedListDigraphBase;
 
-  /// \addtogroup digraphs
+  /// \addtogroup graphs
   /// @{
 
-  ///A list digraph class.
-
-  ///This is a simple and fast digraph implementation.
+  ///A general directed graph structure. 
+
+  ///\ref ListDigraph is a simple and fast <em>directed graph</em> 
+  ///implementation based on static linked lists that are stored in 
+  ///\c std::vector structures.   
   ///
   ///It conforms to the \ref concepts::Digraph "Digraph concept" and it
-  ///also provides several additional useful extra functionalities.
-  ///The most of the member functions and nested classes are
-  ///documented only in the concept class.
+  ///also provides several useful additional functionalities.
+  ///Most of the member functions and nested classes are documented
+  ///only in the concept class.
   ///
   ///An important extra feature of this digraph implementation is that
   ///its maps are real \ref concepts::ReferenceMap "reference map"s.
   ///
-  ///\sa concepts::Digraph.
+  ///\sa concepts::Digraph
 
   class ListDigraph : public ExtendedListDigraphBase {
   private:
-    ///ListDigraph is \e not copy constructible. Use DigraphCopy() instead.
-    
-    ///ListDigraph is \e not copy constructible. Use DigraphCopy() instead.
+    ///ListDigraph is \e not copy constructible. Use copyDigraph() instead.
+    
+    ///ListDigraph is \e not copy constructible. Use copyDigraph() instead.
     ///
     ListDigraph(const ListDigraph &) :ExtendedListDigraphBase() {};
     ///\brief Assignment of ListDigraph to another one is \e not allowed.
-    ///Use DigraphCopy() instead.
+    ///Use copyDigraph() instead.
 
     ///Assignment of ListDigraph to another one is \e not allowed.
-    ///Use DigraphCopy() instead.
+    ///Use copyDigraph() instead.
     void operator=(const ListDigraph &) {}
   public:
@@ -336,6 +338,6 @@
     ///Add a new node to the digraph.
     
-    /// \return the new node.
-    ///
+    ///Add a new node to the digraph.
+    ///\return the new node.
     Node addNode() { return Parent::addNode(); }
 
@@ -349,11 +351,12 @@
     }
 
-    /// Changes the target of \c e to \c n
-
-    /// Changes the target of \c e to \c n
+    /// Change the target of \c e to \c n
+
+    /// Change the target of \c e to \c n
     ///
     ///\note The <tt>ArcIt</tt>s and <tt>OutArcIt</tt>s referencing
     ///the changed arc remain valid. However <tt>InArcIt</tt>s are
     ///invalidated.
+    ///
     ///\warning This functionality cannot be used together with the Snapshot
     ///feature.
@@ -361,11 +364,12 @@
       Parent::changeTarget(e,n); 
     }
-    /// Changes the source of \c e to \c n
-
-    /// Changes the source of \c e to \c n
+    /// Change the source of \c e to \c n
+
+    /// Change the source of \c e to \c n
     ///
     ///\note The <tt>ArcIt</tt>s and <tt>InArcIt</tt>s referencing
     ///the changed arc remain valid. However <tt>OutArcIt</tt>s are
     ///invalidated.
+    ///
     ///\warning This functionality cannot be used together with the Snapshot
     ///feature.
@@ -379,4 +383,5 @@
     ///valid. However <tt>OutArcIt</tt>s and <tt>InArcIt</tt>s are
     ///invalidated.
+    ///
     ///\warning This functionality cannot be used together with the Snapshot
     ///feature.
@@ -387,5 +392,7 @@
     }
 
-    /// Using this it is possible to avoid the superfluous memory
+    /// Reserve memory for nodes.
+
+    /// Using this function it is possible to avoid the superfluous memory
     /// allocation: if you know that the digraph you want to build will
     /// be very large (e.g. it will contain millions of nodes and/or arcs)
@@ -395,8 +402,7 @@
     void reserveNode(int n) { nodes.reserve(n); };
 
-    /// \brief Using this it is possible to avoid the superfluous memory
-    /// allocation.
-
-    /// Using this it is possible to avoid the superfluous memory
+    /// Reserve memory for arcs.
+
+    /// Using this function it is possible to avoid the superfluous memory
     /// allocation: if you know that the digraph you want to build will
     /// be very large (e.g. it will contain millions of nodes and/or arcs)
@@ -409,5 +415,4 @@
 
     ///This function contracts two nodes.
-    ///
     ///Node \p b will be removed but instead of deleting
     ///incident arcs, they will be joined to \p a.
@@ -415,8 +420,8 @@
     ///means that loops will be removed.
     ///
-    ///\note The <tt>ArcIt</tt>s
-    ///referencing a moved arc remain
+    ///\note The <tt>ArcIt</tt>s referencing a moved arc remain
     ///valid. However <tt>InArcIt</tt>s and <tt>OutArcIt</tt>s
     ///may be invalidated.
+    ///
     ///\warning This functionality cannot be used together with the Snapshot
     ///feature.
@@ -453,6 +458,7 @@
     ///
     ///\warning This functionality cannot be used together with the
-    ///Snapshot feature.  \todo It could be implemented in a bit
-    ///faster way.
+    ///Snapshot feature.
+    ///
+    ///\todo It could be implemented in a bit faster way.
     Node split(Node n, bool connect = true) {
       Node b = addNode();
@@ -472,7 +478,9 @@
     ///the digraph, then the original arc is re-targeted to \c
     ///b. Finally an arc from \c b to the original target is added.
-    ///\return The newly created node.  
-    ///\warning This functionality
-    ///cannot be used together with the Snapshot feature.
+    ///
+    ///\return The newly created node.
+    ///
+    ///\warning This functionality cannot be used together with the
+    ///Snapshot feature.
     Node split(Arc e) {
       Node b = addNode();
@@ -483,14 +491,14 @@
       
     /// \brief Class to make a snapshot of the digraph and restore
-    /// to it later.
-    ///
-    /// Class to make a snapshot of the digraph and to restore it
-    /// later.
+    /// it later.
+    ///
+    /// Class to make a snapshot of the digraph and restore it later.
     ///
     /// The newly added nodes and arcs can be removed using the
     /// restore() function.
     ///
-    /// \warning Arc and node deletions cannot be restored. This
-    /// events invalidate the snapshot. 
+    /// \warning Arc and node deletions and other modifications (e.g.
+    /// contracting, splitting, reversing arcs or nodes) cannot be 
+    /// restored. These events invalidate the snapshot. 
     class Snapshot {
     protected:
@@ -777,7 +785,7 @@
       Edge() {}
       Edge (Invalid) { id = -1; }
-      bool operator==(const Edge& arc) const {return id == arc.id;}
-      bool operator!=(const Edge& arc) const {return id != arc.id;}
-      bool operator<(const Edge& arc) const {return id < arc.id;}
+      bool operator==(const Edge& edge) const {return id == edge.id;}
+      bool operator!=(const Edge& edge) const {return id != edge.id;}
+      bool operator<(const Edge& edge) const {return id < edge.id;}
     };
 
@@ -910,8 +918,8 @@
 
     void firstInc(Edge &e, bool& d, const Node& v) const {
-      int de = nodes[v.id].first_out;
-      if (de != -1 ) {
-        e.id = de / 2;
-        d = ((de & 1) == 1);
+      int a = nodes[v.id].first_out;
+      if (a != -1 ) {
+        e.id = a / 2;
+        d = ((a & 1) == 1);
       } else {
         e.id = -1;
@@ -920,8 +928,8 @@
     }
     void nextInc(Edge &e, bool& d) const {
-      int de = (arcs[(e.id * 2) | (d ? 1 : 0)].next_out);
-      if (de != -1 ) {
-        e.id = de / 2;
-        d = ((de & 1) == 1);
+      int a = (arcs[(e.id * 2) | (d ? 1 : 0)].next_out);
+      if (a != -1 ) {
+        e.id = a / 2;
+        d = ((a & 1) == 1);
       } else {
         e.id = -1;
@@ -1009,6 +1017,6 @@
     }
     
-    void erase(const Edge& arc) {
-      int n = arc.id * 2;
+    void erase(const Edge& edge) {
+      int n = edge.id * 2;
       
       if (arcs[n].next_out != -1) {
@@ -1090,38 +1098,38 @@
   };
 
-//   typedef GraphExtender<UndirDigraphExtender<ListDigraphBase> > 
-//   ExtendedListGraphBase;
-
   typedef GraphExtender<ListGraphBase> ExtendedListGraphBase;
 
 
-
-  /// \addtogroup digraphs
+  /// \addtogroup graphs
   /// @{
 
-  ///An undirected list digraph class.
-
-  ///This is a simple and fast undirected digraph implementation.
+  ///A general undirected graph structure.
+
+  ///\ref ListGraph is a simple and fast <em>undirected graph</em> 
+  ///implementation based on static linked lists that are stored in 
+  ///\c std::vector structures. 
   ///
-  ///An important extra feature of this digraph implementation is that
+  ///It conforms to the \ref concepts::Graph "Graph concept" and it
+  ///also provides several useful additional functionalities.
+  ///Most of the member functions and nested classes are documented
+  ///only in the concept class.
+  ///
+  ///An important extra feature of this graph implementation is that
   ///its maps are real \ref concepts::ReferenceMap "reference map"s.
   ///
-  ///It conforms to the
-  ///\ref concepts::Graph "Graph concept".
-  ///
-  ///\sa concepts::Graph.
-  ///
+  ///\sa concepts::Graph
+
   class ListGraph : public ExtendedListGraphBase {
   private:
-    ///ListGraph is \e not copy constructible. Use GraphCopy() instead.
-
-    ///ListGraph is \e not copy constructible. Use GraphCopy() instead.
+    ///ListGraph is \e not copy constructible. Use copyGraph() instead.
+
+    ///ListGraph is \e not copy constructible. Use copyGraph() instead.
     ///
     ListGraph(const ListGraph &) :ExtendedListGraphBase()  {};
     ///\brief Assignment of ListGraph to another one is \e not allowed.
-    ///Use GraphCopy() instead.
+    ///Use copyGraph() instead.
 
     ///Assignment of ListGraph to another one is \e not allowed.
-    ///Use GraphCopy() instead.
+    ///Use copyGraph() instead.
     void operator=(const ListGraph &) {}
   public:
@@ -1134,15 +1142,15 @@
     typedef ExtendedListGraphBase Parent;
 
-    typedef Parent::OutArcIt IncArcIt;
-
-    /// \brief Add a new node to the digraph.
-    ///
+    typedef Parent::OutArcIt IncEdgeIt;
+
+    /// \brief Add a new node to the graph.
+    ///
+    /// Add a new node to the graph.
     /// \return the new node.
-    ///
     Node addNode() { return Parent::addNode(); }
 
-    /// \brief Add a new edge to the digraph.
-    ///
-    /// Add a new arc to the digraph with source node \c s
+    /// \brief Add a new edge to the graph.
+    ///
+    /// Add a new edge to the graph with source node \c s
     /// and target node \c t.
     /// \return the new edge.
@@ -1150,31 +1158,40 @@
       return Parent::addEdge(s, t); 
     }
-    /// \brief Changes the source of \c e to \c n
-    ///
-    /// Changes the source of \c e to \c n
+    /// \brief Change the source of \c e to \c n
+    ///
+    /// This function changes the source of \c e to \c n.
     ///
     ///\note The <tt>ArcIt</tt>s and <tt>InArcIt</tt>s
     ///referencing the changed arc remain
     ///valid. However <tt>OutArcIt</tt>s are invalidated.
+    ///
+    ///\warning This functionality cannot be used together with the
+    ///Snapshot feature.
     void changeSource(Edge e, Node n) { 
       Parent::changeSource(e,n); 
     }    
-    /// \brief Changes the target of \c e to \c n
-    ///
-    /// Changes the target of \c e to \c n
+    /// \brief Change the target of \c e to \c n
+    ///
+    /// This function changes the target of \c e to \c n.
     ///
     /// \note The <tt>ArcIt</tt>s referencing the changed arc remain
     /// valid. However the other iterators may be invalidated.
+    ///
+    ///\warning This functionality cannot be used together with the
+    ///Snapshot feature.
     void changeTarget(Edge e, Node n) { 
       Parent::changeTarget(e,n); 
     }
-    /// \brief Changes the source of \c e to \c n
-    ///
-    /// Changes the source of \c e to \c n. It changes the proper
-    /// node of the represented edge.
+    /// \brief Change the source of \c e to \c n
+    ///
+    /// This function changes the source of \c e to \c n. 
+    /// It also changes the proper node of the represented edge.
     ///
     ///\note The <tt>ArcIt</tt>s and <tt>InArcIt</tt>s
     ///referencing the changed arc remain
     ///valid. However <tt>OutArcIt</tt>s are invalidated.
+    ///
+    ///\warning This functionality cannot be used together with the
+    ///Snapshot feature.
     void changeSource(Arc e, Node n) { 
       if (Parent::direction(e)) {
@@ -1184,12 +1201,15 @@
       } 
     }
-    /// \brief Changes the target of \c e to \c n
-    ///
-    /// Changes the target of \c e to \c n. It changes the proper
-    /// node of the represented edge.
+    /// \brief Change the target of \c e to \c n
+    ///
+    /// This function changes the target of \c e to \c n. 
+    /// It also changes the proper node of the represented edge.
     ///
     ///\note The <tt>ArcIt</tt>s and <tt>OutArcIt</tt>s
     ///referencing the changed arc remain
     ///valid. However <tt>InArcIt</tt>s are invalidated.
+    ///
+    ///\warning This functionality cannot be used together with the
+    ///Snapshot feature.
     void changeTarget(Arc e, Node n) { 
       if (Parent::direction(e)) {
@@ -1202,5 +1222,4 @@
     ///
     /// This function contracts two nodes.
-    ///
     /// Node \p b will be removed but instead of deleting
     /// its neighboring arcs, they will be joined to \p a.
@@ -1210,7 +1229,10 @@
     /// \note The <tt>ArcIt</tt>s referencing a moved arc remain
     /// valid.
+    ///
+    ///\warning This functionality cannot be used together with the
+    ///Snapshot feature.
     void contract(Node a, Node b, bool r = true) {
-      for(IncArcIt e(*this, b); e!=INVALID;) {
-	IncArcIt f = e; ++f;
+      for(IncEdgeIt e(*this, b); e!=INVALID;) {
+	IncEdgeIt f = e; ++f;
 	if (r && runningNode(e) == a) {
 	  erase(e);
@@ -1226,15 +1248,15 @@
 
 
-    /// \brief Class to make a snapshot of the digraph and restore
-    /// to it later.
-    ///
-    /// Class to make a snapshot of the digraph and to restore it
-    /// later.
+    /// \brief Class to make a snapshot of the graph and restore
+    /// it later.
+    ///
+    /// Class to make a snapshot of the graph and restore it later.
     ///
     /// The newly added nodes and edges can be removed
     /// using the restore() function.
     ///
-    /// \warning Arc and node deletions cannot be restored. This
-    /// events invalidate the snapshot. 
+    /// \warning Edge and node deletions and other modifications
+    /// (e.g. changing nodes of edges, contracting nodes) cannot be 
+    /// restored. These events invalidate the snapshot.
     class Snapshot {
     protected:
@@ -1304,36 +1326,36 @@
       protected:
 
-        virtual void add(const Edge& arc) {
-          snapshot.addEdge(arc);
-        }
-        virtual void add(const std::vector<Edge>& arcs) {
-          for (int i = arcs.size() - 1; i >= 0; ++i) {
-            snapshot.addEdge(arcs[i]);
-          }
-        }
-        virtual void erase(const Edge& arc) {
-          snapshot.eraseEdge(arc);
-        }
-        virtual void erase(const std::vector<Edge>& arcs) {
-          for (int i = 0; i < int(arcs.size()); ++i) {
-            snapshot.eraseEdge(arcs[i]);
+        virtual void add(const Edge& edge) {
+          snapshot.addEdge(edge);
+        }
+        virtual void add(const std::vector<Edge>& edges) {
+          for (int i = edges.size() - 1; i >= 0; ++i) {
+            snapshot.addEdge(edges[i]);
+          }
+        }
+        virtual void erase(const Edge& edge) {
+          snapshot.eraseEdge(edge);
+        }
+        virtual void erase(const std::vector<Edge>& edges) {
+          for (int i = 0; i < int(edges.size()); ++i) {
+            snapshot.eraseEdge(edges[i]);
           }
         }
         virtual void build() {
-          Edge arc;
-          std::vector<Edge> arcs;
-          for (notifier()->first(arc); arc != INVALID; 
-               notifier()->next(arc)) {
-            arcs.push_back(arc);
-          }
-          for (int i = arcs.size() - 1; i >= 0; --i) {
-            snapshot.addEdge(arcs[i]);
+          Edge edge;
+          std::vector<Edge> edges;
+          for (notifier()->first(edge); edge != INVALID; 
+               notifier()->next(edge)) {
+            edges.push_back(edge);
+          }
+          for (int i = edges.size() - 1; i >= 0; --i) {
+            snapshot.addEdge(edges[i]);
           }
         }
         virtual void clear() {
-          Edge arc;
-          for (notifier()->first(arc); arc != INVALID; 
-               notifier()->next(arc)) {
-            snapshot.eraseEdge(arc);
+          Edge edge;
+          for (notifier()->first(edge); edge != INVALID; 
+               notifier()->next(edge)) {
+            snapshot.eraseEdge(edge);
           }
         }
@@ -1341,12 +1363,12 @@
         Snapshot& snapshot;
       };
-      
-      ListGraph *digraph;
+
+      ListGraph *graph;
 
       NodeObserverProxy node_observer_proxy;
-      EdgeObserverProxy arc_observer_proxy;
+      EdgeObserverProxy edge_observer_proxy;
 
       std::list<Node> added_nodes;
-      std::list<Edge> added_arcs;
+      std::list<Edge> added_edges;
 
 
@@ -1359,5 +1381,5 @@
         if (it == added_nodes.end()) {
           clear();
-          arc_observer_proxy.detach();
+          edge_observer_proxy.detach();
           throw NodeNotifier::ImmediateDetach();
         } else {
@@ -1366,28 +1388,28 @@
       }
 
-      void addEdge(const Edge& arc) {
-        added_arcs.push_front(arc);        
-      }
-      void eraseEdge(const Edge& arc) {
+      void addEdge(const Edge& edge) {
+        added_edges.push_front(edge);        
+      }
+      void eraseEdge(const Edge& edge) {
         std::list<Edge>::iterator it = 
-          std::find(added_arcs.begin(), added_arcs.end(), arc);
-        if (it == added_arcs.end()) {
+          std::find(added_edges.begin(), added_edges.end(), edge);
+        if (it == added_edges.end()) {
           clear();
           node_observer_proxy.detach();
           throw EdgeNotifier::ImmediateDetach();
         } else {
-          added_arcs.erase(it);
-        }        
-      }
-
-      void attach(ListGraph &_digraph) {
-	digraph = &_digraph;
-	node_observer_proxy.attach(digraph->notifier(Node()));
-        arc_observer_proxy.attach(digraph->notifier(Edge()));
+          added_edges.erase(it);
+        }
+      }
+
+      void attach(ListGraph &_graph) {
+	graph = &_graph;
+	node_observer_proxy.attach(graph->notifier(Node()));
+        edge_observer_proxy.attach(graph->notifier(Edge()));
       }
             
       void detach() {
 	node_observer_proxy.detach();
-	arc_observer_proxy.detach();
+	edge_observer_proxy.detach();
       }
 
@@ -1398,5 +1420,5 @@
       void clear() {
         added_nodes.clear();
-        added_arcs.clear();        
+        added_edges.clear();        
       }
 
@@ -1408,30 +1430,30 @@
       /// To actually make a snapshot you must call save().
       Snapshot() 
-        : digraph(0), node_observer_proxy(*this), 
-          arc_observer_proxy(*this) {}
+        : graph(0), node_observer_proxy(*this), 
+          edge_observer_proxy(*this) {}
       
       /// \brief Constructor that immediately makes a snapshot.
       ///      
-      /// This constructor immediately makes a snapshot of the digraph.
-      /// \param _digraph The digraph we make a snapshot of.
-      Snapshot(ListGraph &_digraph) 
+      /// This constructor immediately makes a snapshot of the graph.
+      /// \param _graph The graph we make a snapshot of.
+      Snapshot(ListGraph &_graph) 
         : node_observer_proxy(*this), 
-          arc_observer_proxy(*this) {
-	attach(_digraph);
+          edge_observer_proxy(*this) {
+	attach(_graph);
       }
       
       /// \brief Make a snapshot.
       ///
-      /// Make a snapshot of the digraph.
+      /// Make a snapshot of the graph.
       ///
       /// This function can be called more than once. In case of a repeated
       /// call, the previous snapshot gets lost.
-      /// \param _digraph The digraph we make the snapshot of.
-      void save(ListGraph &_digraph) {
+      /// \param _graph The graph we make the snapshot of.
+      void save(ListGraph &_graph) {
         if (attached()) {
           detach();
           clear();
         }
-        attach(_digraph);
+        attach(_graph);
       }
       
@@ -1441,11 +1463,11 @@
       void restore() {
 	detach();
-	for(std::list<Edge>::iterator it = added_arcs.begin(); 
-            it != added_arcs.end(); ++it) {
-	  digraph->erase(*it);
+	for(std::list<Edge>::iterator it = added_edges.begin(); 
+            it != added_edges.end(); ++it) {
+	  graph->erase(*it);
 	}
 	for(std::list<Node>::iterator it = added_nodes.begin(); 
             it != added_nodes.end(); ++it) {
-	  digraph->erase(*it);
+	  graph->erase(*it);
 	}
         clear();
Index: lemon/maps.h
===================================================================
--- lemon/maps.h	(revision 54)
+++ lemon/maps.h	(revision 82)
@@ -25,10 +25,10 @@
 
 #include <lemon/bits/utility.h>
-// #include <lemon/bits/traits.h>
+#include <lemon/bits/traits.h>
 
 ///\file
 ///\ingroup maps
 ///\brief Miscellaneous property maps
-///
+
 #include <map>
 
@@ -40,39 +40,44 @@
   /// Base class of maps.
 
-  /// Base class of maps.
-  /// It provides the necessary <tt>typedef</tt>s required by the map concept.
-  template<typename K, typename T>
+  /// Base class of maps. It provides the necessary type definitions
+  /// required by the map %concepts.
+  template<typename K, typename V>
   class MapBase {
   public:
-    /// The key type of the map.
+    /// \biref The key type of the map.
     typedef K Key;
-    /// The value type of the map. (The type of objects associated with the keys).
-    typedef T Value;
-  };
+    /// \brief The value type of the map.
+    /// (The type of objects associated with the keys).
+    typedef V Value;
+  };
+
 
   /// Null map. (a.k.a. DoNothingMap)
 
   /// This map can be used if you have to provide a map only for
-  /// its type definitions, or if you have to provide a writable map, 
-  /// but data written to it is not required (i.e. it will be sent to 
+  /// its type definitions, or if you have to provide a writable map,
+  /// but data written to it is not required (i.e. it will be sent to
   /// <tt>/dev/null</tt>).
-  template<typename K, typename T>
-  class NullMap : public MapBase<K, T> {
-  public:
-    typedef MapBase<K, T> Parent;
-    typedef typename Parent::Key Key;
-    typedef typename Parent::Value Value;
-    
+  /// It conforms the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
+  ///
+  /// \sa ConstMap
+  template<typename K, typename V>
+  class NullMap : public MapBase<K, V> {
+  public:
+    typedef MapBase<K, V> Parent;
+    typedef typename Parent::Key Key;
+    typedef typename Parent::Value Value;
+
     /// Gives back a default constructed element.
-    T operator[](const K&) const { return T(); }
+    Value operator[](const Key&) const { return Value(); }
     /// Absorbs the value.
-    void set(const K&, const T&) {}
-  };
-
-  ///Returns a \c NullMap class
-
-  ///This function just returns a \c NullMap class.
-  ///\relates NullMap
-  template <typename K, typename V> 
+    void set(const Key&, const Value&) {}
+  };
+
+  /// Returns a \ref NullMap class
+
+  /// This function just returns a \ref NullMap class.
+  /// \relates NullMap
+  template <typename K, typename V>
   NullMap<K, V> nullMap() {
     return NullMap<K, V>();
@@ -82,14 +87,22 @@
   /// Constant map.
 
-  /// This is a \ref concepts::ReadMap "readable" map which assigns a 
-  /// specified value to each key.
-  /// In other aspects it is equivalent to \c NullMap.
-  template<typename K, typename T>
-  class ConstMap : public MapBase<K, T> {
+  /// This \ref concepts::ReadMap "readable map" assigns a specified
+  /// value to each key.
+  ///
+  /// In other aspects it is equivalent to \ref NullMap.
+  /// So it conforms the \ref concepts::ReadWriteMap "ReadWriteMap"
+  /// concept, but it absorbs the data written to it.
+  ///
+  /// The simplest way of using this map is through the constMap()
+  /// function.
+  ///
+  /// \sa NullMap
+  /// \sa IdentityMap
+  template<typename K, typename V>
+  class ConstMap : public MapBase<K, V> {
   private:
-    T v;
-  public:
-
-    typedef MapBase<K, T> Parent;
+    V _value;
+  public:
+    typedef MapBase<K, V> Parent;
     typedef typename Parent::Key Key;
     typedef typename Parent::Value Value;
@@ -98,31 +111,33 @@
 
     /// Default constructor.
-    /// The value of the map will be uninitialized. 
-    /// (More exactly it will be default constructed.)
+    /// The value of the map will be default constructed.
     ConstMap() {}
-    
+
     /// Constructor with specified initial value
 
     /// Constructor with specified initial value.
-    /// \param _v is the initial value of the map.
-    ConstMap(const T &_v) : v(_v) {}
-    
-    ///\e
-    T operator[](const K&) const { return v; }
-
-    ///\e
-    void setAll(const T &t) {
-      v = t;
-    }    
-
-    template<typename T1>
-    ConstMap(const ConstMap<K, T1> &, const T &_v) : v(_v) {}
-  };
-
-  ///Returns a \c ConstMap class
-
-  ///This function just returns a \c ConstMap class.
-  ///\relates ConstMap
-  template<typename K, typename V> 
+    /// \param v is the initial value of the map.
+    ConstMap(const Value &v) : _value(v) {}
+
+    /// Gives back the specified value.
+    Value operator[](const Key&) const { return _value; }
+
+    /// Absorbs the value.
+    void set(const Key&, const Value&) {}
+
+    /// Sets the value that is assigned to each key.
+    void setAll(const Value &v) {
+      _value = v;
+    }
+
+    template<typename V1>
+    ConstMap(const ConstMap<K, V1> &, const Value &v) : _value(v) {}
+  };
+
+  /// Returns a \ref ConstMap class
+
+  /// This function just returns a \ref ConstMap class.
+  /// \relates ConstMap
+  template<typename K, typename V>
   inline ConstMap<K, V> constMap(const V &v) {
     return ConstMap<K, V>(v);
@@ -131,11 +146,20 @@
 
   template<typename T, T v>
-  struct Const { };
+  struct Const {};
 
   /// Constant map with inlined constant value.
 
-  /// This is a \ref concepts::ReadMap "readable" map which assigns a 
-  /// specified value to each key.
-  /// In other aspects it is equivalent to \c NullMap.
+  /// This \ref concepts::ReadMap "readable map" assigns a specified
+  /// value to each key.
+  ///
+  /// In other aspects it is equivalent to \ref NullMap.
+  /// So it conforms the \ref concepts::ReadWriteMap "ReadWriteMap"
+  /// concept, but it absorbs the data written to it.
+  ///
+  /// The simplest way of using this map is through the constMap()
+  /// function.
+  ///
+  /// \sa NullMap
+  /// \sa IdentityMap
   template<typename K, typename V, V v>
   class ConstMap<K, Const<V, v> > : public MapBase<K, V> {
@@ -145,67 +169,228 @@
     typedef typename Parent::Value Value;
 
-    ConstMap() { }
-    ///\e
-    V operator[](const K&) const { return v; }
-    ///\e
-    void set(const K&, const V&) { }
-  };
-
-  ///Returns a \c ConstMap class with inlined value
-
-  ///This function just returns a \c ConstMap class with inlined value.
-  ///\relates ConstMap
-  template<typename K, typename V, V v> 
+    /// Constructor.
+    ConstMap() {}
+
+    /// Gives back the specified value.
+    Value operator[](const Key&) const { return v; }
+
+    /// Absorbs the value.
+    void set(const Key&, const Value&) {}
+  };
+
+  /// Returns a \ref ConstMap class with inlined constant value
+
+  /// This function just returns a \ref ConstMap class with inlined
+  /// constant value.
+  /// \relates ConstMap
+  template<typename K, typename V, V v>
   inline ConstMap<K, Const<V, v> > constMap() {
     return ConstMap<K, Const<V, v> >();
   }
 
-  ///Map based on \c std::map
-
-  ///This is essentially a wrapper for \c std::map with addition that
-  ///you can specify a default value different from \c Value().
-  ///It meets the \ref concepts::ReferenceMap "ReferenceMap" concept.
-  template <typename K, typename T, typename Compare = std::less<K> >
-  class StdMap : public MapBase<K, T> {
-    template <typename K1, typename T1, typename C1>
-    friend class StdMap;
-  public:
-
-    typedef MapBase<K, T> Parent;
-    ///Key type
-    typedef typename Parent::Key Key;
-    ///Value type
-    typedef typename Parent::Value Value;
-    ///Reference Type
-    typedef T& Reference;
-    ///Const reference type
-    typedef const T& ConstReference;
+
+  /// Identity map.
+
+  /// This \ref concepts::ReadMap "read-only map" gives back the given
+  /// key as value without any modification.
+  ///
+  /// \sa ConstMap
+  template <typename T>
+  class IdentityMap : public MapBase<T, T> {
+  public:
+    typedef MapBase<T, T> Parent;
+    typedef typename Parent::Key Key;
+    typedef typename Parent::Value Value;
+
+    /// Gives back the given value without any modification.
+    Value operator[](const Key &k) const {
+      return k;
+    }
+  };
+
+  /// Returns an \ref IdentityMap class
+
+  /// This function just returns an \ref IdentityMap class.
+  /// \relates IdentityMap
+  template<typename T>
+  inline IdentityMap<T> identityMap() {
+    return IdentityMap<T>();
+  }
+
+
+  /// \brief Map for storing values for integer keys from the range
+  /// <tt>[0..size-1]</tt>.
+  ///
+  /// This map is essentially a wrapper for \c std::vector. It assigns
+  /// values to integer keys from the range <tt>[0..size-1]</tt>.
+  /// It can be used with some data structures, for example
+  /// \ref UnionFind, \ref BinHeap, when the used items are small
+  /// integers. This map conforms the \ref concepts::ReferenceMap
+  /// "ReferenceMap" concept.
+  ///
+  /// The simplest way of using this map is through the rangeMap()
+  /// function.
+  template <typename V>
+  class RangeMap : public MapBase<int, V> {
+    template <typename V1>
+    friend class RangeMap;
+  private:
+
+    typedef std::vector<V> Vector;
+    Vector _vector;
+
+  public:
+
+    typedef MapBase<int, V> Parent;
+    /// Key type
+    typedef typename Parent::Key Key;
+    /// Value type
+    typedef typename Parent::Value Value;
+    /// Reference type
+    typedef typename Vector::reference Reference;
+    /// Const reference type
+    typedef typename Vector::const_reference ConstReference;
 
     typedef True ReferenceMapTag;
 
+  public:
+
+    /// Constructor with specified default value.
+    RangeMap(int size = 0, const Value &value = Value())
+      : _vector(size, value) {}
+
+    /// Constructs the map from an appropriate \c std::vector.
+    template <typename V1>
+    RangeMap(const std::vector<V1>& vector)
+      : _vector(vector.begin(), vector.end()) {}
+
+    /// Constructs the map from another \ref RangeMap.
+    template <typename V1>
+    RangeMap(const RangeMap<V1> &c)
+      : _vector(c._vector.begin(), c._vector.end()) {}
+
+    /// Returns the size of the map.
+    int size() {
+      return _vector.size();
+    }
+
+    /// Resizes the map.
+
+    /// Resizes the underlying \c std::vector container, so changes the
+    /// keyset of the map.
+    /// \param size The new size of the map. The new keyset will be the
+    /// range <tt>[0..size-1]</tt>.
+    /// \param value The default value to assign to the new keys.
+    void resize(int size, const Value &value = Value()) {
+      _vector.resize(size, value);
+    }
+
   private:
-    
-    typedef std::map<K, T, Compare> Map;
+
+    RangeMap& operator=(const RangeMap&);
+
+  public:
+
+    ///\e
+    Reference operator[](const Key &k) {
+      return _vector[k];
+    }
+
+    ///\e
+    ConstReference operator[](const Key &k) const {
+      return _vector[k];
+    }
+
+    ///\e
+    void set(const Key &k, const Value &v) {
+      _vector[k] = v;
+    }
+  };
+
+  /// Returns a \ref RangeMap class
+
+  /// This function just returns a \ref RangeMap class.
+  /// \relates RangeMap
+  template<typename V>
+  inline RangeMap<V> rangeMap(int size = 0, const V &value = V()) {
+    return RangeMap<V>(size, value);
+  }
+
+  /// \brief Returns a \ref RangeMap class created from an appropriate
+  /// \c std::vector
+
+  /// This function just returns a \ref RangeMap class created from an
+  /// appropriate \c std::vector.
+  /// \relates RangeMap
+  template<typename V>
+  inline RangeMap<V> rangeMap(const std::vector<V> &vector) {
+    return RangeMap<V>(vector);
+  }
+
+
+  /// Map type based on \c std::map
+
+  /// This map is essentially a wrapper for \c std::map with addition
+  /// that you can specify a default value for the keys that are not
+  /// stored actually. This value can be different from the default
+  /// contructed value (i.e. \c %Value()).
+  /// This type conforms the \ref concepts::ReferenceMap "ReferenceMap"
+  /// concept.
+  ///
+  /// This map is useful if a default value should be assigned to most of
+  /// the keys and different values should be assigned only to a few
+  /// keys (i.e. the map is "sparse").
+  /// The name of this type also refers to this important usage.
+  ///
+  /// Apart form that this map can be used in many other cases since it
+  /// is based on \c std::map, which is a general associative container.
+  /// However keep in mind that it is usually not as efficient as other
+  /// maps.
+  ///
+  /// The simplest way of using this map is through the sparseMap()
+  /// function.
+  template <typename K, typename V, typename Compare = std::less<K> >
+  class SparseMap : public MapBase<K, V> {
+    template <typename K1, typename V1, typename C1>
+    friend class SparseMap;
+  public:
+
+    typedef MapBase<K, V> Parent;
+    /// Key type
+    typedef typename Parent::Key Key;
+    /// Value type
+    typedef typename Parent::Value Value;
+    /// Reference type
+    typedef Value& Reference;
+    /// Const reference type
+    typedef const Value& ConstReference;
+
+    typedef True ReferenceMapTag;
+
+  private:
+
+    typedef std::map<K, V, Compare> Map;
+    Map _map;
     Value _value;
-    Map _map;
-
-  public:
-
-    /// Constructor with specified default value
-    StdMap(const T& value = T()) : _value(value) {}
-    /// \brief Constructs the map from an appropriate \c std::map, and 
+
+  public:
+
+    /// \brief Constructor with specified default value.
+    SparseMap(const Value &value = Value()) : _value(value) {}
+    /// \brief Constructs the map from an appropriate \c std::map, and
     /// explicitly specifies a default value.
-    template <typename T1, typename Comp1>
-    StdMap(const std::map<Key, T1, Comp1> &map, const T& value = T()) 
+    template <typename V1, typename Comp1>
+    SparseMap(const std::map<Key, V1, Comp1> &map,
+              const Value &value = Value())
       : _map(map.begin(), map.end()), _value(value) {}
-    
-    /// \brief Constructs a map from an other \ref StdMap.
-    template<typename T1, typename Comp1>
-    StdMap(const StdMap<Key, T1, Comp1> &c) 
+
+    /// \brief Constructs the map from another \ref SparseMap.
+    template<typename V1, typename Comp1>
+    SparseMap(const SparseMap<Key, V1, Comp1> &c)
       : _map(c._map.begin(), c._map.end()), _value(c._value) {}
 
   private:
 
-    StdMap& operator=(const StdMap&);
+    SparseMap& operator=(const SparseMap&);
 
   public:
@@ -220,5 +405,5 @@
     }
 
-    /// \e 
+    ///\e
     ConstReference operator[](const Key &k) const {
       typename Map::const_iterator it = _map.find(k);
@@ -229,147 +414,46 @@
     }
 
-    /// \e 
-    void set(const Key &k, const T &t) {
+    ///\e
+    void set(const Key &k, const Value &v) {
       typename Map::iterator it = _map.lower_bound(k);
       if (it != _map.end() && !_map.key_comp()(k, it->first))
-	it->second = t;
+	it->second = v;
       else
-	_map.insert(it, std::make_pair(k, t));
+	_map.insert(it, std::make_pair(k, v));
     }
 
-    /// \e
-    void setAll(const T &t) {
-      _value = t;
+    ///\e
+    void setAll(const Value &v) {
+      _value = v;
       _map.clear();
-    }    
-
-  };
-  
-  ///Returns a \c StdMap class
-
-  ///This function just returns a \c StdMap class with specified 
-  ///default value.
-  ///\relates StdMap
-  template<typename K, typename V, typename Compare> 
-  inline StdMap<K, V, Compare> stdMap(const V& value = V()) {
-    return StdMap<K, V, Compare>(value);
-  }
-  
-  ///Returns a \c StdMap class
-
-  ///This function just returns a \c StdMap class with specified 
-  ///default value.
-  ///\relates StdMap
-  template<typename K, typename V> 
-  inline StdMap<K, V, std::less<K> > stdMap(const V& value = V()) {
-    return StdMap<K, V, std::less<K> >(value);
-  }
-  
-  ///Returns a \c StdMap class created from an appropriate std::map
-
-  ///This function just returns a \c StdMap class created from an 
-  ///appropriate std::map.
-  ///\relates StdMap
-  template<typename K, typename V, typename Compare> 
-  inline StdMap<K, V, Compare> stdMap( const std::map<K, V, Compare> &map, 
-                                       const V& value = V() ) {
-    return StdMap<K, V, Compare>(map, value);
-  }
-
-  ///Returns a \c StdMap class created from an appropriate std::map
-
-  ///This function just returns a \c StdMap class created from an 
-  ///appropriate std::map.
-  ///\relates StdMap
-  template<typename K, typename V> 
-  inline StdMap<K, V, std::less<K> > stdMap( const std::map<K, V, std::less<K> > &map, 
-                                             const V& value = V() ) {
-    return StdMap<K, V, std::less<K> >(map, value);
-  }
-
-  /// \brief Map for storing values for keys from the range <tt>[0..size-1]</tt>
-  ///
-  /// This map has the <tt>[0..size-1]</tt> keyset and the values
-  /// are stored in a \c std::vector<T>  container. It can be used with
-  /// some data structures, for example \c UnionFind, \c BinHeap, when 
-  /// the used items are small integer numbers.
-  /// This map meets the \ref concepts::ReferenceMap "ReferenceMap" concept.
-  ///
-  /// \todo Revise its name
-  template <typename T>
-  class IntegerMap : public MapBase<int, T> {
-
-    template <typename T1>
-    friend class IntegerMap;
-
-  public:
-
-    typedef MapBase<int, T> Parent;
-    ///\e
-    typedef typename Parent::Key Key;
-    ///\e
-    typedef typename Parent::Value Value;
-    ///\e
-    typedef T& Reference;
-    ///\e
-    typedef const T& ConstReference;
-
-    typedef True ReferenceMapTag;
-
-  private:
-    
-    typedef std::vector<T> Vector;
-    Vector _vector;
-
-  public:
-
-    /// Constructor with specified default value
-    IntegerMap(int size = 0, const T& value = T()) : _vector(size, value) {}
-
-    /// \brief Constructs the map from an appropriate \c std::vector.
-    template <typename T1>
-    IntegerMap(const std::vector<T1>& vector) 
-      : _vector(vector.begin(), vector.end()) {}
-    
-    /// \brief Constructs a map from an other \ref IntegerMap.
-    template <typename T1>
-    IntegerMap(const IntegerMap<T1> &c) 
-      : _vector(c._vector.begin(), c._vector.end()) {}
-
-    /// \brief Resize the container
-    void resize(int size, const T& value = T()) {
-      _vector.resize(size, value);
     }
-
-  private:
-
-    IntegerMap& operator=(const IntegerMap&);
-
-  public:
-
-    ///\e
-    Reference operator[](Key k) {
-      return _vector[k];
-    }
-
-    /// \e 
-    ConstReference operator[](Key k) const {
-      return _vector[k];
-    }
-
-    /// \e 
-    void set(const Key &k, const T& t) {
-      _vector[k] = t;
-    }
-
-  };
-  
-  ///Returns an \c IntegerMap class
-
-  ///This function just returns an \c IntegerMap class.
-  ///\relates IntegerMap
-  template<typename T>
-  inline IntegerMap<T> integerMap(int size = 0, const T& value = T()) {
-    return IntegerMap<T>(size, value);
+  };
+
+  /// Returns a \ref SparseMap class
+
+  /// This function just returns a \ref SparseMap class with specified
+  /// default value.
+  /// \relates SparseMap
+  template<typename K, typename V, typename Compare>
+  inline SparseMap<K, V, Compare> sparseMap(const V& value = V()) {
+    return SparseMap<K, V, Compare>(value);
+  }
+
+  template<typename K, typename V>
+  inline SparseMap<K, V, std::less<K> > sparseMap(const V& value = V()) {
+    return SparseMap<K, V, std::less<K> >(value);
+  }
+
+  /// \brief Returns a \ref SparseMap class created from an appropriate
+  /// \c std::map
+
+  /// This function just returns a \ref SparseMap class created from an
+  /// appropriate \c std::map.
+  /// \relates SparseMap
+  template<typename K, typename V, typename Compare>
+  inline SparseMap<K, V, Compare>
+    sparseMap(const std::map<K, V, Compare> &map, const V& value = V())
+  {
+    return SparseMap<K, V, Compare>(map, value);
   }
 
@@ -379,78 +463,210 @@
   /// @{
 
-  /// \brief Identity map.
-  ///
-  /// This map gives back the given key as value without any
-  /// modification. 
-  template <typename T>
-  class IdentityMap : public MapBase<T, T> {
-  public:
-    typedef MapBase<T, T> Parent;
-    typedef typename Parent::Key Key;
-    typedef typename Parent::Value Value;
-
-    /// \e
-    const T& operator[](const T& t) const {
-      return t;
-    }
-  };
-
-  ///Returns an \c IdentityMap class
-
-  ///This function just returns an \c IdentityMap class.
-  ///\relates IdentityMap
-  template<typename T>
-  inline IdentityMap<T> identityMap() {
-    return IdentityMap<T>();
-  }
-  
-
-  ///\brief Convert the \c Value of a map to another type using
-  ///the default conversion.
-  ///
-  ///This \ref concepts::ReadMap "read only map"
-  ///converts the \c Value of a map to type \c T.
-  ///Its \c Key is inherited from \c M.
-  template <typename M, typename T> 
-  class ConvertMap : public MapBase<typename M::Key, T> {
-    const M& m;
-  public:
-    typedef MapBase<typename M::Key, T> Parent;
-    typedef typename Parent::Key Key;
-    typedef typename Parent::Value Value;
-
-    ///Constructor
-
-    ///Constructor.
-    ///\param _m is the underlying map.
-    ConvertMap(const M &_m) : m(_m) {};
-
-    ///\e
-    Value operator[](const Key& k) const {return m[k];}
-  };
-  
-  ///Returns a \c ConvertMap class
-
-  ///This function just returns a \c ConvertMap class.
-  ///\relates ConvertMap
-  template<typename T, typename M>
-  inline ConvertMap<M, T> convertMap(const M &m) {
-    return ConvertMap<M, T>(m);
-  }
-
-  ///Simple wrapping of a map
-
-  ///This \ref concepts::ReadMap "read only map" returns the simple
-  ///wrapping of the given map. Sometimes the reference maps cannot be
-  ///combined with simple read maps. This map adaptor wraps the given
-  ///map to simple read map.
-  ///
-  ///\sa SimpleWriteMap
-  ///
-  /// \todo Revise the misleading name 
-  template<typename M> 
-  class SimpleMap : public MapBase<typename M::Key, typename M::Value> {
-    const M& m;
-
+  /// Composition of two maps
+
+  /// This \ref concepts::ReadMap "read-only map" returns the
+  /// composition of two given maps. That is to say, if \c m1 is of
+  /// type \c M1 and \c m2 is of \c M2, then for
+  /// \code
+  ///   ComposeMap<M1, M2> cm(m1,m2);
+  /// \endcode
+  /// <tt>cm[x]</tt> will be equal to <tt>m1[m2[x]]</tt>.
+  ///
+  /// The \c Key type of the map is inherited from \c M2 and the
+  /// \c Value type is from \c M1.
+  /// \c M2::Value must be convertible to \c M1::Key.
+  ///
+  /// The simplest way of using this map is through the composeMap()
+  /// function.
+  ///
+  /// \sa CombineMap
+  ///
+  /// \todo Check the requirements.
+  template <typename M1, typename M2>
+  class ComposeMap : public MapBase<typename M2::Key, typename M1::Value> {
+    const M1 &_m1;
+    const M2 &_m2;
+  public:
+    typedef MapBase<typename M2::Key, typename M1::Value> Parent;
+    typedef typename Parent::Key Key;
+    typedef typename Parent::Value Value;
+
+    /// Constructor
+    ComposeMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {}
+
+    /// \e
+    typename MapTraits<M1>::ConstReturnValue
+    operator[](const Key &k) const { return _m1[_m2[k]]; }
+  };
+
+  /// Returns a \ref ComposeMap class
+
+  /// This function just returns a \ref ComposeMap class.
+  ///
+  /// If \c m1 and \c m2 are maps and the \c Value type of \c m2 is
+  /// convertible to the \c Key of \c m1, then <tt>composeMap(m1,m2)[x]</tt>
+  /// will be equal to <tt>m1[m2[x]]</tt>.
+  ///
+  /// \relates ComposeMap
+  template <typename M1, typename M2>
+  inline ComposeMap<M1, M2> composeMap(const M1 &m1, const M2 &m2) {
+    return ComposeMap<M1, M2>(m1, m2);
+  }
+
+
+  /// Combination of two maps using an STL (binary) functor.
+
+  /// This \ref concepts::ReadMap "read-only map" takes two maps and a
+  /// binary functor and returns the combination of the two given maps
+  /// using the functor.
+  /// That is to say, if \c m1 is of type \c M1 and \c m2 is of \c M2
+  /// and \c f is of \c F, then for
+  /// \code
+  ///   CombineMap<M1,M2,F,V> cm(m1,m2,f);
+  /// \endcode
+  /// <tt>cm[x]</tt> will be equal to <tt>f(m1[x],m2[x])</tt>.
+  ///
+  /// The \c Key type of the map is inherited from \c M1 (\c M1::Key
+  /// must be convertible to \c M2::Key) and the \c Value type is \c V.
+  /// \c M2::Value and \c M1::Value must be convertible to the
+  /// corresponding input parameter of \c F and the return type of \c F
+  /// must be convertible to \c V.
+  ///
+  /// The simplest way of using this map is through the combineMap()
+  /// function.
+  ///
+  /// \sa ComposeMap
+  ///
+  /// \todo Check the requirements.
+  template<typename M1, typename M2, typename F,
+	   typename V = typename F::result_type>
+  class CombineMap : public MapBase<typename M1::Key, V> {
+    const M1 &_m1;
+    const M2 &_m2;
+    F _f;
+  public:
+    typedef MapBase<typename M1::Key, V> Parent;
+    typedef typename Parent::Key Key;
+    typedef typename Parent::Value Value;
+
+    /// Constructor
+    CombineMap(const M1 &m1, const M2 &m2, const F &f = F())
+      : _m1(m1), _m2(m2), _f(f) {}
+    /// \e
+    Value operator[](const Key &k) const { return _f(_m1[k],_m2[k]); }
+  };
+
+  /// Returns a \ref CombineMap class
+
+  /// This function just returns a \ref CombineMap class.
+  ///
+  /// For example, if \c m1 and \c m2 are both maps with \c double
+  /// values, then
+  /// \code
+  ///   combineMap(m1,m2,std::plus<double>())
+  /// \endcode
+  /// is equivalent to
+  /// \code
+  ///   addMap(m1,m2)
+  /// \endcode
+  ///
+  /// This function is specialized for adaptable binary function
+  /// classes and C++ functions.
+  ///
+  /// \relates CombineMap
+  template<typename M1, typename M2, typename F, typename V>
+  inline CombineMap<M1, M2, F, V>
+  combineMap(const M1 &m1, const M2 &m2, const F &f) {
+    return CombineMap<M1, M2, F, V>(m1,m2,f);
+  }
+
+  template<typename M1, typename M2, typename F>
+  inline CombineMap<M1, M2, F, typename F::result_type>
+  combineMap(const M1 &m1, const M2 &m2, const F &f) {
+    return combineMap<M1, M2, F, typename F::result_type>(m1,m2,f);
+  }
+
+  template<typename M1, typename M2, typename K1, typename K2, typename V>
+  inline CombineMap<M1, M2, V (*)(K1, K2), V>
+  combineMap(const M1 &m1, const M2 &m2, V (*f)(K1, K2)) {
+    return combineMap<M1, M2, V (*)(K1, K2), V>(m1,m2,f);
+  }
+
+
+  /// Converts an STL style (unary) functor to a map
+
+  /// This \ref concepts::ReadMap "read-only map" returns the value
+  /// of a given functor. Actually, it just wraps the functor and
+  /// provides the \c Key and \c Value typedefs.
+  ///
+  /// Template parameters \c K and \c V will become its \c Key and
+  /// \c Value. In most cases they have to be given explicitly because
+  /// a functor typically does not provide \c argument_type and
+  /// \c result_type typedefs.
+  /// Parameter \c F is the type of the used functor.
+  ///
+  /// The simplest way of using this map is through the functorToMap()
+  /// function.
+  ///
+  /// \sa MapToFunctor
+  template<typename F,
+	   typename K = typename F::argument_type,
+	   typename V = typename F::result_type>
+  class FunctorToMap : public MapBase<K, V> {
+    const F &_f;
+  public:
+    typedef MapBase<K, V> Parent;
+    typedef typename Parent::Key Key;
+    typedef typename Parent::Value Value;
+
+    /// Constructor
+    FunctorToMap(const F &f = F()) : _f(f) {}
+    /// \e
+    Value operator[](const Key &k) const { return _f(k); }
+  };
+
+  /// Returns a \ref FunctorToMap class
+
+  /// This function just returns a \ref FunctorToMap class.
+  ///
+  /// This function is specialized for adaptable binary function
+  /// classes and C++ functions.
+  ///
+  /// \relates FunctorToMap
+  template<typename K, typename V, typename F>
+  inline FunctorToMap<F, K, V> functorToMap(const F &f) {
+    return FunctorToMap<F, K, V>(f);
+  }
+
+  template <typename F>
+  inline FunctorToMap<F, typename F::argument_type, typename F::result_type>
+    functorToMap(const F &f)
+  {
+    return FunctorToMap<F, typename F::argument_type,
+      typename F::result_type>(f);
+  }
+
+  template <typename K, typename V>
+  inline FunctorToMap<V (*)(K), K, V> functorToMap(V (*f)(K)) {
+    return FunctorToMap<V (*)(K), K, V>(f);
+  }
+
+
+  /// Converts a map to an STL style (unary) functor
+
+  /// This class converts a map to an STL style (unary) functor.
+  /// That is it provides an <tt>operator()</tt> to read its values.
+  ///
+  /// For the sake of convenience it also works as a usual
+  /// \ref concepts::ReadMap "readable map", i.e. <tt>operator[]</tt>
+  /// and the \c Key and \c Value typedefs also exist.
+  ///
+  /// The simplest way of using this map is through the mapToFunctor()
+  /// function.
+  ///
+  ///\sa FunctorToMap
+  template <typename M>
+  class MapToFunctor : public MapBase<typename M::Key, typename M::Value> {
+    const M &_m;
   public:
     typedef MapBase<typename M::Key, typename M::Value> Parent;
@@ -458,66 +674,127 @@
     typedef typename Parent::Value Value;
 
-    ///Constructor
-    SimpleMap(const M &_m) : m(_m) {};
-    ///\e
-    Value operator[](Key k) const {return m[k];}
-  };
-  
-  ///Returns a \c SimpleMap class
-
-  ///This function just returns a \c SimpleMap class.
-  ///\relates SimpleMap
+    typedef typename Parent::Key argument_type;
+    typedef typename Parent::Value result_type;
+
+    /// Constructor
+    MapToFunctor(const M &m) : _m(m) {}
+    /// \e
+    Value operator()(const Key &k) const { return _m[k]; }
+    /// \e
+    Value operator[](const Key &k) const { return _m[k]; }
+  };
+
+  /// Returns a \ref MapToFunctor class
+
+  /// This function just returns a \ref MapToFunctor class.
+  /// \relates MapToFunctor
   template<typename M>
-  inline SimpleMap<M> simpleMap(const M &m) {
-    return SimpleMap<M>(m);
-  }
-
-  ///Simple writable wrapping of a map
-
-  ///This \ref concepts::ReadWriteMap "read-write map" returns the simple
-  ///wrapping of the given map. Sometimes the reference maps cannot be
-  ///combined with simple read-write maps. This map adaptor wraps the
-  ///given map to simple read-write map.
-  ///
-  ///\sa SimpleMap
-  ///
-  /// \todo Revise the misleading name
-  template<typename M> 
-  class SimpleWriteMap : public MapBase<typename M::Key, typename M::Value> {
-    M& m;
-
-  public:
-    typedef MapBase<typename M::Key, typename M::Value> Parent;
-    typedef typename Parent::Key Key;
-    typedef typename Parent::Value Value;
-
-    ///Constructor
-    SimpleWriteMap(M &_m) : m(_m) {};
-    ///\e
-    Value operator[](Key k) const {return m[k];}
-    ///\e
-    void set(Key k, const Value& c) { m.set(k, c); }
-  };
-
-  ///Returns a \c SimpleWriteMap class
-
-  ///This function just returns a \c SimpleWriteMap class.
-  ///\relates SimpleWriteMap
-  template<typename M>
-  inline SimpleWriteMap<M> simpleWriteMap(M &m) {
-    return SimpleWriteMap<M>(m);
-  }
-
-  ///Sum of two maps
-
-  ///This \ref concepts::ReadMap "read only map" returns the sum of the two
-  ///given maps.
-  ///Its \c Key and \c Value are inherited from \c M1.
-  ///The \c Key and \c Value of \c M2 must be convertible to those of \c M1.
-  template<typename M1, typename M2> 
+  inline MapToFunctor<M> mapToFunctor(const M &m) {
+    return MapToFunctor<M>(m);
+  }
+
+
+  /// \brief Map adaptor to convert the \c Value type of a map to
+  /// another type using the default conversion.
+
+  /// Map adaptor to convert the \c Value type of a \ref concepts::ReadMap
+  /// "readable map" to another type using the default conversion.
+  /// The \c Key type of it is inherited from \c M and the \c Value
+  /// type is \c V.
+  /// This type conforms the \ref concepts::ReadMap "ReadMap" concept.
+  ///
+  /// The simplest way of using this map is through the convertMap()
+  /// function.
+  template <typename M, typename V>
+  class ConvertMap : public MapBase<typename M::Key, V> {
+    const M &_m;
+  public:
+    typedef MapBase<typename M::Key, V> Parent;
+    typedef typename Parent::Key Key;
+    typedef typename Parent::Value Value;
+
+    /// Constructor
+
+    /// Constructor.
+    /// \param m The underlying map.
+    ConvertMap(const M &m) : _m(m) {}
+
+    /// \e
+    Value operator[](const Key &k) const { return _m[k]; }
+  };
+
+  /// Returns a \ref ConvertMap class
+
+  /// This function just returns a \ref ConvertMap class.
+  /// \relates ConvertMap
+  template<typename V, typename M>
+  inline ConvertMap<M, V> convertMap(const M &map) {
+    return ConvertMap<M, V>(map);
+  }
+
+
+  /// Applies all map setting operations to two maps
+
+  /// This map has two \ref concepts::WriteMap "writable map" parameters
+  /// and each write request will be passed to both of them.
+  /// If \c M1 is also \ref concepts::ReadMap "readable", then the read
+  /// operations will return the corresponding values of \c M1.
+  ///
+  /// The \c Key and \c Value types are inherited from \c M1.
+  /// The \c Key and \c Value of \c M2 must be convertible from those
+  /// of \c M1.
+  ///
+  /// The simplest way of using this map is through the forkMap()
+  /// function.
+  template<typename  M1, typename M2>
+  class ForkMap : public MapBase<typename M1::Key, typename M1::Value> {
+    M1 &_m1;
+    M2 &_m2;
+  public:
+    typedef MapBase<typename M1::Key, typename M1::Value> Parent;
+    typedef typename Parent::Key Key;
+    typedef typename Parent::Value Value;
+
+    /// Constructor
+    ForkMap(M1 &m1, M2 &m2) : _m1(m1), _m2(m2) {}
+    /// Returns the value associated with the given key in the first map.
+    Value operator[](const Key &k) const { return _m1[k]; }
+    /// Sets the value associated with the given key in both maps.
+    void set(const Key &k, const Value &v) { _m1.set(k,v); _m2.set(k,v); }
+  };
+
+  /// Returns a \ref ForkMap class
+
+  /// This function just returns a \ref ForkMap class.
+  /// \relates ForkMap
+  template <typename M1, typename M2>
+  inline ForkMap<M1,M2> forkMap(M1 &m1, M2 &m2) {
+    return ForkMap<M1,M2>(m1,m2);
+  }
+
+
+  /// Sum of two maps
+
+  /// This \ref concepts::ReadMap "read-only map" returns the sum
+  /// of the values of the two given maps.
+  /// Its \c Key and \c Value types are inherited from \c M1.
+  /// The \c Key and \c Value of \c M2 must be convertible to those of
+  /// \c M1.
+  ///
+  /// If \c m1 is of type \c M1 and \c m2 is of \c M2, then for
+  /// \code
+  ///   AddMap<M1,M2> am(m1,m2);
+  /// \endcode
+  /// <tt>am[x]</tt> will be equal to <tt>m1[x]+m2[x]</tt>.
+  ///
+  /// The simplest way of using this map is through the addMap()
+  /// function.
+  ///
+  /// \sa SubMap, MulMap, DivMap
+  /// \sa ShiftMap, ShiftWriteMap
+  template<typename M1, typename M2>
   class AddMap : public MapBase<typename M1::Key, typename M1::Value> {
-    const M1& m1;
-    const M2& m2;
-
+    const M1 &_m1;
+    const M2 &_m2;
   public:
     typedef MapBase<typename M1::Key, typename M1::Value> Parent;
@@ -525,115 +802,47 @@
     typedef typename Parent::Value Value;
 
-    ///Constructor
-    AddMap(const M1 &_m1,const M2 &_m2) : m1(_m1), m2(_m2) {};
-    ///\e
-    Value operator[](Key k) const {return m1[k]+m2[k];}
-  };
-  
-  ///Returns an \c AddMap class
-
-  ///This function just returns an \c AddMap class.
-  ///\todo Extend the documentation: how to call these type of functions?
-  ///
-  ///\relates AddMap
-  template<typename M1, typename M2> 
-  inline AddMap<M1, M2> addMap(const M1 &m1,const M2 &m2) {
+    /// Constructor
+    AddMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {}
+    /// \e
+    Value operator[](const Key &k) const { return _m1[k]+_m2[k]; }
+  };
+
+  /// Returns an \ref AddMap class
+
+  /// This function just returns an \ref AddMap class.
+  ///
+  /// For example, if \c m1 and \c m2 are both maps with \c double
+  /// values, then <tt>addMap(m1,m2)[x]</tt> will be equal to
+  /// <tt>m1[x]+m2[x]</tt>.
+  ///
+  /// \relates AddMap
+  template<typename M1, typename M2>
+  inline AddMap<M1, M2> addMap(const M1 &m1, const M2 &m2) {
     return AddMap<M1, M2>(m1,m2);
   }
 
-  ///Shift a map with a constant.
-
-  ///This \ref concepts::ReadMap "read only map" returns the sum of the
-  ///given map and a constant value.
-  ///Its \c Key and \c Value are inherited from \c M.
-  ///
-  ///Actually,
-  ///\code
-  ///  ShiftMap<X> sh(x,v);
-  ///\endcode
-  ///is equivalent to
-  ///\code
-  ///  ConstMap<X::Key, X::Value> c_tmp(v);
-  ///  AddMap<X, ConstMap<X::Key, X::Value> > sh(x,v);
-  ///\endcode
-  ///
-  ///\sa ShiftWriteMap
-  template<typename M, typename C = typename M::Value> 
-  class ShiftMap : public MapBase<typename M::Key, typename M::Value> {
-    const M& m;
-    C v;
-  public:
-    typedef MapBase<typename M::Key, typename M::Value> Parent;
-    typedef typename Parent::Key Key;
-    typedef typename Parent::Value Value;
-
-    ///Constructor
-
-    ///Constructor.
-    ///\param _m is the undelying map.
-    ///\param _v is the shift value.
-    ShiftMap(const M &_m, const C &_v ) : m(_m), v(_v) {};
-    ///\e
-    Value operator[](Key k) const {return m[k] + v;}
-  };
-
-  ///Shift a map with a constant (ReadWrite version).
-
-  ///This \ref concepts::ReadWriteMap "read-write map" returns the sum of the
-  ///given map and a constant value. It makes also possible to write the map.
-  ///Its \c Key and \c Value are inherited from \c M.
-  ///
-  ///\sa ShiftMap
-  template<typename M, typename C = typename M::Value> 
-  class ShiftWriteMap : public MapBase<typename M::Key, typename M::Value> {
-    M& m;
-    C v;
-  public:
-    typedef MapBase<typename M::Key, typename M::Value> Parent;
-    typedef typename Parent::Key Key;
-    typedef typename Parent::Value Value;
-
-    ///Constructor
-
-    ///Constructor.
-    ///\param _m is the undelying map.
-    ///\param _v is the shift value.
-    ShiftWriteMap(M &_m, const C &_v ) : m(_m), v(_v) {};
-    /// \e
-    Value operator[](Key k) const {return m[k] + v;}
-    /// \e
-    void set(Key k, const Value& c) { m.set(k, c - v); }
-  };
-  
-  ///Returns a \c ShiftMap class
-
-  ///This function just returns a \c ShiftMap class.
-  ///\relates ShiftMap
-  template<typename M, typename C> 
-  inline ShiftMap<M, C> shiftMap(const M &m,const C &v) {
-    return ShiftMap<M, C>(m,v);
-  }
-
-  ///Returns a \c ShiftWriteMap class
-
-  ///This function just returns a \c ShiftWriteMap class.
-  ///\relates ShiftWriteMap
-  template<typename M, typename C> 
-  inline ShiftWriteMap<M, C> shiftMap(M &m,const C &v) {
-    return ShiftWriteMap<M, C>(m,v);
-  }
-
-  ///Difference of two maps
-
-  ///This \ref concepts::ReadMap "read only map" returns the difference
-  ///of the values of the two given maps.
-  ///Its \c Key and \c Value are inherited from \c M1.
-  ///The \c Key and \c Value of \c M2 must be convertible to those of \c M1.
-  ///
-  /// \todo Revise the misleading name
-  template<typename M1, typename M2> 
+
+  /// Difference of two maps
+
+  /// This \ref concepts::ReadMap "read-only map" returns the difference
+  /// of the values of the two given maps.
+  /// Its \c Key and \c Value types are inherited from \c M1.
+  /// The \c Key and \c Value of \c M2 must be convertible to those of
+  /// \c M1.
+  ///
+  /// If \c m1 is of type \c M1 and \c m2 is of \c M2, then for
+  /// \code
+  ///   SubMap<M1,M2> sm(m1,m2);
+  /// \endcode
+  /// <tt>sm[x]</tt> will be equal to <tt>m1[x]-m2[x]</tt>.
+  ///
+  /// The simplest way of using this map is through the subMap()
+  /// function.
+  ///
+  /// \sa AddMap, MulMap, DivMap
+  template<typename M1, typename M2>
   class SubMap : public MapBase<typename M1::Key, typename M1::Value> {
-    const M1& m1;
-    const M2& m2;
+    const M1 &_m1;
+    const M2 &_m2;
   public:
     typedef MapBase<typename M1::Key, typename M1::Value> Parent;
@@ -641,30 +850,48 @@
     typedef typename Parent::Value Value;
 
-    ///Constructor
-    SubMap(const M1 &_m1,const M2 &_m2) : m1(_m1), m2(_m2) {};
-    /// \e
-    Value operator[](Key k) const {return m1[k]-m2[k];}
-  };
-  
-  ///Returns a \c SubMap class
-
-  ///This function just returns a \c SubMap class.
-  ///
-  ///\relates SubMap
-  template<typename M1, typename M2> 
+    /// Constructor
+    SubMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {}
+    /// \e
+    Value operator[](const Key &k) const { return _m1[k]-_m2[k]; }
+  };
+
+  /// Returns a \ref SubMap class
+
+  /// This function just returns a \ref SubMap class.
+  ///
+  /// For example, if \c m1 and \c m2 are both maps with \c double
+  /// values, then <tt>subMap(m1,m2)[x]</tt> will be equal to
+  /// <tt>m1[x]-m2[x]</tt>.
+  ///
+  /// \relates SubMap
+  template<typename M1, typename M2>
   inline SubMap<M1, M2> subMap(const M1 &m1, const M2 &m2) {
-    return SubMap<M1, M2>(m1, m2);
-  }
-
-  ///Product of two maps
-
-  ///This \ref concepts::ReadMap "read only map" returns the product of the
-  ///values of the two given maps.
-  ///Its \c Key and \c Value are inherited from \c M1.
-  ///The \c Key and \c Value of \c M2 must be convertible to those of \c M1.
-  template<typename M1, typename M2> 
+    return SubMap<M1, M2>(m1,m2);
+  }
+
+
+  /// Product of two maps
+
+  /// This \ref concepts::ReadMap "read-only map" returns the product
+  /// of the values of the two given maps.
+  /// Its \c Key and \c Value types are inherited from \c M1.
+  /// The \c Key and \c Value of \c M2 must be convertible to those of
+  /// \c M1.
+  ///
+  /// If \c m1 is of type \c M1 and \c m2 is of \c M2, then for
+  /// \code
+  ///   MulMap<M1,M2> mm(m1,m2);
+  /// \endcode
+  /// <tt>mm[x]</tt> will be equal to <tt>m1[x]*m2[x]</tt>.
+  ///
+  /// The simplest way of using this map is through the mulMap()
+  /// function.
+  ///
+  /// \sa AddMap, SubMap, DivMap
+  /// \sa ScaleMap, ScaleWriteMap
+  template<typename M1, typename M2>
   class MulMap : public MapBase<typename M1::Key, typename M1::Value> {
-    const M1& m1;
-    const M2& m2;
+    const M1 &_m1;
+    const M2 &_m2;
   public:
     typedef MapBase<typename M1::Key, typename M1::Value> Parent;
@@ -672,113 +899,47 @@
     typedef typename Parent::Value Value;
 
-    ///Constructor
-    MulMap(const M1 &_m1,const M2 &_m2) : m1(_m1), m2(_m2) {};
-    /// \e
-    Value operator[](Key k) const {return m1[k]*m2[k];}
-  };
-  
-  ///Returns a \c MulMap class
-
-  ///This function just returns a \c MulMap class.
-  ///\relates MulMap
-  template<typename M1, typename M2> 
+    /// Constructor
+    MulMap(const M1 &m1,const M2 &m2) : _m1(m1), _m2(m2) {}
+    /// \e
+    Value operator[](const Key &k) const { return _m1[k]*_m2[k]; }
+  };
+
+  /// Returns a \ref MulMap class
+
+  /// This function just returns a \ref MulMap class.
+  ///
+  /// For example, if \c m1 and \c m2 are both maps with \c double
+  /// values, then <tt>mulMap(m1,m2)[x]</tt> will be equal to
+  /// <tt>m1[x]*m2[x]</tt>.
+  ///
+  /// \relates MulMap
+  template<typename M1, typename M2>
   inline MulMap<M1, M2> mulMap(const M1 &m1,const M2 &m2) {
     return MulMap<M1, M2>(m1,m2);
   }
- 
-  ///Scales a map with a constant.
-
-  ///This \ref concepts::ReadMap "read only map" returns the value of the
-  ///given map multiplied from the left side with a constant value.
-  ///Its \c Key and \c Value are inherited from \c M.
-  ///
-  ///Actually,
-  ///\code
-  ///  ScaleMap<X> sc(x,v);
-  ///\endcode
-  ///is equivalent to
-  ///\code
-  ///  ConstMap<X::Key, X::Value> c_tmp(v);
-  ///  MulMap<X, ConstMap<X::Key, X::Value> > sc(x,v);
-  ///\endcode
-  ///
-  ///\sa ScaleWriteMap
-  template<typename M, typename C = typename M::Value> 
-  class ScaleMap : public MapBase<typename M::Key, typename M::Value> {
-    const M& m;
-    C v;
-  public:
-    typedef MapBase<typename M::Key, typename M::Value> Parent;
-    typedef typename Parent::Key Key;
-    typedef typename Parent::Value Value;
-
-    ///Constructor
-
-    ///Constructor.
-    ///\param _m is the undelying map.
-    ///\param _v is the scaling value.
-    ScaleMap(const M &_m, const C &_v ) : m(_m), v(_v) {};
-    /// \e
-    Value operator[](Key k) const {return v * m[k];}
-  };
-
-  ///Scales a map with a constant (ReadWrite version).
-
-  ///This \ref concepts::ReadWriteMap "read-write map" returns the value of the
-  ///given map multiplied from the left side with a constant value. It can
-  ///also be used as write map if the \c / operator is defined between
-  ///\c Value and \c C and the given multiplier is not zero.
-  ///Its \c Key and \c Value are inherited from \c M.
-  ///
-  ///\sa ScaleMap
-  template<typename M, typename C = typename M::Value> 
-  class ScaleWriteMap : public MapBase<typename M::Key, typename M::Value> {
-    M& m;
-    C v;
-  public:
-    typedef MapBase<typename M::Key, typename M::Value> Parent;
-    typedef typename Parent::Key Key;
-    typedef typename Parent::Value Value;
-
-    ///Constructor
-
-    ///Constructor.
-    ///\param _m is the undelying map.
-    ///\param _v is the scaling value.
-    ScaleWriteMap(M &_m, const C &_v ) : m(_m), v(_v) {};
-    /// \e
-    Value operator[](Key k) const {return v * m[k];}
-    /// \e
-    void set(Key k, const Value& c) { m.set(k, c / v);}
-  };
-  
-  ///Returns a \c ScaleMap class
-
-  ///This function just returns a \c ScaleMap class.
-  ///\relates ScaleMap
-  template<typename M, typename C> 
-  inline ScaleMap<M, C> scaleMap(const M &m,const C &v) {
-    return ScaleMap<M, C>(m,v);
-  }
-
-  ///Returns a \c ScaleWriteMap class
-
-  ///This function just returns a \c ScaleWriteMap class.
-  ///\relates ScaleWriteMap
-  template<typename M, typename C> 
-  inline ScaleWriteMap<M, C> scaleMap(M &m,const C &v) {
-    return ScaleWriteMap<M, C>(m,v);
-  }
-
-  ///Quotient of two maps
-
-  ///This \ref concepts::ReadMap "read only map" returns the quotient of the
-  ///values of the two given maps.
-  ///Its \c Key and \c Value are inherited from \c M1.
-  ///The \c Key and \c Value of \c M2 must be convertible to those of \c M1.
-  template<typename M1, typename M2> 
+
+
+  /// Quotient of two maps
+
+  /// This \ref concepts::ReadMap "read-only map" returns the quotient
+  /// of the values of the two given maps.
+  /// Its \c Key and \c Value types are inherited from \c M1.
+  /// The \c Key and \c Value of \c M2 must be convertible to those of
+  /// \c M1.
+  ///
+  /// If \c m1 is of type \c M1 and \c m2 is of \c M2, then for
+  /// \code
+  ///   DivMap<M1,M2> dm(m1,m2);
+  /// \endcode
+  /// <tt>dm[x]</tt> will be equal to <tt>m1[x]/m2[x]</tt>.
+  ///
+  /// The simplest way of using this map is through the divMap()
+  /// function.
+  ///
+  /// \sa AddMap, SubMap, MulMap
+  template<typename M1, typename M2>
   class DivMap : public MapBase<typename M1::Key, typename M1::Value> {
-    const M1& m1;
-    const M2& m2;
+    const M1 &_m1;
+    const M2 &_m2;
   public:
     typedef MapBase<typename M1::Key, typename M1::Value> Parent;
@@ -786,154 +947,250 @@
     typedef typename Parent::Value Value;
 
-    ///Constructor
-    DivMap(const M1 &_m1,const M2 &_m2) : m1(_m1), m2(_m2) {};
-    /// \e
-    Value operator[](Key k) const {return m1[k]/m2[k];}
-  };
-  
-  ///Returns a \c DivMap class
-
-  ///This function just returns a \c DivMap class.
-  ///\relates DivMap
-  template<typename M1, typename M2> 
+    /// Constructor
+    DivMap(const M1 &m1,const M2 &m2) : _m1(m1), _m2(m2) {}
+    /// \e
+    Value operator[](const Key &k) const { return _m1[k]/_m2[k]; }
+  };
+
+  /// Returns a \ref DivMap class
+
+  /// This function just returns a \ref DivMap class.
+  ///
+  /// For example, if \c m1 and \c m2 are both maps with \c double
+  /// values, then <tt>divMap(m1,m2)[x]</tt> will be equal to
+  /// <tt>m1[x]/m2[x]</tt>.
+  ///
+  /// \relates DivMap
+  template<typename M1, typename M2>
   inline DivMap<M1, M2> divMap(const M1 &m1,const M2 &m2) {
     return DivMap<M1, M2>(m1,m2);
   }
-  
-  ///Composition of two maps
-
-  ///This \ref concepts::ReadMap "read only map" returns the composition of
-  ///two given maps.
-  ///That is to say, if \c m1 is of type \c M1 and \c m2 is of \c M2,
-  ///then for
-  ///\code
-  ///  ComposeMap<M1, M2> cm(m1,m2);
-  ///\endcode
-  /// <tt>cm[x]</tt> will be equal to <tt>m1[m2[x]]</tt>.
-  ///
-  ///Its \c Key is inherited from \c M2 and its \c Value is from \c M1.
-  ///\c M2::Value must be convertible to \c M1::Key.
-  ///
-  ///\sa CombineMap
-  ///
-  ///\todo Check the requirements.
-  template <typename M1, typename M2> 
-  class ComposeMap : public MapBase<typename M2::Key, typename M1::Value> {
-    const M1& m1;
-    const M2& m2;
-  public:
-    typedef MapBase<typename M2::Key, typename M1::Value> Parent;
-    typedef typename Parent::Key Key;
-    typedef typename Parent::Value Value;
-
-    ///Constructor
-    ComposeMap(const M1 &_m1,const M2 &_m2) : m1(_m1), m2(_m2) {};
-    
-    /// \e
-
-
-    /// \todo Use the  MapTraits once it is ported.
-    ///
-
-    //typename MapTraits<M1>::ConstReturnValue
-    typename M1::Value
-    operator[](Key k) const {return m1[m2[k]];}
-  };
-
-  ///Returns a \c ComposeMap class
-
-  ///This function just returns a \c ComposeMap class.
-  ///\relates ComposeMap
-  template <typename M1, typename M2> 
-  inline ComposeMap<M1, M2> composeMap(const M1 &m1,const M2 &m2) {
-    return ComposeMap<M1, M2>(m1,m2);
-  }
-  
-  ///Combine of two maps using an STL (binary) functor.
-
-  ///Combine of two maps using an STL (binary) functor.
-  ///
-  ///This \ref concepts::ReadMap "read only map" takes two maps and a
-  ///binary functor and returns the composition of the two
-  ///given maps unsing the functor. 
-  ///That is to say, if \c m1 and \c m2 is of type \c M1 and \c M2
-  ///and \c f is of \c F, then for
-  ///\code
-  ///  CombineMap<M1,M2,F,V> cm(m1,m2,f);
-  ///\endcode
-  /// <tt>cm[x]</tt> will be equal to <tt>f(m1[x],m2[x])</tt>
-  ///
-  ///Its \c Key is inherited from \c M1 and its \c Value is \c V.
-  ///\c M2::Value and \c M1::Value must be convertible to the corresponding
-  ///input parameter of \c F and the return type of \c F must be convertible
-  ///to \c V.
-  ///
-  ///\sa ComposeMap
-  ///
-  ///\todo Check the requirements.
-  template<typename M1, typename M2, typename F,
-	   typename V = typename F::result_type> 
-  class CombineMap : public MapBase<typename M1::Key, V> {
-    const M1& m1;
-    const M2& m2;
-    F f;
-  public:
-    typedef MapBase<typename M1::Key, V> Parent;
-    typedef typename Parent::Key Key;
-    typedef typename Parent::Value Value;
-
-    ///Constructor
-    CombineMap(const M1 &_m1,const M2 &_m2,const F &_f = F())
-      : m1(_m1), m2(_m2), f(_f) {};
-    /// \e
-    Value operator[](Key k) const {return f(m1[k],m2[k]);}
-  };
-  
-  ///Returns a \c CombineMap class
-
-  ///This function just returns a \c CombineMap class.
-  ///
-  ///For example if \c m1 and \c m2 are both \c double valued maps, then 
-  ///\code
-  ///combineMap(m1,m2,std::plus<double>())
-  ///\endcode
-  ///is equivalent to
-  ///\code
-  ///addMap(m1,m2)
-  ///\endcode
-  ///
-  ///This function is specialized for adaptable binary function
-  ///classes and C++ functions.
-  ///
-  ///\relates CombineMap
-  template<typename M1, typename M2, typename F, typename V> 
-  inline CombineMap<M1, M2, F, V> 
-  combineMap(const M1& m1,const M2& m2, const F& f) {
-    return CombineMap<M1, M2, F, V>(m1,m2,f);
-  }
-
-  template<typename M1, typename M2, typename F> 
-  inline CombineMap<M1, M2, F, typename F::result_type> 
-  combineMap(const M1& m1, const M2& m2, const F& f) {
-    return combineMap<M1, M2, F, typename F::result_type>(m1,m2,f);
-  }
-
-  template<typename M1, typename M2, typename K1, typename K2, typename V> 
-  inline CombineMap<M1, M2, V (*)(K1, K2), V> 
-  combineMap(const M1 &m1, const M2 &m2, V (*f)(K1, K2)) {
-    return combineMap<M1, M2, V (*)(K1, K2), V>(m1,m2,f);
-  }
-
-  ///Negative value of a map
-
-  ///This \ref concepts::ReadMap "read only map" returns the negative
-  ///value of the value returned by the given map.
-  ///Its \c Key and \c Value are inherited from \c M.
-  ///The unary \c - operator must be defined for \c Value, of course.
-  ///
-  ///\sa NegWriteMap
-  template<typename M> 
+
+
+  /// Shifts a map with a constant.
+
+  /// This \ref concepts::ReadMap "read-only map" returns the sum of
+  /// the given map and a constant value (i.e. it shifts the map with
+  /// the constant). Its \c Key and \c Value are inherited from \c M.
+  ///
+  /// Actually,
+  /// \code
+  ///   ShiftMap<M> sh(m,v);
+  /// \endcode
+  /// is equivalent to
+  /// \code
+  ///   ConstMap<M::Key, M::Value> cm(v);
+  ///   AddMap<M, ConstMap<M::Key, M::Value> > sh(m,cm);
+  /// \endcode
+  ///
+  /// The simplest way of using this map is through the shiftMap()
+  /// function.
+  ///
+  /// \sa ShiftWriteMap
+  template<typename M, typename C = typename M::Value>
+  class ShiftMap : public MapBase<typename M::Key, typename M::Value> {
+    const M &_m;
+    C _v;
+  public:
+    typedef MapBase<typename M::Key, typename M::Value> Parent;
+    typedef typename Parent::Key Key;
+    typedef typename Parent::Value Value;
+
+    /// Constructor
+
+    /// Constructor.
+    /// \param m The undelying map.
+    /// \param v The constant value.
+    ShiftMap(const M &m, const C &v) : _m(m), _v(v) {}
+    /// \e
+    Value operator[](const Key &k) const { return _m[k]+_v; }
+  };
+
+  /// Shifts a map with a constant (read-write version).
+
+  /// This \ref concepts::ReadWriteMap "read-write map" returns the sum
+  /// of the given map and a constant value (i.e. it shifts the map with
+  /// the constant). Its \c Key and \c Value are inherited from \c M.
+  /// It makes also possible to write the map.
+  ///
+  /// The simplest way of using this map is through the shiftWriteMap()
+  /// function.
+  ///
+  /// \sa ShiftMap
+  template<typename M, typename C = typename M::Value>
+  class ShiftWriteMap : public MapBase<typename M::Key, typename M::Value> {
+    M &_m;
+    C _v;
+  public:
+    typedef MapBase<typename M::Key, typename M::Value> Parent;
+    typedef typename Parent::Key Key;
+    typedef typename Parent::Value Value;
+
+    /// Constructor
+
+    /// Constructor.
+    /// \param m The undelying map.
+    /// \param v The constant value.
+    ShiftWriteMap(M &m, const C &v) : _m(m), _v(v) {}
+    /// \e
+    Value operator[](const Key &k) const { return _m[k]+_v; }
+    /// \e
+    void set(const Key &k, const Value &v) { _m.set(k, v-_v); }
+  };
+
+  /// Returns a \ref ShiftMap class
+
+  /// This function just returns a \ref ShiftMap class.
+  ///
+  /// For example, if \c m is a map with \c double values and \c v is
+  /// \c double, then <tt>shiftMap(m,v)[x]</tt> will be equal to
+  /// <tt>m[x]+v</tt>.
+  ///
+  /// \relates ShiftMap
+  template<typename M, typename C>
+  inline ShiftMap<M, C> shiftMap(const M &m, const C &v) {
+    return ShiftMap<M, C>(m,v);
+  }
+
+  /// Returns a \ref ShiftWriteMap class
+
+  /// This function just returns a \ref ShiftWriteMap class.
+  ///
+  /// For example, if \c m is a map with \c double values and \c v is
+  /// \c double, then <tt>shiftWriteMap(m,v)[x]</tt> will be equal to
+  /// <tt>m[x]+v</tt>.
+  /// Moreover it makes also possible to write the map.
+  ///
+  /// \relates ShiftWriteMap
+  template<typename M, typename C>
+  inline ShiftWriteMap<M, C> shiftWriteMap(M &m, const C &v) {
+    return ShiftWriteMap<M, C>(m,v);
+  }
+
+
+  /// Scales a map with a constant.
+
+  /// This \ref concepts::ReadMap "read-only map" returns the value of
+  /// the given map multiplied from the left side with a constant value.
+  /// Its \c Key and \c Value are inherited from \c M.
+  ///
+  /// Actually,
+  /// \code
+  ///   ScaleMap<M> sc(m,v);
+  /// \endcode
+  /// is equivalent to
+  /// \code
+  ///   ConstMap<M::Key, M::Value> cm(v);
+  ///   MulMap<ConstMap<M::Key, M::Value>, M> sc(cm,m);
+  /// \endcode
+  ///
+  /// The simplest way of using this map is through the scaleMap()
+  /// function.
+  ///
+  /// \sa ScaleWriteMap
+  template<typename M, typename C = typename M::Value>
+  class ScaleMap : public MapBase<typename M::Key, typename M::Value> {
+    const M &_m;
+    C _v;
+  public:
+    typedef MapBase<typename M::Key, typename M::Value> Parent;
+    typedef typename Parent::Key Key;
+    typedef typename Parent::Value Value;
+
+    /// Constructor
+
+    /// Constructor.
+    /// \param m The undelying map.
+    /// \param v The constant value.
+    ScaleMap(const M &m, const C &v) : _m(m), _v(v) {}
+    /// \e
+    Value operator[](const Key &k) const { return _v*_m[k]; }
+  };
+
+  /// Scales a map with a constant (read-write version).
+
+  /// This \ref concepts::ReadWriteMap "read-write map" returns the value of
+  /// the given map multiplied from the left side with a constant value.
+  /// Its \c Key and \c Value are inherited from \c M.
+  /// It can also be used as write map if the \c / operator is defined
+  /// between \c Value and \c C and the given multiplier is not zero.
+  ///
+  /// The simplest way of using this map is through the scaleWriteMap()
+  /// function.
+  ///
+  /// \sa ScaleMap
+  template<typename M, typename C = typename M::Value>
+  class ScaleWriteMap : public MapBase<typename M::Key, typename M::Value> {
+    M &_m;
+    C _v;
+  public:
+    typedef MapBase<typename M::Key, typename M::Value> Parent;
+    typedef typename Parent::Key Key;
+    typedef typename Parent::Value Value;
+
+    /// Constructor
+
+    /// Constructor.
+    /// \param m The undelying map.
+    /// \param v The constant value.
+    ScaleWriteMap(M &m, const C &v) : _m(m), _v(v) {}
+    /// \e
+    Value operator[](const Key &k) const { return _v*_m[k]; }
+    /// \e
+    void set(const Key &k, const Value &v) { _m.set(k, v/_v); }
+  };
+
+  /// Returns a \ref ScaleMap class
+
+  /// This function just returns a \ref ScaleMap class.
+  ///
+  /// For example, if \c m is a map with \c double values and \c v is
+  /// \c double, then <tt>scaleMap(m,v)[x]</tt> will be equal to
+  /// <tt>v*m[x]</tt>.
+  ///
+  /// \relates ScaleMap
+  template<typename M, typename C>
+  inline ScaleMap<M, C> scaleMap(const M &m, const C &v) {
+    return ScaleMap<M, C>(m,v);
+  }
+
+  /// Returns a \ref ScaleWriteMap class
+
+  /// This function just returns a \ref ScaleWriteMap class.
+  ///
+  /// For example, if \c m is a map with \c double values and \c v is
+  /// \c double, then <tt>scaleWriteMap(m,v)[x]</tt> will be equal to
+  /// <tt>v*m[x]</tt>.
+  /// Moreover it makes also possible to write the map.
+  ///
+  /// \relates ScaleWriteMap
+  template<typename M, typename C>
+  inline ScaleWriteMap<M, C> scaleWriteMap(M &m, const C &v) {
+    return ScaleWriteMap<M, C>(m,v);
+  }
+
+
+  /// Negative of a map
+
+  /// This \ref concepts::ReadMap "read-only map" returns the negative
+  /// of the values of the given map (using the unary \c - operator).
+  /// Its \c Key and \c Value are inherited from \c M.
+  ///
+  /// If M::Value is \c int, \c double etc., then
+  /// \code
+  ///   NegMap<M> neg(m);
+  /// \endcode
+  /// is equivalent to
+  /// \code
+  ///   ScaleMap<M> neg(m,-1);
+  /// \endcode
+  ///
+  /// The simplest way of using this map is through the negMap()
+  /// function.
+  ///
+  /// \sa NegWriteMap
+  template<typename M>
   class NegMap : public MapBase<typename M::Key, typename M::Value> {
-    const M& m;
+    const M& _m;
   public:
     typedef MapBase<typename M::Key, typename M::Value> Parent;
@@ -941,21 +1198,34 @@
     typedef typename Parent::Value Value;
 
-    ///Constructor
-    NegMap(const M &_m) : m(_m) {};
-    /// \e
-    Value operator[](Key k) const {return -m[k];}
-  };
-  
-  ///Negative value of a map (ReadWrite version)
-
-  ///This \ref concepts::ReadWriteMap "read-write map" returns the negative
-  ///value of the value returned by the given map.
-  ///Its \c Key and \c Value are inherited from \c M.
-  ///The unary \c - operator must be defined for \c Value, of course.
+    /// Constructor
+    NegMap(const M &m) : _m(m) {}
+    /// \e
+    Value operator[](const Key &k) const { return -_m[k]; }
+  };
+
+  /// Negative of a map (read-write version)
+
+  /// This \ref concepts::ReadWriteMap "read-write map" returns the
+  /// negative of the values of the given map (using the unary \c -
+  /// operator).
+  /// Its \c Key and \c Value are inherited from \c M.
+  /// It makes also possible to write the map.
+  ///
+  /// If M::Value is \c int, \c double etc., then
+  /// \code
+  ///   NegWriteMap<M> neg(m);
+  /// \endcode
+  /// is equivalent to
+  /// \code
+  ///   ScaleWriteMap<M> neg(m,-1);
+  /// \endcode
+  ///
+  /// The simplest way of using this map is through the negWriteMap()
+  /// function.
   ///
   /// \sa NegMap
-  template<typename M> 
+  template<typename M>
   class NegWriteMap : public MapBase<typename M::Key, typename M::Value> {
-    M& m;
+    M &_m;
   public:
     typedef MapBase<typename M::Key, typename M::Value> Parent;
@@ -963,40 +1233,53 @@
     typedef typename Parent::Value Value;
 
-    ///Constructor
-    NegWriteMap(M &_m) : m(_m) {};
-    /// \e
-    Value operator[](Key k) const {return -m[k];}
-    /// \e
-    void set(Key k, const Value& v) { m.set(k, -v); }
-  };
-
-  ///Returns a \c NegMap class
-
-  ///This function just returns a \c NegMap class.
-  ///\relates NegMap
-  template <typename M> 
+    /// Constructor
+    NegWriteMap(M &m) : _m(m) {}
+    /// \e
+    Value operator[](const Key &k) const { return -_m[k]; }
+    /// \e
+    void set(const Key &k, const Value &v) { _m.set(k, -v); }
+  };
+
+  /// Returns a \ref NegMap class
+
+  /// This function just returns a \ref NegMap class.
+  ///
+  /// For example, if \c m is a map with \c double values, then
+  /// <tt>negMap(m)[x]</tt> will be equal to <tt>-m[x]</tt>.
+  ///
+  /// \relates NegMap
+  template <typename M>
   inline NegMap<M> negMap(const M &m) {
     return NegMap<M>(m);
   }
 
-  ///Returns a \c NegWriteMap class
-
-  ///This function just returns a \c NegWriteMap class.
-  ///\relates NegWriteMap
-  template <typename M> 
-  inline NegWriteMap<M> negMap(M &m) {
+  /// Returns a \ref NegWriteMap class
+
+  /// This function just returns a \ref NegWriteMap class.
+  ///
+  /// For example, if \c m is a map with \c double values, then
+  /// <tt>negWriteMap(m)[x]</tt> will be equal to <tt>-m[x]</tt>.
+  /// Moreover it makes also possible to write the map.
+  ///
+  /// \relates NegWriteMap
+  template <typename M>
+  inline NegWriteMap<M> negWriteMap(M &m) {
     return NegWriteMap<M>(m);
   }
 
-  ///Absolute value of a map
-
-  ///This \ref concepts::ReadMap "read only map" returns the absolute value
-  ///of the value returned by the given map.
-  ///Its \c Key and \c Value are inherited from \c M. 
-  ///\c Value must be comparable to \c 0 and the unary \c -
-  ///operator must be defined for it, of course.
-  template<typename M> 
+
+  /// Absolute value of a map
+
+  /// This \ref concepts::ReadMap "read-only map" returns the absolute
+  /// value of the values of the given map.
+  /// Its \c Key and \c Value are inherited from \c M.
+  /// \c Value must be comparable to \c 0 and the unary \c -
+  /// operator must be defined for it, of course.
+  ///
+  /// The simplest way of using this map is through the absMap()
+  /// function.
+  template<typename M>
   class AbsMap : public MapBase<typename M::Key, typename M::Value> {
-    const M& m;
+    const M &_m;
   public:
     typedef MapBase<typename M::Key, typename M::Value> Parent;
@@ -1004,206 +1287,223 @@
     typedef typename Parent::Value Value;
 
-    ///Constructor
-    AbsMap(const M &_m) : m(_m) {};
-    /// \e
-    Value operator[](Key k) const {
-      Value tmp = m[k]; 
+    /// Constructor
+    AbsMap(const M &m) : _m(m) {}
+    /// \e
+    Value operator[](const Key &k) const {
+      Value tmp = _m[k];
       return tmp >= 0 ? tmp : -tmp;
     }
 
   };
-  
-  ///Returns an \c AbsMap class
-
-  ///This function just returns an \c AbsMap class.
-  ///\relates AbsMap
-  template<typename M> 
+
+  /// Returns an \ref AbsMap class
+
+  /// This function just returns an \ref AbsMap class.
+  ///
+  /// For example, if \c m is a map with \c double values, then
+  /// <tt>absMap(m)[x]</tt> will be equal to <tt>m[x]</tt> if
+  /// it is positive or zero and <tt>-m[x]</tt> if <tt>m[x]</tt> is
+  /// negative.
+  ///
+  /// \relates AbsMap
+  template<typename M>
   inline AbsMap<M> absMap(const M &m) {
     return AbsMap<M>(m);
   }
 
-  ///Converts an STL style functor to a map
-
-  ///This \ref concepts::ReadMap "read only map" returns the value
-  ///of a given functor.
-  ///
-  ///Template parameters \c K and \c V will become its
-  ///\c Key and \c Value. 
-  ///In most cases they have to be given explicitly because a 
-  ///functor typically does not provide \c argument_type and 
-  ///\c result_type typedefs.
-  ///
-  ///Parameter \c F is the type of the used functor.
-  ///
-  ///\sa MapFunctor
-  template<typename F, 
-	   typename K = typename F::argument_type, 
-	   typename V = typename F::result_type> 
-  class FunctorMap : public MapBase<K, V> {
-    F f;
-  public:
-    typedef MapBase<K, V> Parent;
-    typedef typename Parent::Key Key;
-    typedef typename Parent::Value Value;
-
-    ///Constructor
-    FunctorMap(const F &_f = F()) : f(_f) {}
-    /// \e
-    Value operator[](Key k) const { return f(k);}
-  };
+  /// @}
   
-  ///Returns a \c FunctorMap class
-
-  ///This function just returns a \c FunctorMap class.
-  ///
-  ///This function is specialized for adaptable binary function
-  ///classes and C++ functions.
-  ///
-  ///\relates FunctorMap
-  template<typename K, typename V, typename F> inline 
-  FunctorMap<F, K, V> functorMap(const F &f) {
-    return FunctorMap<F, K, V>(f);
-  }
-
-  template <typename F> inline 
-  FunctorMap<F, typename F::argument_type, typename F::result_type> 
-  functorMap(const F &f) {
-    return FunctorMap<F, typename F::argument_type, 
-      typename F::result_type>(f);
-  }
-
-  template <typename K, typename V> inline 
-  FunctorMap<V (*)(K), K, V> functorMap(V (*f)(K)) {
-    return FunctorMap<V (*)(K), K, V>(f);
-  }
-
-
-  ///Converts a map to an STL style (unary) functor
-
-  ///This class Converts a map to an STL style (unary) functor.
-  ///That is it provides an <tt>operator()</tt> to read its values.
-  ///
-  ///For the sake of convenience it also works as
-  ///a ususal \ref concepts::ReadMap "readable map",
-  ///i.e. <tt>operator[]</tt> and the \c Key and \c Value typedefs also exist.
-  ///
-  ///\sa FunctorMap
-  template <typename M> 
-  class MapFunctor : public MapBase<typename M::Key, typename M::Value> {
-    const M& m;
-  public:
-    typedef MapBase<typename M::Key, typename M::Value> Parent;
-    typedef typename Parent::Key Key;
-    typedef typename Parent::Value Value;
-
-    typedef typename M::Key argument_type;
-    typedef typename M::Value result_type;
-
-    ///Constructor
-    MapFunctor(const M &_m) : m(_m) {};
-    ///\e
-    Value operator()(Key k) const {return m[k];}
-    ///\e
-    Value operator[](Key k) const {return m[k];}
-  };
-  
-  ///Returns a \c MapFunctor class
-
-  ///This function just returns a \c MapFunctor class.
-  ///\relates MapFunctor
-  template<typename M> 
-  inline MapFunctor<M> mapFunctor(const M &m) {
-    return MapFunctor<M>(m);
-  }
-
-  ///Just readable version of \ref ForkWriteMap
-
-  ///This map has two \ref concepts::ReadMap "readable map"
-  ///parameters and each read request will be passed just to the
-  ///first map. This class is the just readable map type of \c ForkWriteMap.
-  ///
-  ///The \c Key and \c Value are inherited from \c M1.
-  ///The \c Key and \c Value of \c M2 must be convertible from those of \c M1.
-  ///
-  ///\sa ForkWriteMap
-  ///
-  /// \todo Why is it needed?
-  template<typename  M1, typename M2> 
-  class ForkMap : public MapBase<typename M1::Key, typename M1::Value> {
-    const M1& m1;
-    const M2& m2;
-  public:
-    typedef MapBase<typename M1::Key, typename M1::Value> Parent;
-    typedef typename Parent::Key Key;
-    typedef typename Parent::Value Value;
-
-    ///Constructor
-    ForkMap(const M1 &_m1, const M2 &_m2) : m1(_m1), m2(_m2) {};
-    /// \e
-    Value operator[](Key k) const {return m1[k];}
-  };
-
-
-  ///Applies all map setting operations to two maps
-
-  ///This map has two \ref concepts::WriteMap "writable map"
-  ///parameters and each write request will be passed to both of them.
-  ///If \c M1 is also \ref concepts::ReadMap "readable",
-  ///then the read operations will return the
-  ///corresponding values of \c M1.
-  ///
-  ///The \c Key and \c Value are inherited from \c M1.
-  ///The \c Key and \c Value of \c M2 must be convertible from those of \c M1.
-  ///
-  ///\sa ForkMap
-  template<typename  M1, typename M2> 
-  class ForkWriteMap : public MapBase<typename M1::Key, typename M1::Value> {
-    M1& m1;
-    M2& m2;
-  public:
-    typedef MapBase<typename M1::Key, typename M1::Value> Parent;
-    typedef typename Parent::Key Key;
-    typedef typename Parent::Value Value;
-
-    ///Constructor
-    ForkWriteMap(M1 &_m1, M2 &_m2) : m1(_m1), m2(_m2) {};
-    ///\e
-    Value operator[](Key k) const {return m1[k];}
-    ///\e
-    void set(Key k, const Value &v) {m1.set(k,v); m2.set(k,v);}
-  };
-  
-  ///Returns a \c ForkMap class
-
-  ///This function just returns a \c ForkMap class.
-  ///\relates ForkMap
-  template <typename M1, typename M2> 
-  inline ForkMap<M1, M2> forkMap(const M1 &m1, const M2 &m2) {
-    return ForkMap<M1, M2>(m1,m2);
-  }
-
-  ///Returns a \c ForkWriteMap class
-
-  ///This function just returns a \c ForkWriteMap class.
-  ///\relates ForkWriteMap
-  template <typename M1, typename M2> 
-  inline ForkWriteMap<M1, M2> forkMap(M1 &m1, M2 &m2) {
-    return ForkWriteMap<M1, M2>(m1,m2);
-  }
-
-
-  
-  /* ************* BOOL MAPS ******************* */
-  
-  ///Logical 'not' of a map
-  
-  ///This bool \ref concepts::ReadMap "read only map" returns the 
-  ///logical negation of the value returned by the given map.
-  ///Its \c Key is inherited from \c M, its \c Value is \c bool.
-  ///
-  ///\sa NotWriteMap
-  template <typename M> 
+  // Logical maps and map adaptors:
+
+  /// \addtogroup maps
+  /// @{
+
+  /// Constant \c true map.
+
+  /// This \ref concepts::ReadMap "read-only map" assigns \c true to
+  /// each key.
+  ///
+  /// Note that
+  /// \code
+  ///   TrueMap<K> tm;
+  /// \endcode
+  /// is equivalent to
+  /// \code
+  ///   ConstMap<K,bool> tm(true);
+  /// \endcode
+  ///
+  /// \sa FalseMap
+  /// \sa ConstMap
+  template <typename K>
+  class TrueMap : public MapBase<K, bool> {
+  public:
+    typedef MapBase<K, bool> Parent;
+    typedef typename Parent::Key Key;
+    typedef typename Parent::Value Value;
+
+    /// Gives back \c true.
+    Value operator[](const Key&) const { return true; }
+  };
+
+  /// Returns a \ref TrueMap class
+
+  /// This function just returns a \ref TrueMap class.
+  /// \relates TrueMap
+  template<typename K>
+  inline TrueMap<K> trueMap() {
+    return TrueMap<K>();
+  }
+
+
+  /// Constant \c false map.
+
+  /// This \ref concepts::ReadMap "read-only map" assigns \c false to
+  /// each key.
+  ///
+  /// Note that
+  /// \code
+  ///   FalseMap<K> fm;
+  /// \endcode
+  /// is equivalent to
+  /// \code
+  ///   ConstMap<K,bool> fm(false);
+  /// \endcode
+  ///
+  /// \sa TrueMap
+  /// \sa ConstMap
+  template <typename K>
+  class FalseMap : public MapBase<K, bool> {
+  public:
+    typedef MapBase<K, bool> Parent;
+    typedef typename Parent::Key Key;
+    typedef typename Parent::Value Value;
+
+    /// Gives back \c false.
+    Value operator[](const Key&) const { return false; }
+  };
+
+  /// Returns a \ref FalseMap class
+
+  /// This function just returns a \ref FalseMap class.
+  /// \relates FalseMap
+  template<typename K>
+  inline FalseMap<K> falseMap() {
+    return FalseMap<K>();
+  }
+
+  /// @}
+
+  /// \addtogroup map_adaptors
+  /// @{
+
+  /// Logical 'and' of two maps
+
+  /// This \ref concepts::ReadMap "read-only map" returns the logical
+  /// 'and' of the values of the two given maps.
+  /// Its \c Key type is inherited from \c M1 and its \c Value type is
+  /// \c bool. \c M2::Key must be convertible to \c M1::Key.
+  ///
+  /// If \c m1 is of type \c M1 and \c m2 is of \c M2, then for
+  /// \code
+  ///   AndMap<M1,M2> am(m1,m2);
+  /// \endcode
+  /// <tt>am[x]</tt> will be equal to <tt>m1[x]&&m2[x]</tt>.
+  ///
+  /// The simplest way of using this map is through the andMap()
+  /// function.
+  ///
+  /// \sa OrMap
+  /// \sa NotMap, NotWriteMap
+  template<typename M1, typename M2>
+  class AndMap : public MapBase<typename M1::Key, bool> {
+    const M1 &_m1;
+    const M2 &_m2;
+  public:
+    typedef MapBase<typename M1::Key, bool> Parent;
+    typedef typename Parent::Key Key;
+    typedef typename Parent::Value Value;
+
+    /// Constructor
+    AndMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {}
+    /// \e
+    Value operator[](const Key &k) const { return _m1[k]&&_m2[k]; }
+  };
+
+  /// Returns an \ref AndMap class
+
+  /// This function just returns an \ref AndMap class.
+  ///
+  /// For example, if \c m1 and \c m2 are both maps with \c bool values,
+  /// then <tt>andMap(m1,m2)[x]</tt> will be equal to
+  /// <tt>m1[x]&&m2[x]</tt>.
+  ///
+  /// \relates AndMap
+  template<typename M1, typename M2>
+  inline AndMap<M1, M2> andMap(const M1 &m1, const M2 &m2) {
+    return AndMap<M1, M2>(m1,m2);
+  }
+
+
+  /// Logical 'or' of two maps
+
+  /// This \ref concepts::ReadMap "read-only map" returns the logical
+  /// 'or' of the values of the two given maps.
+  /// Its \c Key type is inherited from \c M1 and its \c Value type is
+  /// \c bool. \c M2::Key must be convertible to \c M1::Key.
+  ///
+  /// If \c m1 is of type \c M1 and \c m2 is of \c M2, then for
+  /// \code
+  ///   OrMap<M1,M2> om(m1,m2);
+  /// \endcode
+  /// <tt>om[x]</tt> will be equal to <tt>m1[x]||m2[x]</tt>.
+  ///
+  /// The simplest way of using this map is through the orMap()
+  /// function.
+  ///
+  /// \sa AndMap
+  /// \sa NotMap, NotWriteMap
+  template<typename M1, typename M2>
+  class OrMap : public MapBase<typename M1::Key, bool> {
+    const M1 &_m1;
+    const M2 &_m2;
+  public:
+    typedef MapBase<typename M1::Key, bool> Parent;
+    typedef typename Parent::Key Key;
+    typedef typename Parent::Value Value;
+
+    /// Constructor
+    OrMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {}
+    /// \e
+    Value operator[](const Key &k) const { return _m1[k]||_m2[k]; }
+  };
+
+  /// Returns an \ref OrMap class
+
+  /// This function just returns an \ref OrMap class.
+  ///
+  /// For example, if \c m1 and \c m2 are both maps with \c bool values,
+  /// then <tt>orMap(m1,m2)[x]</tt> will be equal to
+  /// <tt>m1[x]||m2[x]</tt>.
+  ///
+  /// \relates OrMap
+  template<typename M1, typename M2>
+  inline OrMap<M1, M2> orMap(const M1 &m1, const M2 &m2) {
+    return OrMap<M1, M2>(m1,m2);
+  }
+
+
+  /// Logical 'not' of a map
+
+  /// This \ref concepts::ReadMap "read-only map" returns the logical
+  /// negation of the values of the given map.
+  /// Its \c Key is inherited from \c M and its \c Value is \c bool.
+  ///
+  /// The simplest way of using this map is through the notMap()
+  /// function.
+  ///
+  /// \sa NotWriteMap
+  template <typename M>
   class NotMap : public MapBase<typename M::Key, bool> {
-    const M& m;
+    const M &_m;
   public:
     typedef MapBase<typename M::Key, bool> Parent;
@@ -1212,20 +1512,24 @@
 
     /// Constructor
-    NotMap(const M &_m) : m(_m) {};
-    ///\e
-    Value operator[](Key k) const {return !m[k];}
-  };
-
-  ///Logical 'not' of a map (ReadWrie version)
-  
-  ///This bool \ref concepts::ReadWriteMap "read-write map" returns the 
-  ///logical negation of the value returned by the given map. When it is set,
-  ///the opposite value is set to the original map.
-  ///Its \c Key is inherited from \c M, its \c Value is \c bool.
-  ///
-  ///\sa NotMap
-  template <typename M> 
+    NotMap(const M &m) : _m(m) {}
+    /// \e
+    Value operator[](const Key &k) const { return !_m[k]; }
+  };
+
+  /// Logical 'not' of a map (read-write version)
+
+  /// This \ref concepts::ReadWriteMap "read-write map" returns the
+  /// logical negation of the values of the given map.
+  /// Its \c Key is inherited from \c M and its \c Value is \c bool.
+  /// It makes also possible to write the map. When a value is set,
+  /// the opposite value is set to the original map.
+  ///
+  /// The simplest way of using this map is through the notWriteMap()
+  /// function.
+  ///
+  /// \sa NotMap
+  template <typename M>
   class NotWriteMap : public MapBase<typename M::Key, bool> {
-    M& m;
+    M &_m;
   public:
     typedef MapBase<typename M::Key, bool> Parent;
@@ -1234,403 +1538,133 @@
 
     /// Constructor
-    NotWriteMap(M &_m) : m(_m) {};
-    ///\e
-    Value operator[](Key k) const {return !m[k];}
-    ///\e
-    void set(Key k, bool v) { m.set(k, !v); }
-  };
-  
-  ///Returns a \c NotMap class
-  
-  ///This function just returns a \c NotMap class.
-  ///\relates NotMap
-  template <typename M> 
+    NotWriteMap(M &m) : _m(m) {}
+    /// \e
+    Value operator[](const Key &k) const { return !_m[k]; }
+    /// \e
+    void set(const Key &k, bool v) { _m.set(k, !v); }
+  };
+
+  /// Returns a \ref NotMap class
+
+  /// This function just returns a \ref NotMap class.
+  ///
+  /// For example, if \c m is a map with \c bool values, then
+  /// <tt>notMap(m)[x]</tt> will be equal to <tt>!m[x]</tt>.
+  ///
+  /// \relates NotMap
+  template <typename M>
   inline NotMap<M> notMap(const M &m) {
     return NotMap<M>(m);
   }
-  
-  ///Returns a \c NotWriteMap class
-  
-  ///This function just returns a \c NotWriteMap class.
-  ///\relates NotWriteMap
-  template <typename M> 
-  inline NotWriteMap<M> notMap(M &m) {
+
+  /// Returns a \ref NotWriteMap class
+
+  /// This function just returns a \ref NotWriteMap class.
+  ///
+  /// For example, if \c m is a map with \c bool values, then
+  /// <tt>notWriteMap(m)[x]</tt> will be equal to <tt>!m[x]</tt>.
+  /// Moreover it makes also possible to write the map.
+  ///
+  /// \relates NotWriteMap
+  template <typename M>
+  inline NotWriteMap<M> notWriteMap(M &m) {
     return NotWriteMap<M>(m);
   }
 
-  namespace _maps_bits {
-
-    template <typename Value>
-    struct Identity {
-      typedef Value argument_type;
-      typedef Value result_type;
-      Value operator()(const Value& val) const {
-	return val;
-      }
-    };
-
-    template <typename _Iterator, typename Enable = void>
-    struct IteratorTraits {
-      typedef typename std::iterator_traits<_Iterator>::value_type Value;
-    };
-
-    template <typename _Iterator>
-    struct IteratorTraits<_Iterator,
-      typename exists<typename _Iterator::container_type>::type> 
-    {
-      typedef typename _Iterator::container_type::value_type Value;
-    };
-
-  }
-  
-
-  /// \brief Writable bool map for logging each \c true assigned element
-  ///
-  /// A \ref concepts::ReadWriteMap "read-write" bool map for logging 
-  /// each \c true assigned element, i.e it copies all the keys set 
-  /// to \c true to the given iterator.
-  ///
-  /// \note The container of the iterator should contain space 
-  /// for each element.
-  ///
-  /// The following example shows how you can write the edges found by 
-  /// the \ref Prim algorithm directly to the standard output.
-  ///\code
-  /// typedef IdMap<Graph, Edge> EdgeIdMap;
-  /// EdgeIdMap edgeId(graph);
-  ///
-  /// typedef MapFunctor<EdgeIdMap> EdgeIdFunctor;
-  /// EdgeIdFunctor edgeIdFunctor(edgeId);
-  ///
-  /// StoreBoolMap<ostream_iterator<int>, EdgeIdFunctor> 
-  ///   writerMap(ostream_iterator<int>(cout, " "), edgeIdFunctor);
-  ///
-  /// prim(graph, cost, writerMap);
-  ///\endcode
-  ///
-  ///\sa BackInserterBoolMap 
-  ///\sa FrontInserterBoolMap 
-  ///\sa InserterBoolMap 
-  ///
-  ///\todo Revise the name of this class and the related ones.
-  template <typename _Iterator, 
-            typename _Functor =
-            _maps_bits::Identity<typename _maps_bits::
-                                 IteratorTraits<_Iterator>::Value> >
-  class StoreBoolMap {
-  public:
-    typedef _Iterator Iterator;
-
-    typedef typename _Functor::argument_type Key;
-    typedef bool Value;
-
-    typedef _Functor Functor;
-
-    /// Constructor
-    StoreBoolMap(Iterator it, const Functor& functor = Functor()) 
-      : _begin(it), _end(it), _functor(functor) {}
-
-    /// Gives back the given iterator set for the first key
-    Iterator begin() const {
-      return _begin;
-    }
- 
-    /// Gives back the the 'after the last' iterator
-    Iterator end() const {
-      return _end;
-    }
-
-    /// The \c set function of the map
-    void set(const Key& key, Value value) const {
-      if (value) {
-	*_end++ = _functor(key);
-      }
-    }
-    
-  private:
-    Iterator _begin;
-    mutable Iterator _end;
-    Functor _functor;
-  };
-
-  /// \brief Writable bool map for logging each \c true assigned element in 
-  /// a back insertable container.
-  ///
-  /// Writable bool map for logging each \c true assigned element by pushing
-  /// them into a back insertable container.
-  /// It can be used to retrieve the items into a standard
-  /// container. The next example shows how you can store the
-  /// edges found by the Prim algorithm in a vector.
-  ///
-  ///\code
-  /// vector<Edge> span_tree_edges;
-  /// BackInserterBoolMap<vector<Edge> > inserter_map(span_tree_edges);
-  /// prim(graph, cost, inserter_map);
-  ///\endcode
-  ///
-  ///\sa StoreBoolMap
-  ///\sa FrontInserterBoolMap
-  ///\sa InserterBoolMap
-  template <typename Container,
-            typename Functor =
-            _maps_bits::Identity<typename Container::value_type> >
-  class BackInserterBoolMap {
-  public:
-    typedef typename Functor::argument_type Key;
-    typedef bool Value;
-
-    /// Constructor
-    BackInserterBoolMap(Container& _container, 
-                        const Functor& _functor = Functor()) 
-      : container(_container), functor(_functor) {}
-
-    /// The \c set function of the map
-    void set(const Key& key, Value value) {
-      if (value) {
-	container.push_back(functor(key));
-      }
-    }
-    
-  private:
-    Container& container;
-    Functor functor;
-  };
-
-  /// \brief Writable bool map for logging each \c true assigned element in 
-  /// a front insertable container.
-  ///
-  /// Writable bool map for logging each \c true assigned element by pushing
-  /// them into a front insertable container.
-  /// It can be used to retrieve the items into a standard
-  /// container. For example see \ref BackInserterBoolMap.
-  ///
-  ///\sa BackInserterBoolMap
-  ///\sa InserterBoolMap
-  template <typename Container,
-            typename Functor =
-            _maps_bits::Identity<typename Container::value_type> >
-  class FrontInserterBoolMap {
-  public:
-    typedef typename Functor::argument_type Key;
-    typedef bool Value;
-
-    /// Constructor
-    FrontInserterBoolMap(Container& _container,
-                         const Functor& _functor = Functor()) 
-      : container(_container), functor(_functor) {}
-
-    /// The \c set function of the map
-    void set(const Key& key, Value value) {
-      if (value) {
-	container.push_front(functor(key));
-      }
-    }
-    
-  private:
-    Container& container;    
-    Functor functor;
-  };
-
-  /// \brief Writable bool map for storing each \c true assigned element in 
-  /// an insertable container.
-  ///
-  /// Writable bool map for storing each \c true assigned element in an 
-  /// insertable container. It will insert all the keys set to \c true into
-  /// the container.
-  ///
-  /// For example, if you want to store the cut arcs of the strongly
-  /// connected components in a set you can use the next code:
-  ///
-  ///\code
-  /// set<Arc> cut_arcs;
-  /// InserterBoolMap<set<Arc> > inserter_map(cut_arcs);
-  /// stronglyConnectedCutArcs(digraph, cost, inserter_map);
-  ///\endcode
-  ///
-  ///\sa BackInserterBoolMap
-  ///\sa FrontInserterBoolMap
-  template <typename Container,
-            typename Functor =
-            _maps_bits::Identity<typename Container::value_type> >
-  class InserterBoolMap {
-  public:
-    typedef typename Container::value_type Key;
-    typedef bool Value;
-
-    /// Constructor with specified iterator
-    
-    /// Constructor with specified iterator.
-    /// \param _container The container for storing the elements.
-    /// \param _it The elements will be inserted before this iterator.
-    /// \param _functor The functor that is used when an element is stored.
-    InserterBoolMap(Container& _container, typename Container::iterator _it,
-                    const Functor& _functor = Functor()) 
-      : container(_container), it(_it), functor(_functor) {}
-
-    /// Constructor
-
-    /// Constructor without specified iterator.
-    /// The elements will be inserted before <tt>_container.end()</tt>.
-    /// \param _container The container for storing the elements.
-    /// \param _functor The functor that is used when an element is stored.
-    InserterBoolMap(Container& _container, const Functor& _functor = Functor())
-      : container(_container), it(_container.end()), functor(_functor) {}
-
-    /// The \c set function of the map
-    void set(const Key& key, Value value) {
-      if (value) {
-	it = container.insert(it, functor(key));
-        ++it;
-      }
-    }
-    
-  private:
-    Container& container;
-    typename Container::iterator it;
-    Functor functor;
-  };
-
-  /// \brief Writable bool map for filling each \c true assigned element with a 
-  /// given value.
-  ///
-  /// Writable bool map for filling each \c true assigned element with a 
-  /// given value. The value can set the container.
-  ///
-  /// The following code finds the connected components of a graph
-  /// and stores it in the \c comp map:
-  ///\code
-  /// typedef Graph::NodeMap<int> ComponentMap;
-  /// ComponentMap comp(graph);
-  /// typedef FillBoolMap<Graph::NodeMap<int> > ComponentFillerMap;
-  /// ComponentFillerMap filler(comp, 0);
-  ///
-  /// Dfs<Graph>::DefProcessedMap<ComponentFillerMap>::Create dfs(graph);
-  /// dfs.processedMap(filler);
-  /// dfs.init();
-  /// for (NodeIt it(graph); it != INVALID; ++it) {
-  ///   if (!dfs.reached(it)) {
-  ///     dfs.addSource(it);
-  ///     dfs.start();
-  ///     ++filler.fillValue();
-  ///   }
-  /// }
-  ///\endcode
-  template <typename Map>
-  class FillBoolMap {
-  public:
-    typedef typename Map::Key Key;
-    typedef bool Value;
-
-    /// Constructor
-    FillBoolMap(Map& _map, const typename Map::Value& _fill) 
-      : map(_map), fill(_fill) {}
-
-    /// Constructor
-    FillBoolMap(Map& _map) 
-      : map(_map), fill() {}
-
-    /// Gives back the current fill value
-    const typename Map::Value& fillValue() const {
-      return fill;
-    } 
-
-    /// Gives back the current fill value
-    typename Map::Value& fillValue() {
-      return fill;
-    } 
-
-    /// Sets the current fill value
-    void fillValue(const typename Map::Value& _fill) {
-      fill = _fill;
-    } 
-
-    /// The \c set function of the map
-    void set(const Key& key, Value value) {
-      if (value) {
-	map.set(key, fill);
-      }
-    }
-    
-  private:
-    Map& map;
-    typename Map::Value fill;
-  };
-
-
-  /// \brief Writable bool map for storing the sequence number of 
-  /// \c true assignments.  
-  /// 
-  /// Writable bool map that stores for each \c true assigned elements  
-  /// the sequence number of this setting.
-  /// It makes it easy to calculate the leaving
-  /// order of the nodes in the \c Dfs algorithm.
-  ///
-  ///\code
-  /// typedef Digraph::NodeMap<int> OrderMap;
-  /// OrderMap order(digraph);
-  /// typedef SettingOrderBoolMap<OrderMap> OrderSetterMap;
-  /// OrderSetterMap setter(order);
-  /// Dfs<Digraph>::DefProcessedMap<OrderSetterMap>::Create dfs(digraph);
-  /// dfs.processedMap(setter);
-  /// dfs.init();
-  /// for (NodeIt it(digraph); it != INVALID; ++it) {
-  ///   if (!dfs.reached(it)) {
-  ///     dfs.addSource(it);
-  ///     dfs.start();
-  ///   }
-  /// }
-  ///\endcode
-  ///
-  /// The storing of the discovering order is more difficult because the
-  /// ReachedMap should be readable in the dfs algorithm but the setting
-  /// order map is not readable. Thus we must use the fork map:
-  ///
-  ///\code
-  /// typedef Digraph::NodeMap<int> OrderMap;
-  /// OrderMap order(digraph);
-  /// typedef SettingOrderBoolMap<OrderMap> OrderSetterMap;
-  /// OrderSetterMap setter(order);
-  /// typedef Digraph::NodeMap<bool> StoreMap;
-  /// StoreMap store(digraph);
-  ///
-  /// typedef ForkWriteMap<StoreMap, OrderSetterMap> ReachedMap;
-  /// ReachedMap reached(store, setter);
-  ///
-  /// Dfs<Digraph>::DefReachedMap<ReachedMap>::Create dfs(digraph);
-  /// dfs.reachedMap(reached);
-  /// dfs.init();
-  /// for (NodeIt it(digraph); it != INVALID; ++it) {
-  ///   if (!dfs.reached(it)) {
-  ///     dfs.addSource(it);
-  ///     dfs.start();
-  ///   }
-  /// }
-  ///\endcode
-  template <typename Map>
-  class SettingOrderBoolMap {
-  public:
-    typedef typename Map::Key Key;
-    typedef bool Value;
-
-    /// Constructor
-    SettingOrderBoolMap(Map& _map) 
-      : map(_map), counter(0) {}
-
-    /// Number of set operations.
-    int num() const {
-      return counter;
-    }
-
-    /// The \c set function of the map
-    void set(const Key& key, Value value) {
-      if (value) {
-	map.set(key, counter++);
-      }
-    }
-    
-  private:
-    Map& map;
-    int counter;
-  };
+
+  /// Combination of two maps using the \c == operator
+
+  /// This \ref concepts::ReadMap "read-only map" assigns \c true to
+  /// the keys for which the corresponding values of the two maps are
+  /// equal.
+  /// Its \c Key type is inherited from \c M1 and its \c Value type is
+  /// \c bool. \c M2::Key must be convertible to \c M1::Key.
+  ///
+  /// If \c m1 is of type \c M1 and \c m2 is of \c M2, then for
+  /// \code
+  ///   EqualMap<M1,M2> em(m1,m2);
+  /// \endcode
+  /// <tt>em[x]</tt> will be equal to <tt>m1[x]==m2[x]</tt>.
+  ///
+  /// The simplest way of using this map is through the equalMap()
+  /// function.
+  ///
+  /// \sa LessMap
+  template<typename M1, typename M2>
+  class EqualMap : public MapBase<typename M1::Key, bool> {
+    const M1 &_m1;
+    const M2 &_m2;
+  public:
+    typedef MapBase<typename M1::Key, bool> Parent;
+    typedef typename Parent::Key Key;
+    typedef typename Parent::Value Value;
+
+    /// Constructor
+    EqualMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {}
+    /// \e
+    Value operator[](const Key &k) const { return _m1[k]==_m2[k]; }
+  };
+
+  /// Returns an \ref EqualMap class
+
+  /// This function just returns an \ref EqualMap class.
+  ///
+  /// For example, if \c m1 and \c m2 are maps with keys and values of
+  /// the same type, then <tt>equalMap(m1,m2)[x]</tt> will be equal to
+  /// <tt>m1[x]==m2[x]</tt>.
+  ///
+  /// \relates EqualMap
+  template<typename M1, typename M2>
+  inline EqualMap<M1, M2> equalMap(const M1 &m1, const M2 &m2) {
+    return EqualMap<M1, M2>(m1,m2);
+  }
+
+
+  /// Combination of two maps using the \c < operator
+
+  /// This \ref concepts::ReadMap "read-only map" assigns \c true to
+  /// the keys for which the corresponding value of the first map is
+  /// less then the value of the second map.
+  /// Its \c Key type is inherited from \c M1 and its \c Value type is
+  /// \c bool. \c M2::Key must be convertible to \c M1::Key.
+  ///
+  /// If \c m1 is of type \c M1 and \c m2 is of \c M2, then for
+  /// \code
+  ///   LessMap<M1,M2> lm(m1,m2);
+  /// \endcode
+  /// <tt>lm[x]</tt> will be equal to <tt>m1[x]<m2[x]</tt>.
+  ///
+  /// The simplest way of using this map is through the lessMap()
+  /// function.
+  ///
+  /// \sa EqualMap
+  template<typename M1, typename M2>
+  class LessMap : public MapBase<typename M1::Key, bool> {
+    const M1 &_m1;
+    const M2 &_m2;
+  public:
+    typedef MapBase<typename M1::Key, bool> Parent;
+    typedef typename Parent::Key Key;
+    typedef typename Parent::Value Value;
+
+    /// Constructor
+    LessMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {}
+    /// \e
+    Value operator[](const Key &k) const { return _m1[k]<_m2[k]; }
+  };
+
+  /// Returns an \ref LessMap class
+
+  /// This function just returns an \ref LessMap class.
+  ///
+  /// For example, if \c m1 and \c m2 are maps with keys and values of
+  /// the same type, then <tt>lessMap(m1,m2)[x]</tt> will be equal to
+  /// <tt>m1[x]<m2[x]</tt>.
+  ///
+  /// \relates LessMap
+  template<typename M1, typename M2>
+  inline LessMap<M1, M2> lessMap(const M1 &m1, const M2 &m2) {
+    return LessMap<M1, M2>(m1,m2);
+  }
 
   /// @}
Index: lemon/math.h
===================================================================
--- lemon/math.h	(revision 68)
+++ lemon/math.h	(revision 68)
@@ -0,0 +1,63 @@
+/* -*- C++ -*-
+ *
+ * This file is a part of LEMON, a generic C++ optimization library
+ *
+ * Copyright (C) 2003-2008
+ * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
+ * (Egervary Research Group on Combinatorial Optimization, EGRES).
+ *
+ * Permission to use, modify and distribute this software is granted
+ * provided that this copyright notice appears in all copies. For
+ * precise terms see the accompanying LICENSE file.
+ *
+ * This software is provided "AS IS" with no warranty of any kind,
+ * express or implied, and with no claim as to its suitability for any
+ * purpose.
+ *
+ */
+
+#ifndef LEMON_MATH_H
+#define LEMON_MATH_H
+
+///\ingroup misc
+///\file
+///\brief Some extensions to the standard \c cmath library.
+///
+///Some extensions to the standard \c cmath library.
+///
+///This file includes the standard math library (cmath).
+
+#include<cmath>
+
+namespace lemon {
+
+  /// \addtogroup misc
+  /// @{
+  
+  /// The Euler constant
+  const long double E       = 2.7182818284590452353602874713526625L;
+  /// log_2(e)
+  const long double LOG2E   = 1.4426950408889634073599246810018921L;
+  /// log_10(e)
+  const long double LOG10E  = 0.4342944819032518276511289189166051L;
+  /// ln(2)
+  const long double LN2     = 0.6931471805599453094172321214581766L;
+  /// ln(10)
+  const long double LN10    = 2.3025850929940456840179914546843642L;
+  /// pi
+  const long double PI      = 3.1415926535897932384626433832795029L;
+  /// pi/2
+  const long double PI_2    = 1.5707963267948966192313216916397514L;
+  /// pi/4
+  const long double PI_4    = 0.7853981633974483096156608458198757L;
+  /// sqrt(2)
+  const long double SQRT2   = 1.4142135623730950488016887242096981L;
+  /// 1/sqrt(2)
+  const long double SQRT1_2 = 0.7071067811865475244008443621048490L;
+  
+
+  /// @}
+
+} //namespace lemon
+
+#endif //LEMON_TOLERANCE_H
Index: lemon/random.h
===================================================================
--- lemon/random.h	(revision 49)
+++ lemon/random.h	(revision 68)
@@ -68,7 +68,8 @@
 
 #include <ctime>
-#include <cmath>
-
+
+#include <lemon/math.h>
 #include <lemon/dim2.h>
+
 ///\ingroup misc
 ///\file
@@ -255,5 +256,5 @@
           --curr;
         }
-        curr[0] = (((curr[0] & hiMask) | (curr[length - 1] & loMask)) >> 1) ^
+        state[0] = (((state[0] & hiMask) | (curr[length - 1] & loMask)) >> 1) ^
           curr[length - shift] ^ mask[curr[length - 1] & 1ul];
 
@@ -760,5 +761,5 @@
       double xi,nu;
       const double delta = k-std::floor(k);
-      const double v0=M_E/(M_E-delta);
+      const double v0=E/(E-delta);
       do {
 	double V0=1.0-real<double>();
Index: lemon/tolerance.h
===================================================================
--- lemon/tolerance.h	(revision 49)
+++ lemon/tolerance.h	(revision 72)
@@ -41,7 +41,7 @@
   ///as a result of a probably inexact computation.
   ///
-  ///This is an abstract class, it should be specialized for all numerical
-  ///data types. These specialized classes like \ref Tolerance<double>
-  ///may offer additional tuning parameters.
+  ///This is an abstract class, it should be specialized for all 
+  ///numerical data types. These specialized classes like 
+  ///Tolerance<double> may offer additional tuning parameters.
   ///
   ///\sa Tolerance<float>
@@ -118,5 +118,5 @@
 
     ///\name Comparisons
-    ///See \ref Tolerance for more details.
+    ///See \ref lemon::Tolerance "Tolerance" for more details.
 
     ///@{
@@ -169,5 +169,5 @@
 
     ///\name Comparisons
-    ///See \ref Tolerance for more details.
+    ///See \ref lemon::Tolerance "Tolerance" for more details.
 
     ///@{
@@ -220,5 +220,5 @@
 
     ///\name Comparisons
-    ///See \ref Tolerance for more details.
+    ///See \ref lemon::Tolerance "Tolerance" for more details.
 
     ///@{
@@ -253,5 +253,5 @@
 
     ///\name Comparisons
-    ///See \ref Tolerance for more details.
+    ///See \ref lemon::Tolerance "Tolerance" for more details.
 
     ///@{
@@ -276,5 +276,5 @@
   ///Unsigned integer specialization of Tolerance.
 
-  ///Unsigned integer specialization of \ref Tolerance.
+  ///Unsigned integer specialization of Tolerance.
   ///\sa Tolerance
   template<>
@@ -286,5 +286,5 @@
 
     ///\name Comparisons
-    ///See \ref Tolerance for more details.
+    ///See \ref lemon::Tolerance "Tolerance" for more details.
 
     ///@{
@@ -320,5 +320,5 @@
 
     ///\name Comparisons
-    ///See \ref Tolerance for more details.
+    ///See \ref lemon::Tolerance "Tolerance" for more details.
 
     ///@{
@@ -343,5 +343,5 @@
   ///Unsigned long integer specialization of Tolerance.
 
-  ///Unsigned long integer specialization of \ref Tolerance.
+  ///Unsigned long integer specialization of Tolerance.
   ///\sa Tolerance
   template<>
@@ -353,5 +353,5 @@
 
     ///\name Comparisons
-    ///See \ref Tolerance for more details.
+    ///See \ref lemon::Tolerance "Tolerance" for more details.
 
     ///@{
@@ -378,5 +378,5 @@
   ///Long long integer specialization of Tolerance.
 
-  ///Long long integer specialization of \ref Tolerance.
+  ///Long long integer specialization of Tolerance.
   ///\warning This class (more exactly, type <tt>long long</tt>)
   ///is not ansi compatible.
@@ -390,5 +390,5 @@
 
     ///\name Comparisons
-    ///See \ref Tolerance for more details.
+    ///See \ref lemon::Tolerance "Tolerance" for more details.
 
     ///@{
@@ -413,5 +413,5 @@
   ///Unsigned long long integer specialization of Tolerance.
 
-  ///Unsigned long long integer specialization of \ref Tolerance.
+  ///Unsigned long long integer specialization of Tolerance.
   ///\warning This class (more exactly, type <tt>unsigned long long</tt>)
   ///is not ansi compatible.
@@ -425,5 +425,5 @@
 
     ///\name Comparisons
-    ///See \ref Tolerance for more details.
+    ///See \ref lemon::Tolerance "Tolerance" for more details.
 
     ///@{
