Index: .hgignore
===================================================================
--- .hgignore	(revision 3)
+++ .hgignore	(revision 9)
@@ -6,4 +6,7 @@
 *.o
 .#.*
+*.log
+*.lo
+*.tar.*
 Makefile.in
 aclocal.m4
@@ -20,10 +23,12 @@
 lemon/stamp-h2
 doc/Doxyfile
-lemon/.dirstamp
-lemon/.libs/*
+.dirstamp
+.libs/*
+.deps/*
 
 syntax: regexp
-html/.*
-autom4te.cache/.*
-build-aux/.*
-objs.*/.*
+^doc/html/.*
+^autom4te.cache/.*
+^build-aux/.*
+^objs.*/.*
+^test/[a-z_]*$
Index: INSTALL
===================================================================
--- INSTALL	(revision 5)
+++ INSTALL	(revision 5)
@@ -0,0 +1,117 @@
+Installation Instructions
+=========================
+
+   Since you are reading this I assume you already obtained one of the release
+tarballs and successfully extracted it. The latest version of LEMON is
+available at our webpage (http://lemon.cs.elte.hu/).
+
+   In order to install LEMON from the extracted source tarball you have to
+issue the following commands:
+
+  1. `cd lemon-x.y.z'
+
+     This changes to the directory which was created when you extracted the
+     sources. The x.y.z part is a version number.
+
+  2. `./configure'
+
+     This runs the configure shell script, which does some checks and
+     configuration (creates makefiles etc).
+
+  3. `make'
+
+     This command compiles the non-template part of LEMON into libemon.a file.
+     It also compiles the benchmark and demo programs when enabled.
+
+  4. `make check'
+
+     This step is optional, but recommended. It runs the test programs that we
+     developed for LEMON to check whether the library works properly on your
+     platform.
+
+  5. `make install'
+
+     This command installs LEMON under /usr/local (you will need root
+     privileges to be able to do that). If you want to install it to some
+     other location, then pass the --prefix=DIRECTORY flag to configure in
+     step 1. For example: `./configure --prefix=/home/username/lemon'
+
+
+Configure Flags
+===============
+
+   You can pass the following flags to configure in step 1
+(see ./configure --help for more):
+
+CXX=comp
+
+  Change the C++ compiler to 'comp'.
+
+CXXFLAGS='flags'
+
+  Pass the 'flags' to the compiler. For example
+  CXXFLAGS='-O3 -march=pentium-m'
+  turns  on generation of aggressively optimized
+  Pentium-M specific code.
+
+--enable-demo
+
+   Build the demo programs too.
+
+--disable-demo
+
+   Do not build the demo programs (default).
+
+--enable-benchmark
+
+   Build the benchmark programs too.
+
+--disable-benchmark
+
+   Do not build the benchmark programs (default).
+
+--with-glpk[=PREFIX]
+
+   Enable GLPK support (default). You should specify the prefix too if
+   you installed GLPK to some non-standard location (e.g. your home
+   directory). If it is not found, GLPK support will be disabled.
+
+--with-glpk-includedir=DIR
+
+   The directory where the GLPK header files are located. This is only
+   useful when the GLPK headers and libraries are not under the same
+   prefix (which is unlikely).
+
+--with-glpk-libdir=DIR
+
+   The directory where the GLPK libraries are located. This is only
+   useful when the GLPK headers and libraries are not under the same
+   prefix (which is unlikely).
+
+--without-glpk
+
+   Disable GLPK support.
+
+--with-cplex[=PREFIX]
+
+   Enable CPLEX support (default). You should specify the prefix too
+   if you installed CPLEX to some non-standard location
+   (e.g. /opt/ilog/cplex75). If it is not found, CPLEX support will be
+   disabled.
+
+--with-cplex-includedir=DIR
+
+   The directory where the CPLEX header files are located. This is
+   only useful when the CPLEX headers and libraries are not under the
+   same prefix (e.g.  /usr/local/cplex/cplex75/include).
+
+--with-cplex-libdir=DIR
+
+   The directory where the CPLEX libraries are located. This is only
+   useful when the CPLEX headers and libraries are not under the same
+   prefix (e.g.
+   /usr/local/cplex/cplex75/lib/i86_linux2_glibc2.2_gcc3.0/static_pic_mt).
+
+--without-cplex
+
+   Disable CPLEX support.
Index: LICENSE
===================================================================
--- LICENSE	(revision 5)
+++ LICENSE	(revision 5)
@@ -0,0 +1,33 @@
+LEMON code without an explicit copyright is covered by the following
+copyright/license.
+
+Copyright (C) 2003-2007 Egervary Jeno Kombinatorikus Optimalizalasi
+Kutatocsoport (Egervary Combinatorial Optimization Research Group,
+EGRES).
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
+
+===========================================================================
+This license is a verbatim copy of the Boost Software License, Version 1.0.
+
+
Index: Makefile.am
===================================================================
--- Makefile.am	(revision 1)
+++ Makefile.am	(revision 5)
@@ -5,4 +5,5 @@
 
 EXTRA_DIST = \
+	LICENSE \
 	m4/lx_check_cplex.m4 \
 	m4/lx_check_glpk.m4 \
Index: README
===================================================================
--- README	(revision 24)
+++ README	(revision 24)
@@ -0,0 +1,60 @@
+------------------------------------------------------------------
+LEMON - a Library of Efficient Models and Optimization in Networks
+------------------------------------------------------------------
+
+LEMON is the abbreviation of Library of Efficient Models and
+Optimization in Networks. It is an open source library written in
+C++. It provides a set of easy-to-use implementation of common data
+structures and algorithms in the area of optimization and helps
+implementing new ones. It is an especially suitable tool to solve the
+design and optimization problems of telecommunications networks. To
+achieve wide usability, a fundamental design requirement is the
+genericity of interface of data structures and algorithms. LEMON is an
+open source library end invites people all around the world in its
+development.
+
+--------
+Contents
+--------
+
+COPYING, LICENSE
+
+  Copying, distribution and modification conditions and terms.
+
+INSTALL
+
+  For general building and installation instructions, see the file.
+
+lemon/
+
+  Source code of LEMON itself.
+
+doc/
+
+  Documentation of LEMON. The starting page is doc/html/index.html.
+  The documentation installs into the directory
+
+    /usr/local/share/doc/lemon/html
+
+  or -- if you use different prefix -- into
+
+    ${prefix}/share/doc/lemon/html
+
+  (see also INSTALL).
+
+demo/
+
+  Some demonstration programs to make you easier to get familiar with
+  LEMON. Use --enable-demo configure option to also compile these codes
+  (see also INSTALL).
+
+test/
+
+  Contains programs to check the integrity and correctness of
+  LEMON. The command 'make check' performs these tests.
+
+benchmark/
+  
+  Contains programs measuring the performance of LEMON. Use
+  --enable-benchmark configure option to also compile these codes (see
+  also INSTALL).
Index: configure.ac
===================================================================
--- configure.ac	(revision 1)
+++ configure.ac	(revision 21)
@@ -7,6 +7,6 @@
 m4_define([lemon_version_nano], [])
 m4_define([lemon_version_tag], [hg])
-m4_define([lemon_hg_revision], [m4_normalize(esyscmd([hg tip |grep ^changeset |cut -d ':' -f 3]))])
-m4_define([lemon_version], [lemon_version_major().lemon_version_minor()ifelse(lemon_version_micro(), [], [], [.lemon_version_micro()])ifelse(lemon_version_nano(), [], [], [.lemon_version_nano()])ifelse(lemon_version_tag(), [], [], lemon_version_tag(), [hg], [[_]lemon_version_tag()[]lemon_hg_revision()], [[_]lemon_version_tag()])])
+m4_define([lemon_hg_revision], [m4_normalize(esyscmd([hg id -i]))])
+m4_define([lemon_version], [lemon_version_major().lemon_version_minor()ifelse(lemon_version_micro(), [], [], [.lemon_version_micro()])ifelse(lemon_version_nano(), [], [], [.lemon_version_nano()])ifelse(lemon_version_tag(), [], [], lemon_version_tag(), [hg], [[_]lemon_version_tag()[_]lemon_hg_revision()], [[_]lemon_version_tag()])])
 
 AC_PREREQ([2.59])
Index: lemon/Makefile.am
===================================================================
--- lemon/Makefile.am	(revision 25)
+++ lemon/Makefile.am	(revision 32)
@@ -8,5 +8,7 @@
 
 lemon_libemon_la_SOURCES = \
-        lemon/base.cc
+        lemon/base.cc \
+        lemon/random.cc
+
 
 lemon_libemon_la_CXXFLAGS = $(GLPK_CFLAGS) $(CPLEX_CFLAGS) $(SOPLEX_CXXFLAGS)
@@ -14,7 +16,7 @@
 
 lemon_HEADERS += \
-        lemon/concept_check.h \
+        lemon/dim2.h \
+        lemon/random.h \
 	lemon/list_graph.h \
-        lemon/maps.h \
         lemon/tolerance.h
 
@@ -23,4 +25,3 @@
         lemon/bits/utility.h
 
-concept_HEADERS += \
-        lemon/concepts/maps.h
+concept_HEADERS +=
Index: lemon/bits/invalid.h
===================================================================
--- lemon/bits/invalid.h	(revision 7)
+++ lemon/bits/invalid.h	(revision 13)
@@ -25,5 +25,5 @@
 namespace lemon {
 
-  /// \brief Dummy type to make it easier to make invalid iterators.
+  /// \brief Dummy type to make it easier to create invalid iterators.
   ///
   /// See \ref INVALID for the usage.
@@ -35,6 +35,6 @@
   };
   
-  /// Invalid iterators.
-  
+  /// \brief Invalid iterators.
+  ///
   /// \ref Invalid is a global type that converts to each iterator
   /// in such a way that the value of the target iterator will be invalid.
Index: lemon/dim2.h
===================================================================
--- lemon/dim2.h	(revision 15)
+++ lemon/dim2.h	(revision 15)
@@ -0,0 +1,709 @@
+/* -*- C++ -*-
+ *
+ * This file is a part of LEMON, a generic C++ optimization library
+ *
+ * Copyright (C) 2003-2007
+ * 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_DIM2_H
+#define LEMON_DIM2_H
+
+#include <iostream>
+#include <lemon/bits/utility.h>
+
+///\ingroup misc
+///\file
+///\brief A simple two dimensional vector and a bounding box implementation 
+///
+/// The class \ref lemon::dim2::Point "dim2::Point" implements
+///a two dimensional vector with the usual
+/// operations.
+///
+/// The class \ref lemon::dim2::BoundingBox "dim2::BoundingBox"
+/// can be used to determine
+/// the rectangular bounding box of a set of
+/// \ref lemon::dim2::Point "dim2::Point"'s.
+
+namespace lemon {
+
+  ///Tools for handling two dimensional coordinates
+
+  ///This namespace is a storage of several
+  ///tools for handling two dimensional coordinates
+  namespace dim2 {
+
+  /// \addtogroup misc
+  /// @{
+
+  /// A simple two dimensional vector (plainvector) implementation
+
+  /// A simple two dimensional vector (plainvector) implementation
+  ///with the usual vector
+  /// operators.
+  ///
+  template<typename T>
+    class Point {
+
+    public:
+
+      typedef T Value;
+
+      ///First coordinate
+      T x;
+      ///Second coordinate
+      T y;     
+      
+      ///Default constructor
+      Point() {}
+
+      ///Construct an instance from coordinates
+      Point(T a, T b) : x(a), y(b) { }
+
+      ///The dimension of the vector.
+
+      ///The dimension of the vector.
+      ///This function always returns 2. 
+      int size() const { return 2; }
+
+      ///Subscripting operator
+
+      ///\c p[0] is \c p.x and \c p[1] is \c p.y
+      ///
+      T& operator[](int idx) { return idx == 0 ? x : y; }
+
+      ///Const subscripting operator
+
+      ///\c p[0] is \c p.x and \c p[1] is \c p.y
+      ///
+      const T& operator[](int idx) const { return idx == 0 ? x : y; }
+
+      ///Conversion constructor
+      template<class TT> Point(const Point<TT> &p) : x(p.x), y(p.y) {}
+
+      ///Give back the square of the norm of the vector
+      T normSquare() const {
+        return x*x+y*y;
+      }
+  
+      ///Increment the left hand side by u
+      Point<T>& operator +=(const Point<T>& u) {
+        x += u.x;
+        y += u.y;
+        return *this;
+      }
+  
+      ///Decrement the left hand side by u
+      Point<T>& operator -=(const Point<T>& u) {
+        x -= u.x;
+        y -= u.y;
+        return *this;
+      }
+
+      ///Multiply the left hand side with a scalar
+      Point<T>& operator *=(const T &u) {
+        x *= u;
+        y *= u;
+        return *this;
+      }
+
+      ///Divide the left hand side by a scalar
+      Point<T>& operator /=(const T &u) {
+        x /= u;
+        y /= u;
+        return *this;
+      }
+  
+      ///Return the scalar product of two vectors
+      T operator *(const Point<T>& u) const {
+        return x*u.x+y*u.y;
+      }
+  
+      ///Return the sum of two vectors
+      Point<T> operator+(const Point<T> &u) const {
+        Point<T> b=*this;
+        return b+=u;
+      }
+
+      ///Return the negative of the vector
+      Point<T> operator-() const {
+        Point<T> b=*this;
+        b.x=-b.x; b.y=-b.y;
+        return b;
+      }
+
+      ///Return the difference of two vectors
+      Point<T> operator-(const Point<T> &u) const {
+        Point<T> b=*this;
+        return b-=u;
+      }
+
+      ///Return a vector multiplied by a scalar
+      Point<T> operator*(const T &u) const {
+        Point<T> b=*this;
+        return b*=u;
+      }
+
+      ///Return a vector divided by a scalar
+      Point<T> operator/(const T &u) const {
+        Point<T> b=*this;
+        return b/=u;
+      }
+
+      ///Test equality
+      bool operator==(const Point<T> &u) const {
+        return (x==u.x) && (y==u.y);
+      }
+
+      ///Test inequality
+      bool operator!=(Point u) const {
+        return  (x!=u.x) || (y!=u.y);
+      }
+
+    };
+
+  ///Return a Point 
+
+  ///Return a Point.
+  ///\relates Point
+  template <typename T>
+  inline Point<T> makePoint(const T& x, const T& y) {
+    return Point<T>(x, y);
+  }
+
+  ///Return a vector multiplied by a scalar
+
+  ///Return a vector multiplied by a scalar.
+  ///\relates Point
+  template<typename T> Point<T> operator*(const T &u,const Point<T> &x) {
+    return x*u;
+  }
+
+  ///Read a plainvector from a stream
+
+  ///Read a plainvector from a stream.
+  ///\relates Point
+  ///
+  template<typename T>
+  inline std::istream& operator>>(std::istream &is, Point<T> &z) {
+    char c;
+    if (is >> c) {
+      if (c != '(') is.putback(c);
+    } else {
+      is.clear();
+    }
+    if (!(is >> z.x)) return is;
+    if (is >> c) {
+      if (c != ',') is.putback(c);
+    } else {
+      is.clear();
+    }
+    if (!(is >> z.y)) return is;
+    if (is >> c) {
+      if (c != ')') is.putback(c);
+    } else {
+      is.clear();
+    }
+    return is;
+  }
+
+  ///Write a plainvector to a stream
+
+  ///Write a plainvector to a stream.
+  ///\relates Point
+  ///
+  template<typename T>
+  inline std::ostream& operator<<(std::ostream &os, const Point<T>& z)
+  {
+    os << "(" << z.x << ", " << z.y << ")";
+    return os;
+  }
+
+  ///Rotate by 90 degrees
+
+  ///Returns the parameter rotated by 90 degrees in positive direction.
+  ///\relates Point
+  ///
+  template<typename T>
+  inline Point<T> rot90(const Point<T> &z)
+  {
+    return Point<T>(-z.y,z.x);
+  }
+
+  ///Rotate by 180 degrees
+
+  ///Returns the parameter rotated by 180 degrees.
+  ///\relates Point
+  ///
+  template<typename T>
+  inline Point<T> rot180(const Point<T> &z)
+  {
+    return Point<T>(-z.x,-z.y);
+  }
+
+  ///Rotate by 270 degrees
+
+  ///Returns the parameter rotated by 90 degrees in negative direction.
+  ///\relates Point
+  ///
+  template<typename T>
+  inline Point<T> rot270(const Point<T> &z)
+  {
+    return Point<T>(z.y,-z.x);
+  }
+
+  
+
+  /// A class to calculate or store the bounding box of plainvectors.
+
+  /// A class to calculate or store the bounding box of plainvectors.
+  ///
+    template<typename T>
+    class BoundingBox {
+      Point<T> bottom_left, top_right;
+      bool _empty;
+    public:
+      
+      ///Default constructor: creates an empty bounding box
+      BoundingBox() { _empty = true; }
+
+      ///Construct an instance from one point
+      BoundingBox(Point<T> a) { bottom_left=top_right=a; _empty = false; }
+      
+      ///Construct an instance from two points
+      
+      ///Construct an instance from two points.
+      ///\param a The bottom left corner.
+      ///\param b The top right corner.
+      ///\warning The coordinates of the bottom left corner must be no more
+      ///than those of the top right one.
+      BoundingBox(Point<T> a,Point<T> b)
+      {
+	bottom_left=a;
+	top_right=b;
+	_empty = false;
+      }
+      
+      ///Construct an instance from four numbers
+
+      ///Construct an instance from four numbers.
+      ///\param l The left side of the box.
+      ///\param b The bottom of the box.
+      ///\param r The right side of the box.
+      ///\param t The top of the box.
+      ///\warning The left side must be no more than the right side and
+      ///bottom must be no more than the top. 
+      BoundingBox(T l,T b,T r,T t)
+      {
+	bottom_left=Point<T>(l,b);
+	top_right=Point<T>(r,t);
+	_empty = false;
+      }
+      
+      ///Return \c true if the bounding box is empty.
+      
+      ///Return \c true if the bounding box is empty (i.e. return \c false
+      ///if at least one point was added to the box or the coordinates of
+      ///the box were set).
+      ///The coordinates of an empty bounding box are not defined. 
+      bool empty() const {
+        return _empty;
+      }
+      
+      ///Make the BoundingBox empty
+      void clear() {
+        _empty=1;
+      }
+
+      ///Give back the bottom left corner
+
+      ///Give back the bottom left corner.
+      ///If the bounding box is empty, then the return value is not defined.
+      Point<T> bottomLeft() const {
+        return bottom_left;
+      }
+
+      ///Set the bottom left corner
+
+      ///Set the bottom left corner.
+      ///It should only be used for non-empty box.
+      void bottomLeft(Point<T> p) {
+	bottom_left = p;
+      }
+
+      ///Give back the top right corner
+
+      ///Give back the top right corner.
+      ///If the bounding box is empty, then the return value is not defined.
+      Point<T> topRight() const {
+        return top_right;
+      }
+
+      ///Set the top right corner
+
+      ///Set the top right corner.
+      ///It should only be used for non-empty box.
+      void topRight(Point<T> p) {
+	top_right = p;
+      }
+
+      ///Give back the bottom right corner
+
+      ///Give back the bottom right corner.
+      ///If the bounding box is empty, then the return value is not defined.
+      Point<T> bottomRight() const {
+        return Point<T>(top_right.x,bottom_left.y);
+      }
+
+      ///Set the bottom right corner
+
+      ///Set the bottom right corner.
+      ///It should only be used for non-empty box.
+      void bottomRight(Point<T> p) {
+	top_right.x = p.x;
+	bottom_left.y = p.y;
+      }
+ 
+      ///Give back the top left corner
+
+      ///Give back the top left corner.
+      ///If the bounding box is empty, then the return value is not defined.
+      Point<T> topLeft() const {
+        return Point<T>(bottom_left.x,top_right.y);
+      }
+
+      ///Set the top left corner
+
+      ///Set the top left corner.
+      ///It should only be used for non-empty box.
+      void topLeft(Point<T> p) {
+	top_right.y = p.y;
+	bottom_left.x = p.x;
+      }
+
+      ///Give back the bottom of the box
+
+      ///Give back the bottom of the box.
+      ///If the bounding box is empty, then the return value is not defined.
+      T bottom() const {
+        return bottom_left.y;
+      }
+
+      ///Set the bottom of the box
+
+      ///Set the bottom of the box.
+      ///It should only be used for non-empty box.
+      void bottom(T t) {
+	bottom_left.y = t;
+      }
+
+      ///Give back the top of the box
+
+      ///Give back the top of the box.
+      ///If the bounding box is empty, then the return value is not defined.
+      T top() const {
+        return top_right.y;
+      }
+
+      ///Set the top of the box
+
+      ///Set the top of the box.
+      ///It should only be used for non-empty box.
+      void top(T t) {
+	top_right.y = t;
+      }
+
+      ///Give back the left side of the box
+
+      ///Give back the left side of the box.
+      ///If the bounding box is empty, then the return value is not defined.
+      T left() const {
+        return bottom_left.x;
+      }
+ 
+      ///Set the left side of the box
+
+      ///Set the left side of the box.
+      ///It should only be used for non-empty box.
+      void left(T t) {
+	bottom_left.x = t;
+      }
+
+      /// Give back the right side of the box
+
+      /// Give back the right side of the box.
+      ///If the bounding box is empty, then the return value is not defined.
+      T right() const {
+        return top_right.x;
+      }
+
+      ///Set the right side of the box
+
+      ///Set the right side of the box.
+      ///It should only be used for non-empty box.
+      void right(T t) {
+	top_right.x = t;
+      }
+
+      ///Give back the height of the box
+
+      ///Give back the height of the box.
+      ///If the bounding box is empty, then the return value is not defined.
+      T height() const {
+        return top_right.y-bottom_left.y;
+      }
+
+      ///Give back the width of the box
+
+      ///Give back the width of the box.
+      ///If the bounding box is empty, then the return value is not defined.
+      T width() const {
+        return top_right.x-bottom_left.x;
+      }
+
+      ///Checks whether a point is inside a bounding box
+      bool inside(const Point<T>& u) const {
+        if (_empty)
+          return false;
+        else{
+          return ((u.x-bottom_left.x)*(top_right.x-u.x) >= 0 &&
+              (u.y-bottom_left.y)*(top_right.y-u.y) >= 0 );
+        }
+      }
+  
+      ///Increments a bounding box with a point
+
+      ///Increments a bounding box with a point.
+      ///
+      BoundingBox& add(const Point<T>& u){
+        if (_empty){
+          bottom_left=top_right=u;
+          _empty = false;
+        }
+        else{
+          if (bottom_left.x > u.x) bottom_left.x = u.x;
+          if (bottom_left.y > u.y) bottom_left.y = u.y;
+          if (top_right.x < u.x) top_right.x = u.x;
+          if (top_right.y < u.y) top_right.y = u.y;
+        }
+        return *this;
+      }
+    
+      ///Increments a bounding box to contain another bounding box
+      
+      ///Increments a bounding box to contain another bounding box.
+      ///
+      BoundingBox& add(const BoundingBox &u){
+        if ( !u.empty() ){
+          this->add(u.bottomLeft());
+	  this->add(u.topRight());
+        }
+        return *this;
+      }
+  
+      ///Intersection of two bounding boxes
+
+      ///Intersection of two bounding boxes.
+      ///
+      BoundingBox operator&(const BoundingBox& u) const {
+        BoundingBox b;
+        if (this->_empty || u._empty) {
+	  b._empty = true;
+	} else {
+	  b.bottom_left.x = std::max(this->bottom_left.x,u.bottom_left.x);
+	  b.bottom_left.y = std::max(this->bottom_left.y,u.bottom_left.y);
+	  b.top_right.x = std::min(this->top_right.x,u.top_right.x);
+	  b.top_right.y = std::min(this->top_right.y,u.top_right.y);
+	  b._empty = b.bottom_left.x > b.top_right.x ||
+	             b.bottom_left.y > b.top_right.y;
+	} 
+        return b;
+      }
+
+    };//class Boundingbox
+
+
+  ///Map of x-coordinates of a \ref Point "Point"-map
+
+  ///\ingroup maps
+  ///Map of x-coordinates of a \ref Point "Point"-map.
+  ///
+  template<class M>
+  class XMap 
+  {
+    M& _map;
+  public:
+
+    typedef typename M::Value::Value Value;
+    typedef typename M::Key Key;
+    ///\e
+    XMap(M& map) : _map(map) {}
+    Value operator[](Key k) const {return _map[k].x;}
+    void set(Key k,Value v) {_map.set(k,typename M::Value(v,_map[k].y));}
+  };
+    
+  ///Returns an \ref XMap class
+
+  ///This function just returns an \ref XMap class.
+  ///
+  ///\ingroup maps
+  ///\relates XMap
+  template<class M> 
+  inline XMap<M> xMap(M &m) 
+  {
+    return XMap<M>(m);
+  }
+
+  template<class M> 
+  inline XMap<M> xMap(const M &m) 
+  {
+    return XMap<M>(m);
+  }
+
+  ///Constant (read only) version of \ref XMap
+
+  ///\ingroup maps
+  ///Constant (read only) version of \ref XMap
+  ///
+  template<class M>
+  class ConstXMap 
+  {
+    const M& _map;
+  public:
+
+    typedef typename M::Value::Value Value;
+    typedef typename M::Key Key;
+    ///\e
+    ConstXMap(const M &map) : _map(map) {}
+    Value operator[](Key k) const {return _map[k].x;}
+  };
+    
+  ///Returns a \ref ConstXMap class
+
+  ///This function just returns a \ref ConstXMap class.
+  ///
+  ///\ingroup maps
+  ///\relates ConstXMap
+  template<class M> 
+  inline ConstXMap<M> xMap(const M &m) 
+  {
+    return ConstXMap<M>(m);
+  }
+
+  ///Map of y-coordinates of a \ref Point "Point"-map
+    
+  ///\ingroup maps
+  ///Map of y-coordinates of a \ref Point "Point"-map.
+  ///
+  template<class M>
+  class YMap 
+  {
+    M& _map;
+  public:
+
+    typedef typename M::Value::Value Value;
+    typedef typename M::Key Key;
+    ///\e
+    YMap(M& map) : _map(map) {}
+    Value operator[](Key k) const {return _map[k].y;}
+    void set(Key k,Value v) {_map.set(k,typename M::Value(_map[k].x,v));}
+  };
+
+  ///Returns a \ref YMap class
+
+  ///This function just returns a \ref YMap class.
+  ///
+  ///\ingroup maps
+  ///\relates YMap
+  template<class M> 
+  inline YMap<M> yMap(M &m) 
+  {
+    return YMap<M>(m);
+  }
+
+  template<class M> 
+  inline YMap<M> yMap(const M &m) 
+  {
+    return YMap<M>(m);
+  }
+
+  ///Constant (read only) version of \ref YMap
+
+  ///\ingroup maps
+  ///Constant (read only) version of \ref YMap
+  ///
+  template<class M>
+  class ConstYMap 
+  {
+    const M& _map;
+  public:
+
+    typedef typename M::Value::Value Value;
+    typedef typename M::Key Key;
+    ///\e
+    ConstYMap(const M &map) : _map(map) {}
+    Value operator[](Key k) const {return _map[k].y;}
+  };
+    
+  ///Returns a \ref ConstYMap class
+
+  ///This function just returns a \ref ConstYMap class.
+  ///
+  ///\ingroup maps
+  ///\relates ConstYMap
+  template<class M> 
+  inline ConstYMap<M> yMap(const M &m) 
+  {
+    return ConstYMap<M>(m);
+  }
+
+
+    ///\brief Map of the \ref Point::normSquare() "normSquare()"
+    ///of a \ref Point "Point"-map
+    ///
+    ///Map of the \ref Point::normSquare() "normSquare()"
+    ///of a \ref Point "Point"-map.
+    ///\ingroup maps
+    ///
+  template<class M>
+  class NormSquareMap 
+  {
+    const M& _map;
+  public:
+
+    typedef typename M::Value::Value Value;
+    typedef typename M::Key Key;
+    ///\e
+    NormSquareMap(const M &map) : _map(map) {}
+    Value operator[](Key k) const {return _map[k].normSquare();}
+  };
+    
+  ///Returns a \ref NormSquareMap class
+
+  ///This function just returns a \ref NormSquareMap class.
+  ///
+  ///\ingroup maps
+  ///\relates NormSquareMap
+  template<class M> 
+  inline NormSquareMap<M> normSquareMap(const M &m) 
+  {
+    return NormSquareMap<M>(m);
+  }
+
+  /// @}
+
+  } //namespce dim2
+  
+} //namespace lemon
+
+#endif //LEMON_DIM2_H
Index: lemon/maps.h
===================================================================
--- lemon/maps.h	(revision 26)
+++ lemon/maps.h	(revision 34)
@@ -45,7 +45,7 @@
   class MapBase {
   public:
-    ///\e
+    /// The key type of the map.
     typedef K Key;
-    ///\e
+    /// The value type of the map. (The type of objects associated with the keys).
     typedef T Value;
   };
@@ -53,7 +53,8 @@
   /// Null map. (a.k.a. DoNothingMap)
 
-  /// 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 will sent to <tt>/dev/null</tt>...
+  /// 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 
+  /// <tt>/dev/null</tt>).
   template<typename K, typename T>
   class NullMap : public MapBase<K, T> {
@@ -69,4 +70,8 @@
   };
 
+  ///Returns a \c NullMap class
+
+  ///This function just returns a \c NullMap class.
+  ///\relates NullMap
   template <typename K, typename V> 
   NullMap<K, V> nullMap() {
@@ -91,11 +96,13 @@
     /// Default constructor
 
+    /// Default constructor.
     /// The value of the map will be uninitialized. 
     /// (More exactly it will be default constructed.)
     ConstMap() {}
-    ///\e
-
-    /// \param _v The initial value of the map.
-    ///
+    
+    /// 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) {}
     
@@ -159,6 +166,6 @@
   ///Map based on std::map
 
-  ///This is essentially a wrapper for \c std::map. With addition that
-  ///you can specify a default value different from \c Value() .
+  ///This is essentially a wrapper for \c std::map with addition that
+  ///you can specify a default value different from \c Value().
   template <typename K, typename T, typename Compare = std::less<K> >
   class StdMap {
@@ -243,7 +250,7 @@
   };
 
-  /// \brief Map for storing values for the range \c [0..size-1] range keys
-  ///
-  /// The current map has the \c [0..size-1] keyset and the values
+  /// \brief Map for storing values for keys from the range <tt>[0..size-1]</tt>
+  ///
+  /// The current 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 
@@ -322,7 +329,7 @@
   /// @{
 
-  /// \brief Identity mapping.
-  ///
-  /// This mapping gives back the given key as value without any
+  /// \brief Identity map.
+  ///
+  /// This map gives back the given key as value without any
   /// modification. 
   template <typename T>
@@ -353,5 +360,5 @@
   ///
   ///This \c concepts::ReadMap "read only map"
-  ///converts the \c Value of a maps to type \c T.
+  ///converts the \c Value of a map to type \c T.
   ///Its \c Key is inherited from \c M.
   template <typename M, typename T> 
@@ -365,6 +372,6 @@
     ///Constructor
 
-    ///Constructor
-    ///\param _m is the underlying map
+    ///Constructor.
+    ///\param _m is the underlying map.
     ConvertMap(const M &_m) : m(_m) {};
 
@@ -375,7 +382,7 @@
   };
   
-  ///Returns an \c ConvertMap class
-
-  ///This function just returns an \c ConvertMap class.
+  ///Returns a \c ConvertMap class
+
+  ///This function just returns a \c ConvertMap class.
   ///\relates ConvertMap
   template<typename T, typename M>
@@ -384,5 +391,5 @@
   }
 
-  ///Simple wrapping of the map
+  ///Simple wrapping of a map
 
   ///This \c concepts::ReadMap "read only map" returns the simple
@@ -391,5 +398,7 @@
   ///map to simple read map.
   ///
-  /// \todo Revise the misleading name
+  ///\sa SimpleWriteMap
+  ///
+  /// \todo Revise the misleading name 
   template<typename M> 
   class SimpleMap : public MapBase<typename M::Key, typename M::Value> {
@@ -407,5 +416,5 @@
   };
 
-  ///Simple writeable wrapping of the map
+  ///Simple writable wrapping of the map
 
   ///This \c concepts::WriteMap "write map" returns the simple
@@ -414,4 +423,6 @@
   ///given map to simple read-write map.
   ///
+  ///\sa SimpleMap
+  ///
   /// \todo Revise the misleading name
   template<typename M> 
@@ -435,7 +446,7 @@
 
   ///This \c concepts::ReadMap "read only map" returns the sum of the two
-  ///given maps. Its \c Key and \c Value will be inherited from \c M1.
+  ///given maps.
+  ///Its \c Key and \c Value are inherited from \c M1.
   ///The \c Key and \c Value of M2 must be convertible to those of \c M1.
-
   template<typename M1, typename M2> 
   class AddMap : public MapBase<typename M1::Key, typename M1::Value> {
@@ -469,5 +480,5 @@
   ///This \c concepts::ReadMap "read only map" returns the sum of the
   ///given map and a constant value.
-  ///Its \c Key and \c Value is inherited from \c M.
+  ///Its \c Key and \c Value are inherited from \c M.
   ///
   ///Actually,
@@ -475,9 +486,11 @@
   ///  ShiftMap<X> sh(x,v);
   ///\endcode
-  ///is equivalent with
+  ///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> {
@@ -491,7 +504,7 @@
     ///Constructor
 
-    ///Constructor
-    ///\param _m is the undelying map
-    ///\param _v is the shift value
+    ///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
@@ -499,19 +512,11 @@
   };
 
-  ///Shift a map with a constant. This map is also writable.
+  ///Shift a map with a constant (ReadWrite version).
 
   ///This \c 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 is inherited from \c M.
-  ///
-  ///Actually,
-  ///\code
-  ///  ShiftMap<X> sh(x,v);
-  ///\endcode
-  ///is equivalent with
-  ///\code
-  ///  ConstMap<X::Key, X::Value> c_tmp(v);
-  ///  AddMap<X, ConstMap<X::Key, X::Value> > sh(x,v);
-  ///\endcode
+  ///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> {
@@ -525,7 +530,7 @@
     ///Constructor
 
-    ///Constructor
-    ///\param _m is the undelying map
-    ///\param _v is the shift value
+    ///Constructor.
+    ///\param _m is the undelying map.
+    ///\param _v is the shift value.
     ShiftWriteMap(M &_m, const C &_v ) : m(_m), v(_v) {};
     /// \e
@@ -535,7 +540,7 @@
   };
   
-  ///Returns an \c ShiftMap class
-
-  ///This function just returns an \c ShiftMap class.
+  ///Returns a \c ShiftMap class
+
+  ///This function just returns a \c ShiftMap class.
   ///\relates ShiftMap
   template<typename M, typename C> 
@@ -544,4 +549,8 @@
   }
 
+  ///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) {
@@ -552,6 +561,6 @@
 
   ///This \c concepts::ReadMap "read only map" returns the difference
-  ///of the values of the two
-  ///given maps. Its \c Key and \c Value will be inherited from \c M1.
+  ///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.
   ///
@@ -585,9 +594,7 @@
 
   ///This \c concepts::ReadMap "read only map" returns the product of the
-  ///values of the two
-  ///given
-  ///maps. Its \c Key and \c Value will be inherited from \c M1.
+  ///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> 
   class MulMap : public MapBase<typename M1::Key, typename M1::Value> {
@@ -614,9 +621,9 @@
   }
  
-  ///Scales a maps with a constant.
+  ///Scales a map with a constant.
 
   ///This \c 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 is inherited from \c M.
+  ///Its \c Key and \c Value are inherited from \c M.
   ///
   ///Actually,
@@ -624,9 +631,11 @@
   ///  ScaleMap<X> sc(x,v);
   ///\endcode
-  ///is equivalent with
+  ///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> {
@@ -640,7 +649,7 @@
     ///Constructor
 
-    ///Constructor
-    ///\param _m is the undelying map
-    ///\param _v is the scaling value
+    ///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
@@ -648,10 +657,13 @@
   };
 
-  ///Scales a maps with a constant (ReadWrite version).
+  ///Scales a map with a constant (ReadWrite version).
 
   ///This \c concepts::ReadWriteMap "read-write map" returns the value of the
   ///given map multiplied from the left side with a constant value. It can
-  ///be used as write map also if the given multiplier is not zero.
-  ///Its \c Key and \c Value is inherited from \c M.
+  ///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> {
@@ -665,7 +677,7 @@
     ///Constructor
 
-    ///Constructor
-    ///\param _m is the undelying map
-    ///\param _v is the scaling value
+    ///Constructor.
+    ///\param _m is the undelying map.
+    ///\param _v is the scaling value.
     ScaleWriteMap(M &_m, const C &_v ) : m(_m), v(_v) {};
     /// \e
@@ -675,7 +687,7 @@
   };
   
-  ///Returns an \c ScaleMap class
-
-  ///This function just returns an \c ScaleMap class.
+  ///Returns a \c ScaleMap class
+
+  ///This function just returns a \c ScaleMap class.
   ///\relates ScaleMap
   template<typename M, typename C> 
@@ -684,4 +696,8 @@
   }
 
+  ///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) {
@@ -692,8 +708,7 @@
 
   ///This \c concepts::ReadMap "read only map" returns the quotient of the
-  ///values of the two
-  ///given maps. Its \c Key and \c Value will be inherited from \c M1.
+  ///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> 
   class DivMap : public MapBase<typename M1::Key, typename M1::Value> {
@@ -723,16 +738,17 @@
 
   ///This \c 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,
+  ///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.
-  ///The \c M2::Value must be convertible to \c M1::Key.
+  /// <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> 
@@ -758,8 +774,8 @@
     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> 
@@ -768,25 +784,25 @@
   }
   
-  ///Combines of two maps using an STL (binary) functor.
-
-  ///Combines of two maps using an STL (binary) functor.
-  ///
+  ///Combine of two maps using an STL (binary) functor.
+
+  ///Combine of two maps using an STL (binary) functor.
   ///
   ///This \c concepts::ReadMap "read only map" takes two maps and a
-  ///binary functor and returns the composition of
-  ///the two
+  ///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
+  ///and \c f is of \c F, then for
   ///\code
-  ///  CombineMap<M1, M2,F,V> cm(m1,m2,f);
+  ///  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.
-  ///The \c M2::Value and \c M1::Value must be convertible to the corresponding
+  ///\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,
@@ -814,7 +830,7 @@
   ///For example if \c m1 and \c m2 are both \c double valued maps, then 
   ///\code
-  ///combineMap<double>(m1,m2,std::plus<double>())
+  ///combineMap(m1,m2,std::plus<double>())
   ///\endcode
-  ///is equivalent with
+  ///is equivalent to
   ///\code
   ///addMap(m1,m2)
@@ -822,5 +838,5 @@
   ///
   ///This function is specialized for adaptable binary function
-  ///classes and c++ functions.
+  ///classes and C++ functions.
   ///
   ///\relates CombineMap
@@ -846,9 +862,9 @@
 
   ///This \c concepts::ReadMap "read only map" returns the negative
-  ///value of the
-  ///value returned by the
-  ///given map. Its \c Key and \c Value will be inherited from \c M.
+  ///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> 
   class NegMap : public MapBase<typename M::Key, typename M::Value> {
@@ -868,8 +884,9 @@
 
   ///This \c concepts::ReadWriteMap "read-write map" returns the negative
-  ///value of the value returned by the
-  ///given map. Its \c Key and \c Value will be inherited from \c M.
+  ///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 NegMap
   template<typename M> 
   class NegWriteMap : public MapBase<typename M::Key, typename M::Value> {
@@ -897,4 +914,8 @@
   }
 
+  ///Returns a \c NegWriteMap class
+
+  ///This function just returns a \c NegWriteMap class.
+  ///\relates NegWriteMap
   template <typename M> 
   inline NegWriteMap<M> negMap(M &m) {
@@ -905,12 +926,8 @@
 
   ///This \c concepts::ReadMap "read only map" returns the absolute value
-  ///of the
-  ///value returned by the
-  ///given map. Its \c Key and \c Value will be inherited
-  ///from <tt>M</tt>. <tt>Value</tt>
-  ///must be comparable to <tt>0</tt> and the unary <tt>-</tt>
+  ///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> 
   class AbsMap : public MapBase<typename M::Key, typename M::Value> {
@@ -931,7 +948,7 @@
   };
   
-  ///Returns a \c AbsMap class
-
-  ///This function just returns a \c AbsMap class.
+  ///Returns an \c AbsMap class
+
+  ///This function just returns an \c AbsMap class.
   ///\relates AbsMap
   template<typename M> 
@@ -943,12 +960,14 @@
 
   ///This \c concepts::ReadMap "read only map" returns the value
-  ///of a
-  ///given map.
+  ///of a given functor.
   ///
   ///Template parameters \c K and \c V will become its
-  ///\c Key and \c Value. They must be given explicitely
-  ///because a functor does not provide such typedefs.
+  ///\c Key and \c Value. 
+  ///In most cases they have to be given explicitly because a 
+  ///functor typically does not provide such typedefs.
   ///
   ///Parameter \c F is the type of the used functor.
+  ///
+  ///\sa MapFunctor
   template<typename F, 
 	   typename K = typename F::argument_type, 
@@ -972,5 +991,5 @@
   ///
   ///It is specialized for adaptable function classes and
-  ///c++ functions.
+  ///C++ functions.
   ///\relates FunctorMap
   template<typename K, typename V, typename F> inline 
@@ -1000,4 +1019,6 @@
   ///a ususal \c 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> {
@@ -1034,6 +1055,8 @@
   ///first map. This class is the just readable map type of the ForkWriteMap.
   ///
-  ///The \c Key and \c Value will be inherited from \c M1.
+  ///The \c Key and \c Value are inherited from \c M1.
   ///The \c Key and \c Value of M2 must be convertible from those of \c M1.
+  ///
+  ///\sa ForkWriteMap
   ///
   /// \todo Why is it needed?
@@ -1062,6 +1085,8 @@
   ///corresponding values of \c M1.
   ///
-  ///The \c Key and \c Value will be inherited from \c M1.
+  ///The \c Key and \c Value are inherited from \c M1.
   ///The \c Key and \c Value of 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> {
@@ -1081,8 +1106,7 @@
   };
   
-  ///Returns an \c ForkMap class
-
-  ///This function just returns an \c ForkMap class.
-  ///
+  ///Returns a \c ForkMap class
+
+  ///This function just returns a \c ForkMap class.
   ///\relates ForkMap
   template <typename M1, typename M2> 
@@ -1091,4 +1115,8 @@
   }
 
+  ///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) {
@@ -1103,8 +1131,8 @@
   
   ///This bool \c concepts::ReadMap "read only map" returns the 
-  ///logical negation of
-  ///value returned by the
-  ///given map. Its \c Key and will be inherited from \c M,
-  ///its Value is <tt>bool</tt>.
+  ///logical negation of the value returned by the given map.
+  ///Its \c Key is inherited from \c M, its Value is \c bool.
+  ///
+  ///\sa NotWriteMap
   template <typename M> 
   class NotMap : public MapBase<typename M::Key, bool> {
@@ -1124,8 +1152,9 @@
   
   ///This bool \c concepts::ReadWriteMap "read-write map" returns the 
-  ///logical negation of value returned by the given map. When it is set,
+  ///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 and will be inherited from \c M,
-  ///its Value is <tt>bool</tt>.
+  ///Its \c Key is inherited from \c M, its Value is \c bool.
+  ///
+  ///\sa NotMap
   template <typename M> 
   class NotWriteMap : public MapBase<typename M::Key, bool> {
@@ -1153,4 +1182,8 @@
   }
   
+  ///Returns a \c NotWriteMap class
+  
+  ///This function just returns a \c NotWriteMap class.
+  ///\relates NotWriteMap
   template <typename M> 
   inline NotWriteMap<M> notMap(M &m) {
@@ -1184,8 +1217,8 @@
   
 
-  /// \brief Writable bool map for logging each true assigned elements
-  ///
-  /// Writable bool map for logging each true assigned elements, i.e it
-  /// copies all the keys set to true to the given iterator.
+  /// \brief Writable bool map for logging each \c true assigned element
+  ///
+  /// Writable 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 
@@ -1208,5 +1241,9 @@
   ///\endcode
   ///
-  ///\todo Revise the name of this class and the relates ones.
+  ///\sa BackInserterBoolMap 
+  ///\sa FrontInserterBoolMap 
+  ///\sa InserterBoolMap 
+  ///
+  ///\todo Revise the name of this class and the related ones.
   template <typename _Iterator, 
             typename _Functor =
@@ -1236,5 +1273,5 @@
     }
 
-    /// Setter function of the map
+    /// The \c set function of the map
     void set(const Key& key, Value value) const {
       if (value) {
@@ -1249,9 +1286,9 @@
   };
 
-  /// \brief Writable bool map for logging each true assigned elements in 
-  /// a back insertable container
-  ///
-  /// Writable bool map for logging each true assigned elements by pushing
-  /// back them into a back insertable container.
+  /// \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
@@ -1263,4 +1300,8 @@
   /// prim(graph, cost, inserter_map);
   ///\endcode
+  ///
+  ///\sa StoreBoolMap
+  ///\sa FrontInserterBoolMap
+  ///\sa InserterBoolMap
   template <typename Container,
             typename Functor =
@@ -1268,5 +1309,5 @@
   class BackInserterBoolMap {
   public:
-    typedef typename Container::value_type Key;
+    typedef typename Functor::argument_type Key;
     typedef bool Value;
 
@@ -1276,5 +1317,5 @@
       : container(_container), functor(_functor) {}
 
-    /// Setter function of the map
+    /// The \c set function of the map
     void set(const Key& key, Value value) {
       if (value) {
@@ -1288,10 +1329,14 @@
   };
 
-  /// \brief Writable bool map for storing each true assignments in 
+  /// \brief Writable bool map for logging each \c true assigned element in 
   /// a front insertable container.
   ///
-  /// Writable bool map for storing each true assignment in a front 
-  /// insertable container. It will push front all the keys set to \c true into
-  /// the container. For example see the BackInserterBoolMap.
+  /// 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 =
@@ -1299,5 +1344,5 @@
   class FrontInserterBoolMap {
   public:
-    typedef typename Container::value_type Key;
+    typedef typename Functor::argument_type Key;
     typedef bool Value;
 
@@ -1307,8 +1352,8 @@
       : container(_container), functor(_functor) {}
 
-    /// Setter function of the map
+    /// The \c set function of the map
     void set(const Key& key, Value value) {
       if (value) {
-	container.push_front(key);
+	container.push_front(functor(key));
       }
     }
@@ -1319,8 +1364,8 @@
   };
 
-  /// \brief Writable bool map for storing each true assigned elements in 
+  /// \brief Writable bool map for storing each \c true assigned element in 
   /// an insertable container.
   ///
-  /// Writable bool map for storing each true assigned elements in an 
+  /// 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.
@@ -1334,4 +1379,7 @@
   /// stronglyConnectedCutArcs(digraph, cost, inserter_map);
   ///\endcode
+  ///
+  ///\sa BackInserterBoolMap
+  ///\sa FrontInserterBoolMap
   template <typename Container,
             typename Functor =
@@ -1342,5 +1390,10 @@
     typedef bool Value;
 
-    /// Constructor
+    /// 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()) 
@@ -1348,11 +1401,16 @@
 
     /// 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) {}
 
-    /// Setter function of the map
+    /// The \c set function of the map
     void set(const Key& key, Value value) {
       if (value) {
-	it = container.insert(it, key);
+	it = container.insert(it, functor(key));
         ++it;
       }
@@ -1365,9 +1423,9 @@
   };
 
-  /// \brief Fill the true set elements with a given value.
-  ///
-  /// Writable bool map to fill the elements set to \c true with a given value.
-  /// The value can set 
-  /// the container.
+  /// \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
@@ -1419,5 +1477,5 @@
     } 
 
-    /// Set function of the map
+    /// The \c set function of the map
     void set(const Key& key, Value value) {
       if (value) {
@@ -1432,8 +1490,8 @@
 
 
-  /// \brief Writable bool map which stores the sequence number of 
-  /// true assignments.  
+  /// \brief Writable bool map for storing the sequence number of 
+  /// \c true assignments.  
   /// 
-  /// Writable bool map which stores for each true assigned elements  
+  /// 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
Index: lemon/random.cc
===================================================================
--- lemon/random.cc	(revision 16)
+++ lemon/random.cc	(revision 16)
@@ -0,0 +1,29 @@
+/* -*- C++ -*-
+ *
+ * This file is a part of LEMON, a generic C++ optimization library
+ *
+ * Copyright (C) 2003-2007
+ * 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.
+ *
+ */
+
+///\file
+///\brief Instantiation of the Random class.
+
+#include <lemon/random.h>
+
+namespace lemon {
+  /// \brief Global random number generator instance
+  ///
+  /// A global Mersenne Twister random number generator instance.
+  Random rnd;
+}
Index: lemon/random.h
===================================================================
--- lemon/random.h	(revision 23)
+++ lemon/random.h	(revision 23)
@@ -0,0 +1,872 @@
+/* -*- C++ -*-
+ *
+ * This file is a part of LEMON, a generic C++ optimization library
+ *
+ * Copyright (C) 2003-2007
+ * 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.
+ *
+ */
+
+/*
+ * This file contains the reimplemented version of the Mersenne Twister
+ * Generator of Matsumoto and Nishimura.
+ *
+ * See the appropriate copyright notice below.
+ * 
+ * Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
+ * All rights reserved.                          
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * 3. The names of its contributors may not be used to endorse or promote 
+ *    products derived from this software without specific prior written 
+ *    permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *
+ * Any feedback is very welcome.
+ * http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html
+ * email: m-mat @ math.sci.hiroshima-u.ac.jp (remove space)
+ */
+
+#ifndef LEMON_RANDOM_H
+#define LEMON_RANDOM_H
+
+#include <algorithm>
+#include <iterator>
+#include <vector>
+
+#include <ctime>
+#include <cmath>
+
+#include <lemon/dim2.h>
+///\ingroup misc
+///\file
+///\brief Mersenne Twister random number generator
+
+namespace lemon {
+
+  namespace _random_bits {
+    
+    template <typename _Word, int _bits = std::numeric_limits<_Word>::digits>
+    struct RandomTraits {};
+
+    template <typename _Word>
+    struct RandomTraits<_Word, 32> {
+
+      typedef _Word Word;
+      static const int bits = 32;
+
+      static const int length = 624;
+      static const int shift = 397;
+      
+      static const Word mul = 0x6c078965u;
+      static const Word arrayInit = 0x012BD6AAu;
+      static const Word arrayMul1 = 0x0019660Du;
+      static const Word arrayMul2 = 0x5D588B65u;
+
+      static const Word mask = 0x9908B0DFu;
+      static const Word loMask = (1u << 31) - 1;
+      static const Word hiMask = ~loMask;
+
+
+      static Word tempering(Word rnd) {
+        rnd ^= (rnd >> 11);
+        rnd ^= (rnd << 7) & 0x9D2C5680u;
+        rnd ^= (rnd << 15) & 0xEFC60000u;
+        rnd ^= (rnd >> 18);
+        return rnd;
+      }
+
+    };
+
+    template <typename _Word>
+    struct RandomTraits<_Word, 64> {
+
+      typedef _Word Word;
+      static const int bits = 64;
+
+      static const int length = 312;
+      static const int shift = 156;
+
+      static const Word mul = Word(0x5851F42Du) << 32 | Word(0x4C957F2Du);
+      static const Word arrayInit = Word(0x00000000u) << 32 |Word(0x012BD6AAu);
+      static const Word arrayMul1 = Word(0x369DEA0Fu) << 32 |Word(0x31A53F85u);
+      static const Word arrayMul2 = Word(0x27BB2EE6u) << 32 |Word(0x87B0B0FDu);
+
+      static const Word mask = Word(0xB5026F5Au) << 32 | Word(0xA96619E9u);
+      static const Word loMask = (Word(1u) << 31) - 1;
+      static const Word hiMask = ~loMask;
+
+      static Word tempering(Word rnd) {
+        rnd ^= (rnd >> 29) & (Word(0x55555555u) << 32 | Word(0x55555555u));
+        rnd ^= (rnd << 17) & (Word(0x71D67FFFu) << 32 | Word(0xEDA60000u));
+        rnd ^= (rnd << 37) & (Word(0xFFF7EEE0u) << 32 | Word(0x00000000u));
+        rnd ^= (rnd >> 43);
+        return rnd;
+      }
+
+    };
+
+    template <typename _Word>
+    class RandomCore {
+    public:
+
+      typedef _Word Word;
+
+    private:
+
+      static const int bits = RandomTraits<Word>::bits;
+
+      static const int length = RandomTraits<Word>::length;
+      static const int shift = RandomTraits<Word>::shift;
+
+    public:
+
+      void initState() {
+        static const Word seedArray[4] = {
+          0x12345u, 0x23456u, 0x34567u, 0x45678u
+        };
+    
+        initState(seedArray, seedArray + 4);
+      }
+
+      void initState(Word seed) {
+
+        static const Word mul = RandomTraits<Word>::mul;
+
+        current = state; 
+
+        Word *curr = state + length - 1;
+        curr[0] = seed; --curr;
+        for (int i = 1; i < length; ++i) {
+          curr[0] = (mul * ( curr[1] ^ (curr[1] >> (bits - 2)) ) + i);
+          --curr;
+        }
+      }
+
+      template <typename Iterator>
+      void initState(Iterator begin, Iterator end) {
+
+        static const Word init = RandomTraits<Word>::arrayInit;
+        static const Word mul1 = RandomTraits<Word>::arrayMul1;
+        static const Word mul2 = RandomTraits<Word>::arrayMul2;
+
+
+        Word *curr = state + length - 1; --curr;
+        Iterator it = begin; int cnt = 0;
+        int num;
+
+        initState(init);
+
+        num = length > end - begin ? length : end - begin;
+        while (num--) {
+          curr[0] = (curr[0] ^ ((curr[1] ^ (curr[1] >> (bits - 2))) * mul1)) 
+            + *it + cnt;
+          ++it; ++cnt;
+          if (it == end) {
+            it = begin; cnt = 0;
+          }
+          if (curr == state) {
+            curr = state + length - 1; curr[0] = state[0];
+          }
+          --curr;
+        }
+
+        num = length - 1; cnt = length - (curr - state) - 1;
+        while (num--) {
+          curr[0] = (curr[0] ^ ((curr[1] ^ (curr[1] >> (bits - 2))) * mul2))
+            - cnt;
+          --curr; ++cnt;
+          if (curr == state) {
+            curr = state + length - 1; curr[0] = state[0]; --curr;
+            cnt = 1;
+          }
+        }
+        
+        state[length - 1] = Word(1) << (bits - 1);
+      }
+      
+      void copyState(const RandomCore& other) {
+        std::copy(other.state, other.state + length, state);
+        current = state + (other.current - other.state);
+      }
+
+      Word operator()() {
+        if (current == state) fillState();
+        --current;
+        Word rnd = *current;
+        return RandomTraits<Word>::tempering(rnd);
+      }
+
+    private:
+
+  
+      void fillState() {
+        static const Word mask[2] = { 0x0ul, RandomTraits<Word>::mask };
+        static const Word loMask = RandomTraits<Word>::loMask;
+        static const Word hiMask = RandomTraits<Word>::hiMask;
+
+        current = state + length; 
+
+        register Word *curr = state + length - 1;
+        register long num;
+      
+        num = length - shift;
+        while (num--) {
+          curr[0] = (((curr[0] & hiMask) | (curr[-1] & loMask)) >> 1) ^
+            curr[- shift] ^ mask[curr[-1] & 1ul];
+          --curr;
+        }
+        num = shift - 1;
+        while (num--) {
+          curr[0] = (((curr[0] & hiMask) | (curr[-1] & loMask)) >> 1) ^
+            curr[length - shift] ^ mask[curr[-1] & 1ul];
+          --curr;
+        }
+        curr[0] = (((curr[0] & hiMask) | (curr[length - 1] & loMask)) >> 1) ^
+          curr[length - shift] ^ mask[curr[length - 1] & 1ul];
+
+      }
+
+  
+      Word *current;
+      Word state[length];
+      
+    };
+
+
+    template <typename Result, 
+              int shift = (std::numeric_limits<Result>::digits + 1) / 2>
+    struct Masker {
+      static Result mask(const Result& result) {
+        return Masker<Result, (shift + 1) / 2>::
+          mask(static_cast<Result>(result | (result >> shift)));
+      }
+    };
+    
+    template <typename Result>
+    struct Masker<Result, 1> {
+      static Result mask(const Result& result) {
+        return static_cast<Result>(result | (result >> 1));
+      }
+    };
+
+    template <typename Result, typename Word, 
+              int rest = std::numeric_limits<Result>::digits, int shift = 0, 
+              bool last = rest <= std::numeric_limits<Word>::digits>
+    struct IntConversion {
+      static const int bits = std::numeric_limits<Word>::digits;
+    
+      static Result convert(RandomCore<Word>& rnd) {
+        return static_cast<Result>(rnd() >> (bits - rest)) << shift;
+      }
+      
+    }; 
+
+    template <typename Result, typename Word, int rest, int shift> 
+    struct IntConversion<Result, Word, rest, shift, false> {
+      static const int bits = std::numeric_limits<Word>::digits;
+
+      static Result convert(RandomCore<Word>& rnd) {
+        return (static_cast<Result>(rnd()) << shift) | 
+          IntConversion<Result, Word, rest - bits, shift + bits>::convert(rnd);
+      }
+    };
+
+
+    template <typename Result, typename Word,
+              bool one_word = (std::numeric_limits<Word>::digits < 
+			       std::numeric_limits<Result>::digits) >
+    struct Mapping {
+      static Result map(RandomCore<Word>& rnd, const Result& bound) {
+        Word max = Word(bound - 1);
+        Result mask = Masker<Result>::mask(bound - 1);
+        Result num;
+        do {
+          num = IntConversion<Result, Word>::convert(rnd) & mask; 
+        } while (num > max);
+        return num;
+      }
+    };
+
+    template <typename Result, typename Word>
+    struct Mapping<Result, Word, false> {
+      static Result map(RandomCore<Word>& rnd, const Result& bound) {
+        Word max = Word(bound - 1);
+        Word mask = Masker<Word, (std::numeric_limits<Result>::digits + 1) / 2>
+          ::mask(max);
+        Word num;
+        do {
+          num = rnd() & mask;
+        } while (num > max);
+        return num;
+      }
+    };
+
+    template <typename Result, int exp, bool pos = (exp >= 0)>
+    struct ShiftMultiplier {
+      static const Result multiplier() {
+        Result res = ShiftMultiplier<Result, exp / 2>::multiplier();
+        res *= res;
+        if ((exp & 1) == 1) res *= static_cast<Result>(2.0);
+        return res; 
+      }
+    };
+
+    template <typename Result, int exp>
+    struct ShiftMultiplier<Result, exp, false> {
+      static const Result multiplier() {
+        Result res = ShiftMultiplier<Result, exp / 2>::multiplier();
+        res *= res;
+        if ((exp & 1) == 1) res *= static_cast<Result>(0.5);
+        return res; 
+      }
+    };
+
+    template <typename Result>
+    struct ShiftMultiplier<Result, 0, true> {
+      static const Result multiplier() {
+        return static_cast<Result>(1.0); 
+      }
+    };
+
+    template <typename Result>
+    struct ShiftMultiplier<Result, -20, true> {
+      static const Result multiplier() {
+        return static_cast<Result>(1.0/1048576.0); 
+      }
+    };
+    
+    template <typename Result>
+    struct ShiftMultiplier<Result, -32, true> {
+      static const Result multiplier() {
+        return static_cast<Result>(1.0/424967296.0); 
+      }
+    };
+
+    template <typename Result>
+    struct ShiftMultiplier<Result, -53, true> {
+      static const Result multiplier() {
+        return static_cast<Result>(1.0/9007199254740992.0); 
+      }
+    };
+
+    template <typename Result>
+    struct ShiftMultiplier<Result, -64, true> {
+      static const Result multiplier() {
+        return static_cast<Result>(1.0/18446744073709551616.0); 
+      }
+    };
+
+    template <typename Result, int exp>
+    struct Shifting {
+      static Result shift(const Result& result) {
+        return result * ShiftMultiplier<Result, exp>::multiplier();
+      }
+    };
+
+    template <typename Result, typename Word,
+              int rest = std::numeric_limits<Result>::digits, int shift = 0, 
+              bool last = rest <= std::numeric_limits<Word>::digits>
+    struct RealConversion{ 
+      static const int bits = std::numeric_limits<Word>::digits;
+
+      static Result convert(RandomCore<Word>& rnd) {
+        return Shifting<Result, - shift - rest>::
+          shift(static_cast<Result>(rnd() >> (bits - rest)));
+      }
+    };
+
+    template <typename Result, typename Word, int rest, int shift>
+    struct RealConversion<Result, Word, rest, shift, false> { 
+      static const int bits = std::numeric_limits<Word>::digits;
+
+      static Result convert(RandomCore<Word>& rnd) {
+        return Shifting<Result, - shift - bits>::
+          shift(static_cast<Result>(rnd())) +
+          RealConversion<Result, Word, rest-bits, shift + bits>::
+          convert(rnd);
+      }
+    };
+
+    template <typename Result, typename Word>
+    struct Initializer {
+
+      template <typename Iterator>
+      static void init(RandomCore<Word>& rnd, Iterator begin, Iterator end) {
+        std::vector<Word> ws;
+        for (Iterator it = begin; it != end; ++it) {
+          ws.push_back(Word(*it));
+        }
+        rnd.initState(ws.begin(), ws.end());
+      }
+
+      static void init(RandomCore<Word>& rnd, Result seed) {
+        rnd.initState(seed);
+      }
+    };
+
+    template <typename Word>
+    struct BoolConversion {
+      static bool convert(RandomCore<Word>& rnd) {
+        return (rnd() & 1) == 1;
+      }
+    };
+
+    template <typename Word>
+    struct BoolProducer {
+      Word buffer;
+      int num;
+      
+      BoolProducer() : num(0) {}
+
+      bool convert(RandomCore<Word>& rnd) {
+        if (num == 0) {
+          buffer = rnd();
+          num = RandomTraits<Word>::bits;
+        }
+        bool r = (buffer & 1);
+        buffer >>= 1;
+        --num;
+        return r;
+      }
+    };
+
+  }
+
+  /// \ingroup misc
+  ///
+  /// \brief Mersenne Twister random number generator
+  ///
+  /// The Mersenne Twister is a twisted generalized feedback
+  /// shift-register generator of Matsumoto and Nishimura. The period
+  /// of this generator is \f$ 2^{19937} - 1 \f$ and it is
+  /// equi-distributed in 623 dimensions for 32-bit numbers. The time
+  /// performance of this generator is comparable to the commonly used
+  /// generators.
+  ///
+  /// This implementation is specialized for both 32-bit and 64-bit
+  /// architectures. The generators differ sligthly in the
+  /// initialization and generation phase so they produce two
+  /// completly different sequences.
+  ///
+  /// The generator gives back random numbers of serveral types. To
+  /// get a random number from a range of a floating point type you
+  /// can use one form of the \c operator() or the \c real() member
+  /// function. If you want to get random number from the {0, 1, ...,
+  /// n-1} integer range use the \c operator[] or the \c integer()
+  /// method. And to get random number from the whole range of an
+  /// integer type you can use the argumentless \c integer() or \c
+  /// uinteger() functions. After all you can get random bool with
+  /// equal chance of true and false or given probability of true
+  /// result with the \c boolean() member functions.
+  ///
+  ///\code
+  /// // The commented code is identical to the other
+  /// double a = rnd();                     // [0.0, 1.0)
+  /// // double a = rnd.real();             // [0.0, 1.0)
+  /// double b = rnd(100.0);                // [0.0, 100.0)
+  /// // double b = rnd.real(100.0);        // [0.0, 100.0)
+  /// double c = rnd(1.0, 2.0);             // [1.0, 2.0)
+  /// // double c = rnd.real(1.0, 2.0);     // [1.0, 2.0)
+  /// int d = rnd[100000];                  // 0..99999
+  /// // int d = rnd.integer(100000);       // 0..99999
+  /// int e = rnd[6] + 1;                   // 1..6
+  /// // int e = rnd.integer(1, 1 + 6);     // 1..6
+  /// int b = rnd.uinteger<int>();          // 0 .. 2^31 - 1
+  /// int c = rnd.integer<int>();           // - 2^31 .. 2^31 - 1
+  /// bool g = rnd.boolean();               // P(g = true) = 0.5
+  /// bool h = rnd.boolean(0.8);            // P(h = true) = 0.8
+  ///\endcode
+  ///
+  /// The lemon provides a global instance of the random number
+  /// generator which name is \ref lemon::rnd "rnd". Usually it is a
+  /// good programming convenience to use this global generator to get
+  /// random numbers.
+  class Random {
+  private:
+
+    // Architecture word
+    typedef unsigned long Word;
+    
+    _random_bits::RandomCore<Word> core;
+    _random_bits::BoolProducer<Word> bool_producer;
+    
+
+  public:
+
+    /// \brief Constructor
+    ///
+    /// Constructor with constant seeding.
+    Random() { core.initState(); }
+
+    /// \brief Constructor
+    ///
+    /// Constructor with seed. The current number type will be converted
+    /// to the architecture word type.
+    template <typename Number>
+    Random(Number seed) { 
+      _random_bits::Initializer<Number, Word>::init(core, seed);
+    }
+
+    /// \brief Constructor
+    ///
+    /// Constructor with array seeding. The given range should contain
+    /// any number type and the numbers will be converted to the
+    /// architecture word type.
+    template <typename Iterator>
+    Random(Iterator begin, Iterator end) { 
+      typedef typename std::iterator_traits<Iterator>::value_type Number;
+      _random_bits::Initializer<Number, Word>::init(core, begin, end);
+    }
+
+    /// \brief Copy constructor
+    ///
+    /// Copy constructor. The generated sequence will be identical to
+    /// the other sequence. It can be used to save the current state
+    /// of the generator and later use it to generate the same
+    /// sequence.
+    Random(const Random& other) {
+      core.copyState(other.core);
+    }
+
+    /// \brief Assign operator
+    ///
+    /// Assign operator. The generated sequence will be identical to
+    /// the other sequence. It can be used to save the current state
+    /// of the generator and later use it to generate the same
+    /// sequence.
+    Random& operator=(const Random& other) {
+      if (&other != this) {
+        core.copyState(other.core);
+      }
+      return *this;
+    }
+
+    /// \brief Returns a random real number from the range [0, 1)
+    ///
+    /// It returns a random real number from the range [0, 1). The
+    /// default Number type is double.
+    template <typename Number>
+    Number real() {
+      return _random_bits::RealConversion<Number, Word>::convert(core);
+    }
+
+    double real() {
+      return real<double>();
+    }
+
+    /// \brief Returns a random real number the range [0, b)
+    ///
+    /// It returns a random real number from the range [0, b).
+    template <typename Number>
+    Number real(Number b) { 
+      return real<Number>() * b; 
+    }
+
+    /// \brief Returns a random real number from the range [a, b)
+    ///
+    /// It returns a random real number from the range [a, b).
+    template <typename Number>
+    Number real(Number a, Number b) { 
+      return real<Number>() * (b - a) + a; 
+    }
+
+    /// \brief Returns a random real number from the range [0, 1)
+    ///
+    /// It returns a random double from the range [0, 1).
+    double operator()() {
+      return real<double>();
+    }
+
+    /// \brief Returns a random real number from the range [0, b)
+    ///
+    /// It returns a random real number from the range [0, b).
+    template <typename Number>
+    Number operator()(Number b) { 
+      return real<Number>() * b; 
+    }
+
+    /// \brief Returns a random real number from the range [a, b)
+    ///
+    /// It returns a random real number from the range [a, b).
+    template <typename Number>
+    Number operator()(Number a, Number b) { 
+      return real<Number>() * (b - a) + a; 
+    }
+
+    /// \brief Returns a random integer from a range
+    ///
+    /// It returns a random integer from the range {0, 1, ..., b - 1}.
+    template <typename Number>
+    Number integer(Number b) {
+      return _random_bits::Mapping<Number, Word>::map(core, b);
+    }
+
+    /// \brief Returns a random integer from a range
+    ///
+    /// It returns a random integer from the range {a, a + 1, ..., b - 1}.
+    template <typename Number>
+    Number integer(Number a, Number b) {
+      return _random_bits::Mapping<Number, Word>::map(core, b - a) + a;
+    }
+
+    /// \brief Returns a random integer from a range
+    ///
+    /// It returns a random integer from the range {0, 1, ..., b - 1}.
+    template <typename Number>
+    Number operator[](Number b) {
+      return _random_bits::Mapping<Number, Word>::map(core, b);
+    }
+
+    /// \brief Returns a random non-negative integer
+    ///
+    /// It returns a random non-negative integer uniformly from the
+    /// whole range of the current \c Number type.  The default result
+    /// type of this function is unsigned int.
+    template <typename Number>
+    Number uinteger() {
+      return _random_bits::IntConversion<Number, Word>::convert(core);
+    }
+
+    unsigned int uinteger() {
+      return uinteger<unsigned int>();
+    }
+
+    /// \brief Returns a random integer
+    ///
+    /// It returns a random integer uniformly from the whole range of
+    /// the current \c Number type. The default result type of this
+    /// function is int.
+    template <typename Number>
+    Number integer() {
+      static const int nb = std::numeric_limits<Number>::digits + 
+        (std::numeric_limits<Number>::is_signed ? 1 : 0);
+      return _random_bits::IntConversion<Number, Word, nb>::convert(core);
+    }
+
+    int integer() {
+      return integer<int>();
+    }
+    
+    /// \brief Returns a random bool
+    ///
+    /// It returns a random bool. The generator holds a buffer for
+    /// random bits. Every time when it become empty the generator makes
+    /// a new random word and fill the buffer up.
+    bool boolean() {
+      return bool_producer.convert(core);
+    }
+
+    ///\name Nonuniform distributions
+    ///
+    
+    ///@{
+    
+    /// \brief Returns a random bool
+    ///
+    /// It returns a random bool with given probability of true result.
+    bool boolean(double p) {
+      return operator()() < p;
+    }
+
+    /// Standard Gauss distribution
+
+    /// Standard Gauss distribution.
+    /// \note The Cartesian form of the Box-Muller
+    /// transformation is used to generate a random normal distribution.
+    /// \todo Consider using the "ziggurat" method instead.
+    double gauss() 
+    {
+      double V1,V2,S;
+      do {
+	V1=2*real<double>()-1;
+	V2=2*real<double>()-1;
+	S=V1*V1+V2*V2;
+      } while(S>=1);
+      return std::sqrt(-2*std::log(S)/S)*V1;
+    }
+    /// Gauss distribution with given mean and standard deviation
+
+    /// Gauss distribution with given mean and standard deviation.
+    /// \sa gauss()
+    double gauss(double mean,double std_dev)
+    {
+      return gauss()*std_dev+mean;
+    }
+
+    /// Exponential distribution with given mean
+
+    /// This function generates an exponential distribution random number
+    /// with mean <tt>1/lambda</tt>.
+    ///
+    double exponential(double lambda=1.0)
+    {
+      return -std::log(1.0-real<double>())/lambda;
+    }
+
+    /// Gamma distribution with given integer shape
+
+    /// This function generates a gamma distribution random number.
+    /// 
+    ///\param k shape parameter (<tt>k>0</tt> integer)
+    double gamma(int k) 
+    {
+      double s = 0;
+      for(int i=0;i<k;i++) s-=std::log(1.0-real<double>());
+      return s;
+    }
+    
+    /// Gamma distribution with given shape and scale parameter
+
+    /// This function generates a gamma distribution random number.
+    /// 
+    ///\param k shape parameter (<tt>k>0</tt>)
+    ///\param theta scale parameter
+    ///
+    double gamma(double k,double theta=1.0)
+    {
+      double xi,nu;
+      const double delta = k-std::floor(k);
+      const double v0=M_E/(M_E-delta);
+      do {
+	double V0=1.0-real<double>();
+	double V1=1.0-real<double>();
+	double V2=1.0-real<double>();
+	if(V2<=v0) 
+	  {
+	    xi=std::pow(V1,1.0/delta);
+	    nu=V0*std::pow(xi,delta-1.0);
+	  }
+	else 
+	  {
+	    xi=1.0-std::log(V1);
+	    nu=V0*std::exp(-xi);
+	  }
+      } while(nu>std::pow(xi,delta-1.0)*std::exp(-xi));
+      return theta*(xi-gamma(int(std::floor(k))));
+    }
+    
+    /// Weibull distribution
+
+    /// This function generates a Weibull distribution random number.
+    /// 
+    ///\param k shape parameter (<tt>k>0</tt>)
+    ///\param lambda scale parameter (<tt>lambda>0</tt>)
+    ///
+    double weibull(double k,double lambda)
+    {
+      return lambda*pow(-std::log(1.0-real<double>()),1.0/k);
+    }  
+      
+    /// Pareto distribution
+
+    /// This function generates a Pareto distribution random number.
+    /// 
+    ///\param k shape parameter (<tt>k>0</tt>)
+    ///\param x_min location parameter (<tt>x_min>0</tt>)
+    ///
+    double pareto(double k,double x_min)
+    {
+      return exponential(gamma(k,1.0/x_min));
+    }  
+      
+    ///@}
+    
+    ///\name Two dimensional distributions
+    ///
+
+    ///@{
+    
+    /// Uniform distribution on the full unit circle
+
+    /// Uniform distribution on the full unit circle.
+    ///
+    dim2::Point<double> disc() 
+    {
+      double V1,V2;
+      do {
+	V1=2*real<double>()-1;
+	V2=2*real<double>()-1;
+	
+      } while(V1*V1+V2*V2>=1);
+      return dim2::Point<double>(V1,V2);
+    }
+    /// A kind of two dimensional Gauss distribution
+
+    /// This function provides a turning symmetric two-dimensional distribution.
+    /// Both coordinates are of standard normal distribution, but they are not
+    /// independent.
+    ///
+    /// \note The coordinates are the two random variables provided by
+    /// the Box-Muller method.
+    dim2::Point<double> gauss2()
+    {
+      double V1,V2,S;
+      do {
+	V1=2*real<double>()-1;
+	V2=2*real<double>()-1;
+	S=V1*V1+V2*V2;
+      } while(S>=1);
+      double W=std::sqrt(-2*std::log(S)/S);
+      return dim2::Point<double>(W*V1,W*V2);
+    }
+    /// A kind of two dimensional exponential distribution
+
+    /// This function provides a turning symmetric two-dimensional distribution.
+    /// The x-coordinate is of conditionally exponential distribution
+    /// with the condition that x is positive and y=0. If x is negative and 
+    /// y=0 then, -x is of exponential distribution. The same is true for the
+    /// y-coordinate.
+    dim2::Point<double> exponential2() 
+    {
+      double V1,V2,S;
+      do {
+	V1=2*real<double>()-1;
+	V2=2*real<double>()-1;
+	S=V1*V1+V2*V2;
+      } while(S>=1);
+      double W=-std::log(S)/S;
+      return dim2::Point<double>(W*V1,W*V2);
+    }
+
+    ///@}    
+  };
+
+
+  extern Random rnd;
+
+}
+
+#endif
Index: lemon/tolerance.h
===================================================================
--- lemon/tolerance.h	(revision 7)
+++ lemon/tolerance.h	(revision 16)
@@ -49,7 +49,11 @@
   ///\sa Tolerance<long double>
   ///\sa Tolerance<int>
+#if defined __GNUC__ && !defined __STRICT_ANSI__  
   ///\sa Tolerance<long long int>
+#endif
   ///\sa Tolerance<unsigned int>
+#if defined __GNUC__ && !defined __STRICT_ANSI__  
   ///\sa Tolerance<unsigned long long int>
+#endif
 
   template<class T>
@@ -131,5 +135,5 @@
     bool negative(Value a) const { return -_epsilon>a; }
     ///Returns \c true if \c a is \e surely non-zero
-    bool nonZero(Value a) const { return positive(a)||negative(a); };
+    bool nonZero(Value a) const { return positive(a)||negative(a); }
 
     ///@}
@@ -182,5 +186,5 @@
     bool negative(Value a) const { return -_epsilon>a; }
     ///Returns \c true if \c a is \e surely non-zero
-    bool nonZero(Value a) const { return positive(a)||negative(a); };
+    bool nonZero(Value a) const { return positive(a)||negative(a); }
 
     ///@}
@@ -233,5 +237,5 @@
     bool negative(Value a) const { return -_epsilon>a; }
     ///Returns \c true if \c a is \e surely non-zero
-    bool nonZero(Value a) const { return positive(a)||negative(a); };
+    bool nonZero(Value a) const { return positive(a)||negative(a); }
 
     ///@}
@@ -266,5 +270,5 @@
     static bool negative(Value a) { return 0>a; }
     ///Returns \c true if \c a is \e surely non-zero
-    static bool nonZero(Value a) { return a!=0; };
+    static bool nonZero(Value a) { return a!=0; }
 
     ///@}
@@ -299,5 +303,5 @@
     static bool negative(Value) { return false; }
     ///Returns \c true if \c a is \e surely non-zero
-    static bool nonZero(Value a) { return a!=0; };
+    static bool nonZero(Value a) { return a!=0; }
 
     ///@}
@@ -333,5 +337,5 @@
     static bool negative(Value a) { return 0>a; }
     ///Returns \c true if \c a is \e surely non-zero
-    static bool nonZero(Value a) { return a!=0;};
+    static bool nonZero(Value a) { return a!=0;}
 
     ///@}
@@ -366,5 +370,5 @@
     static bool negative(Value) { return false; }
     ///Returns \c true if \c a is \e surely non-zero
-    static bool nonZero(Value a) { return a!=0;};
+    static bool nonZero(Value a) { return a!=0;}
 
     ///@}
@@ -403,5 +407,5 @@
     static bool negative(Value a) { return 0>a; }
     ///Returns \c true if \c a is \e surely non-zero
-    static bool nonZero(Value a) { return a!=0;};
+    static bool nonZero(Value a) { return a!=0;}
 
     ///@}
@@ -438,5 +442,5 @@
     static bool negative(Value) { return false; }
     ///Returns \c true if \c a is \e surely non-zero
-    static bool nonZero(Value a) { return a!=0;};
+    static bool nonZero(Value a) { return a!=0;}
 
     ///@}
Index: test/Makefile.am
===================================================================
--- test/Makefile.am	(revision 25)
+++ test/Makefile.am	(revision 32)
@@ -4,14 +4,16 @@
 noinst_HEADERS += \
         test/test_tools.h
- 
+
 check_PROGRAMS += \
-        test/maps_test \
+        test/dim_test \
+        test/random_test \
         test/test_tools_fail \
         test/test_tools_pass
- 
+
 TESTS += $(check_PROGRAMS)
 XFAIL_TESTS += test/test_tools_fail$(EXEEXT)
 
-test_maps_test_SOURCES = test/maps_test.cc
+test_dim_test_SOURCES = test/dim_test.cc
+test_random_test_SOURCES = test/random_test.cc
 test_test_tools_fail_SOURCES = test/test_tools_fail.cc
 test_test_tools_pass_SOURCES = test/test_tools_pass.cc
Index: test/dim_test.cc
===================================================================
--- test/dim_test.cc	(revision 14)
+++ test/dim_test.cc	(revision 14)
@@ -0,0 +1,87 @@
+/* -*- C++ -*-
+ *
+ * This file is a part of LEMON, a generic C++ optimization library
+ *
+ * Copyright (C) 2003-2007
+ * 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.
+ *
+ */
+
+#include <lemon/dim2.h>
+#include <iostream>
+#include "test_tools.h"
+
+using namespace std;
+using namespace lemon;
+
+int main()
+{
+  cout << "Testing classes 'dim2::Point' and 'dim2::BoundingBox'." << endl;
+
+  typedef dim2::Point<int> Point;
+
+  Point p;
+  check(p.size()==2, "Wrong vector initialization.");
+
+  Point a(1,2);
+  Point b(3,4);
+  check(a[0]==1 && a[1]==2, "Wrong vector initialization.");
+
+  p = a+b;
+  check(p.x==4 && p.y==6, "Wrong vector addition.");
+
+  p = a-b;
+  check(p.x==-2 && p.y==-2, "Wrong vector subtraction.");
+
+  check(a.normSquare()==5,"Wrong vector norm calculation.");
+  check(a*b==11, "Wrong vector scalar product.");
+
+  int l=2;
+  p = a*l;
+  check(p.x==2 && p.y==4, "Wrong vector multiplication by a scalar.");
+
+  p = b/l;
+  check(p.x==1 && p.y==2, "Wrong vector division by a scalar.");
+
+  typedef dim2::BoundingBox<int> BB;
+  BB box1;
+  check(box1.empty(), "It should be empty.");
+
+  box1.add(a);
+  check(!box1.empty(), "It should not be empty.");
+  box1.add(b);
+
+  check(box1.bottomLeft().x==1 &&
+        box1.bottomLeft().y==2 &&
+        box1.topRight().x==3 &&
+        box1.topRight().y==4,
+        "Wrong addition of points to box.");
+
+  p.x=2; p.y=3;
+  check(box1.inside(p), "It should be inside.");
+
+  p.x=1; p.y=3;
+  check(box1.inside(p), "It should be inside.");
+
+  p.x=0; p.y=3;
+  check(!box1.inside(p), "It should not be inside.");
+
+  BB box2(p);
+  check(!box2.empty(),
+        "It should not be empty. Constructed from 1 point.");
+
+  box2.add(box1);
+  check(box2.inside(p),
+        "It should be inside. Incremented a box with another one.");
+
+  return 0;
+}
Index: test/random_test.cc
===================================================================
--- test/random_test.cc	(revision 10)
+++ test/random_test.cc	(revision 10)
@@ -0,0 +1,36 @@
+/* -*- C++ -*-
+ *
+ * This file is a part of LEMON, a generic C++ optimization library
+ *
+ * Copyright (C) 2003-2007
+ * 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.
+ *
+ */
+
+#include <lemon/random.h>
+#include "test_tools.h"
+
+///\file \brief Test cases for random.h
+///
+///\todo To be extended
+///
+
+int main()
+{
+  double a=lemon::rnd();
+  check(a<1.0&&a>0.0,"This should be in [0,1)");
+  a=lemon::rnd.gauss();
+  a=lemon::rnd.gamma(3.45,0);
+  a=lemon::rnd.gamma(4);
+  //Does gamma work with integer k?
+  a=lemon::rnd.gamma(4.0,0);
+}
