Index: lemon/bits/alteration_notifier.h
===================================================================
--- lemon/bits/alteration_notifier.h	(revision 57)
+++ lemon/bits/alteration_notifier.h	(revision 57)
@@ -0,0 +1,485 @@
+/* -*- 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_BITS_ALTERATION_NOTIFIER_H
+#define LEMON_BITS_ALTERATION_NOTIFIER_H
+
+#include <vector>
+#include <list>
+
+#include <lemon/bits/utility.h>
+
+///\ingroup graphbits
+///\file
+///\brief Observer notifier for graph alteration observers.
+
+namespace lemon {
+
+  /// \ingroup graphbits
+  ///
+  /// \brief Notifier class to notify observes about alterations in 
+  /// a container.
+  ///
+  /// The simple graph's can be refered as two containers, one node container
+  /// and one edge container. But they are not standard containers they
+  /// does not store values directly they are just key continars for more
+  /// value containers which are the node and edge maps.
+  ///
+  /// The graph's node and edge sets can be changed as we add or erase
+  /// nodes and edges in the graph. Lemon would like to handle easily
+  /// that the node and edge maps should contain values for all nodes or
+  /// edges. If we want to check on every indicing if the map contains
+  /// the current indicing key that cause a drawback in the performance
+  /// in the library. We use another solution we notify all maps about
+  /// an alteration in the graph, which cause only drawback on the
+  /// alteration of the graph.
+  ///
+  /// This class provides an interface to the container. The \e first() and \e 
+  /// next() member functions make possible to iterate on the keys of the
+  /// container. The \e id() function returns an integer id for each key.
+  /// The \e maxId() function gives back an upper bound of the ids.
+  ///
+  /// For the proper functonality of this class, we should notify it
+  /// about each alteration in the container. The alterations have four type
+  /// as \e add(), \e erase(), \e build() and \e clear(). The \e add() and
+  /// \e erase() signals that only one or few items added or erased to or
+  /// from the graph. If all items are erased from the graph or from an empty
+  /// graph a new graph is builded then it can be signaled with the
+  /// clear() and build() members. Important rule that if we erase items 
+  /// from graph we should first signal the alteration and after that erase
+  /// them from the container, on the other way on item addition we should
+  /// first extend the container and just after that signal the alteration.
+  ///
+  /// The alteration can be observed with a class inherited from the
+  /// \e ObserverBase nested class. The signals can be handled with
+  /// overriding the virtual functions defined in the base class.  The
+  /// observer base can be attached to the notifier with the 
+  /// \e attach() member and can be detached with detach() function. The
+  /// alteration handlers should not call any function which signals
+  /// an other alteration in the same notifier and should not
+  /// detach any observer from the notifier.
+  ///
+  /// Alteration observers try to be exception safe. If an \e add() or
+  /// a \e clear() function throws an exception then the remaining
+  /// observeres will not be notified and the fulfilled additions will
+  /// be rolled back by calling the \e erase() or \e clear()
+  /// functions. Thence the \e erase() and \e clear() should not throw
+  /// exception. Actullay, it can be throw only 
+  /// \ref AlterationObserver::ImmediateDetach ImmediateDetach
+  /// exception which detach the observer from the notifier.
+  ///
+  /// There are some place when the alteration observing is not completly
+  /// reliable. If we want to carry out the node degree in the graph
+  /// as in the \ref InDegMap and we use the reverseEdge that cause 
+  /// unreliable functionality. Because the alteration observing signals
+  /// only erasing and adding but not the reversing it will stores bad
+  /// degrees. The sub graph adaptors cannot signal the alterations because
+  /// just a setting in the filter map can modify the graph and this cannot
+  /// be watched in any way.
+  ///
+  /// \param _Container The container which is observed.
+  /// \param _Item The item type which is obserbved.
+  ///
+  /// \author Balazs Dezso
+
+  template <typename _Container, typename _Item>
+  class AlterationNotifier {
+  public:
+
+    typedef True Notifier;
+
+    typedef _Container Container;
+    typedef _Item Item;
+
+    /// \brief Exception which can be called from \e clear() and 
+    /// \e erase().
+    ///
+    /// From the \e clear() and \e erase() function only this
+    /// exception is allowed to throw. The exception immediatly
+    /// detaches the current observer from the notifier. Because the
+    /// \e clear() and \e erase() should not throw other exceptions
+    /// it can be used to invalidate the observer.
+    struct ImmediateDetach {};
+
+    /// \brief ObserverBase is the base class for the observers.
+    ///
+    /// ObserverBase is the abstract base class for the observers.
+    /// It will be notified about an item was inserted into or
+    /// erased from the graph.
+    ///
+    /// The observer interface contains some pure virtual functions
+    /// to override. The add() and erase() functions are
+    /// to notify the oberver when one item is added or
+    /// erased.
+    ///
+    /// The build() and clear() members are to notify the observer
+    /// about the container is built from an empty container or
+    /// is cleared to an empty container. 
+    /// 
+    /// \author Balazs Dezso
+
+    class ObserverBase {
+    protected:
+      typedef AlterationNotifier Notifier;
+
+      friend class AlterationNotifier;
+
+      /// \brief Default constructor.
+      ///
+      /// Default constructor for ObserverBase.
+      /// 
+      ObserverBase() : _notifier(0) {}
+
+      /// \brief Constructor which attach the observer into notifier.
+      ///
+      /// Constructor which attach the observer into notifier.
+      ObserverBase(AlterationNotifier& nf) {
+        attach(nf);
+      }
+
+      /// \brief Constructor which attach the obserever to the same notifier.
+      ///
+      /// Constructor which attach the obserever to the same notifier as
+      /// the other observer is attached to. 
+      ObserverBase(const ObserverBase& copy) {
+	if (copy.attached()) {
+          attach(*copy.notifier());
+	}
+      }
+	
+      /// \brief Destructor
+      virtual ~ObserverBase() {
+        if (attached()) {
+          detach();
+        }
+      }
+
+      /// \brief Attaches the observer into an AlterationNotifier.
+      ///
+      /// This member attaches the observer into an AlterationNotifier.
+      ///
+      void attach(AlterationNotifier& nf) {
+	nf.attach(*this);
+      }
+      
+      /// \brief Detaches the observer into an AlterationNotifier.
+      ///
+      /// This member detaches the observer from an AlterationNotifier.
+      ///
+      void detach() {
+        _notifier->detach(*this);
+      }
+      
+      /// \brief Gives back a pointer to the notifier which the map 
+      /// attached into.
+      ///
+      /// This function gives back a pointer to the notifier which the map
+      /// attached into.
+      ///
+      Notifier* notifier() const { return const_cast<Notifier*>(_notifier); }
+      
+      /// Gives back true when the observer is attached into a notifier.
+      bool attached() const { return _notifier != 0; }
+
+    private:
+
+      ObserverBase& operator=(const ObserverBase& copy);
+
+    protected:
+      
+      Notifier* _notifier;
+      typename std::list<ObserverBase*>::iterator _index;
+
+      /// \brief The member function to notificate the observer about an
+      /// item is added to the container.
+      ///
+      /// The add() member function notificates the observer about an item
+      /// is added to the container. It have to be overrided in the
+      /// subclasses.
+      virtual void add(const Item&) = 0;
+
+      /// \brief The member function to notificate the observer about 
+      /// more item is added to the container.
+      ///
+      /// The add() member function notificates the observer about more item
+      /// is added to the container. It have to be overrided in the
+      /// subclasses.
+      virtual void add(const std::vector<Item>& items) = 0;
+
+      /// \brief The member function to notificate the observer about an
+      /// item is erased from the container.
+      ///
+      /// The erase() member function notificates the observer about an
+      /// item is erased from the container. It have to be overrided in
+      /// the subclasses.	
+      virtual void erase(const Item&) = 0;
+
+      /// \brief The member function to notificate the observer about 
+      /// more item is erased from the container.
+      ///
+      /// The erase() member function notificates the observer about more item
+      /// is erased from the container. It have to be overrided in the
+      /// subclasses.
+      virtual void erase(const std::vector<Item>& items) = 0;
+
+      /// \brief The member function to notificate the observer about the
+      /// container is built.
+      ///
+      /// The build() member function notificates the observer about the
+      /// container is built from an empty container. It have to be
+      /// overrided in the subclasses.
+
+      virtual void build() = 0;
+
+      /// \brief The member function to notificate the observer about all
+      /// items are erased from the container.
+      ///
+      /// The clear() member function notificates the observer about all
+      /// items are erased from the container. It have to be overrided in
+      /// the subclasses.      
+      virtual void clear() = 0;
+
+    };
+	
+  protected:
+
+    const Container* container;
+
+    typedef std::list<ObserverBase*> Observers; 
+    Observers _observers;
+
+		
+  public:
+
+    /// \brief Default constructor.
+    ///
+    /// The default constructor of the AlterationNotifier. 
+    /// It creates an empty notifier.
+    AlterationNotifier() 
+      : container(0) {}
+
+    /// \brief Constructor.
+    ///
+    /// Constructor with the observed container parameter.
+    AlterationNotifier(const Container& _container) 
+      : container(&_container) {}
+
+    /// \brief Copy Constructor of the AlterationNotifier. 
+    ///
+    /// Copy constructor of the AlterationNotifier. 
+    /// It creates only an empty notifier because the copiable
+    /// notifier's observers have to be registered still into that notifier.
+    AlterationNotifier(const AlterationNotifier& _notifier) 
+      : container(_notifier.container) {}
+
+    /// \brief Destructor.
+    ///		
+    /// Destructor of the AlterationNotifier.
+    ///
+    ~AlterationNotifier() {
+      typename Observers::iterator it;
+      for (it = _observers.begin(); it != _observers.end(); ++it) {
+	(*it)->_notifier = 0;
+      }
+    }
+
+    /// \brief Sets the container.
+    ///
+    /// Sets the container.
+    void setContainer(const Container& _container) {
+      container = &_container;
+    }
+
+  protected:
+
+    AlterationNotifier& operator=(const AlterationNotifier&);
+
+  public:
+
+
+
+    /// \brief First item in the container.
+    ///
+    /// Returns the first item in the container. It is
+    /// for start the iteration on the container.
+    void first(Item& item) const {
+      container->first(item);
+    }
+
+    /// \brief Next item in the container.
+    ///
+    /// Returns the next item in the container. It is
+    /// for iterate on the container.
+    void next(Item& item) const {
+      container->next(item);
+    }
+
+    /// \brief Returns the id of the item.
+    ///
+    /// Returns the id of the item provided by the container.
+    int id(const Item& item) const {
+      return container->id(item);
+    }
+
+    /// \brief Returns the maximum id of the container.
+    ///
+    /// Returns the maximum id of the container.
+    int maxId() const {
+      return container->maxId(Item());
+    }
+		
+  protected:
+
+    void attach(ObserverBase& observer) {
+      observer._index = _observers.insert(_observers.begin(), &observer);
+      observer._notifier = this;
+    } 
+
+    void detach(ObserverBase& observer) {
+      _observers.erase(observer._index);
+      observer._index = _observers.end();
+      observer._notifier = 0;
+    }
+
+  public:
+	
+    /// \brief Notifies all the registed observers about an item added to 
+    /// the container.
+    ///
+    /// It notifies all the registed observers about an item added to 
+    /// the container.
+    /// 
+    void add(const Item& item) {
+      typename Observers::reverse_iterator it;
+      try {
+        for (it = _observers.rbegin(); it != _observers.rend(); ++it) {
+          (*it)->add(item);
+        }
+      } catch (...) {
+        typename Observers::iterator jt;
+        for (jt = it.base(); jt != _observers.end(); ++jt) {
+          (*jt)->erase(item);
+        }
+        throw;
+      }
+    }	
+
+    /// \brief Notifies all the registed observers about more item added to 
+    /// the container.
+    ///
+    /// It notifies all the registed observers about more item added to 
+    /// the container.
+    /// 
+    void add(const std::vector<Item>& items) {
+      typename Observers::reverse_iterator it;
+      try {
+        for (it = _observers.rbegin(); it != _observers.rend(); ++it) {
+          (*it)->add(items);
+        }
+      } catch (...) {
+        typename Observers::iterator jt;
+        for (jt = it.base(); jt != _observers.end(); ++jt) {
+          (*jt)->erase(items);
+        }
+        throw;
+      }
+    }	
+
+    /// \brief Notifies all the registed observers about an item erased from 
+    /// the container.
+    ///	
+    /// It notifies all the registed observers about an item erased from 
+    /// the container.
+    /// 
+    void erase(const Item& item) throw() {
+      typename Observers::iterator it = _observers.begin();
+      while (it != _observers.end()) {
+        try {
+          (*it)->erase(item);
+          ++it;
+        } catch (const ImmediateDetach&) {
+          it = _observers.erase(it);
+          (*it)->_index = _observers.end();
+          (*it)->_notifier = 0;
+        }
+      }
+    }
+
+    /// \brief Notifies all the registed observers about more item erased  
+    /// from the container.
+    ///	
+    /// It notifies all the registed observers about more item erased from 
+    /// the container.
+    /// 
+    void erase(const std::vector<Item>& items) {
+      typename Observers::iterator it = _observers.begin();
+      while (it != _observers.end()) {
+        try {
+          (*it)->erase(items);
+          ++it;
+        } catch (const ImmediateDetach&) {
+          it = _observers.erase(it);
+          (*it)->_index = _observers.end();
+          (*it)->_notifier = 0;
+        }
+      }
+    }
+
+    /// \brief Notifies all the registed observers about the container is 
+    /// built.
+    ///		
+    /// Notifies all the registed observers about the container is built
+    /// from an empty container.
+    void build() {
+      typename Observers::reverse_iterator it;
+      try {
+        for (it = _observers.rbegin(); it != _observers.rend(); ++it) {
+          (*it)->build();
+        }
+      } catch (...) {
+        typename Observers::iterator jt;
+        for (jt = it.base(); jt != _observers.end(); ++jt) {
+          (*jt)->clear();
+        }
+        throw;
+      }
+    }
+
+    /// \brief Notifies all the registed observers about all items are 
+    /// erased.
+    ///
+    /// Notifies all the registed observers about all items are erased
+    /// from the container.
+    void clear() {
+      typename Observers::iterator it = _observers.begin();
+      while (it != _observers.end()) {
+        try {
+          (*it)->clear();
+          ++it;
+        } catch (const ImmediateDetach&) {
+          it = _observers.erase(it);
+          (*it)->_index = _observers.end();
+          (*it)->_notifier = 0;
+        }
+      }
+    }
+  };
+
+}
+
+#endif
Index: lemon/bits/array_map.h
===================================================================
--- lemon/bits/array_map.h	(revision 57)
+++ lemon/bits/array_map.h	(revision 57)
@@ -0,0 +1,346 @@
+/* -*- 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_BITS_ARRAY_MAP_H
+#define LEMON_BITS_ARRAY_MAP_H
+
+#include <memory>
+
+#include <lemon/bits/traits.h>
+#include <lemon/bits/alteration_notifier.h>
+#include <lemon/concept_check.h>
+#include <lemon/concepts/maps.h>
+
+/// \ingroup graphbits
+/// \file
+/// \brief Graph map based on the array storage.
+
+namespace lemon {
+
+  /// \ingroup graphbits
+  ///
+  /// \brief Graph map based on the array storage.
+  ///
+  /// The ArrayMap template class is graph map structure what
+  /// automatically updates the map when a key is added to or erased from
+  /// the map. This map uses the allocators to implement 
+  /// the container functionality.
+  ///
+  /// The template parameters are the Graph the current Item type and
+  /// the Value type of the map.
+  template <typename _Graph, typename _Item, typename _Value>
+  class ArrayMap 
+    : public ItemSetTraits<_Graph, _Item>::ItemNotifier::ObserverBase {
+  public:
+    /// The graph type of the maps. 
+    typedef _Graph Graph;
+    /// The item type of the map.
+    typedef _Item Item;
+    /// The reference map tag.
+    typedef True ReferenceMapTag;
+
+    /// The key type of the maps.
+    typedef _Item Key;
+    /// The value type of the map.
+    typedef _Value Value;
+
+    /// The const reference type of the map.
+    typedef const _Value& ConstReference;
+    /// The reference type of the map.
+    typedef _Value& Reference;
+
+    /// The notifier type.
+    typedef typename ItemSetTraits<_Graph, _Item>::ItemNotifier Notifier;
+
+    /// The MapBase of the Map which imlements the core regisitry function.
+    typedef typename Notifier::ObserverBase Parent;
+		
+  private:
+    typedef std::allocator<Value> Allocator;
+
+  public:
+
+    /// \brief Graph initialized map constructor.
+    ///
+    /// Graph initialized map constructor.
+    explicit ArrayMap(const Graph& graph) {
+      Parent::attach(graph.notifier(Item()));
+      allocate_memory();
+      Notifier* nf = Parent::notifier();
+      Item it;
+      for (nf->first(it); it != INVALID; nf->next(it)) {
+	int id = nf->id(it);;
+	allocator.construct(&(values[id]), Value());
+      }								
+    }
+
+    /// \brief Constructor to use default value to initialize the map. 
+    ///
+    /// It constructs a map and initialize all of the the map. 
+    ArrayMap(const Graph& graph, const Value& value) {
+      Parent::attach(graph.notifier(Item()));
+      allocate_memory();
+      Notifier* nf = Parent::notifier();
+      Item it;
+      for (nf->first(it); it != INVALID; nf->next(it)) {
+	int id = nf->id(it);;
+	allocator.construct(&(values[id]), value);
+      }								
+    }
+
+    /// \brief Constructor to copy a map of the same map type.
+    ///
+    /// Constructor to copy a map of the same map type.     
+    ArrayMap(const ArrayMap& copy) : Parent() {
+      if (copy.attached()) {
+	attach(*copy.notifier());
+      }
+      capacity = copy.capacity;
+      if (capacity == 0) return;
+      values = allocator.allocate(capacity);
+      Notifier* nf = Parent::notifier();
+      Item it;
+      for (nf->first(it); it != INVALID; nf->next(it)) {
+	int id = nf->id(it);;
+	allocator.construct(&(values[id]), copy.values[id]);
+      }
+    }
+
+    /// \brief Assign operator.
+    ///
+    /// This operator assigns for each item in the map the
+    /// value mapped to the same item in the copied map.  
+    /// The parameter map should be indiced with the same
+    /// itemset because this assign operator does not change
+    /// the container of the map. 
+    ArrayMap& operator=(const ArrayMap& cmap) {
+      return operator=<ArrayMap>(cmap);
+    }
+
+
+    /// \brief Template assign operator.
+    ///
+    /// The given parameter should be conform to the ReadMap
+    /// concecpt and could be indiced by the current item set of
+    /// the NodeMap. In this case the value for each item
+    /// is assigned by the value of the given ReadMap. 
+    template <typename CMap>
+    ArrayMap& operator=(const CMap& cmap) {
+      checkConcept<concepts::ReadMap<Key, _Value>, CMap>();
+      const typename Parent::Notifier* nf = Parent::notifier();
+      Item it;
+      for (nf->first(it); it != INVALID; nf->next(it)) {
+        set(it, cmap[it]);
+      }
+      return *this;
+    }
+
+    /// \brief The destructor of the map.
+    ///     
+    /// The destructor of the map.
+    virtual ~ArrayMap() {      
+      if (attached()) {
+	clear();
+	detach();
+      }
+    }
+		
+  protected:
+
+    using Parent::attach;
+    using Parent::detach;
+    using Parent::attached;
+
+  public:
+
+    /// \brief The subscript operator. 
+    ///
+    /// The subscript operator. The map can be subscripted by the
+    /// actual keys of the graph. 
+    Value& operator[](const Key& key) {
+      int id = Parent::notifier()->id(key);
+      return values[id];
+    } 
+		
+    /// \brief The const subscript operator.
+    ///
+    /// The const subscript operator. The map can be subscripted by the
+    /// actual keys of the graph. 
+    const Value& operator[](const Key& key) const {
+      int id = Parent::notifier()->id(key);
+      return values[id];
+    }
+
+    /// \brief Setter function of the map.
+    ///	
+    /// Setter function of the map. Equivalent with map[key] = val.
+    /// This is a compatibility feature with the not dereferable maps.
+    void set(const Key& key, const Value& val) {
+      (*this)[key] = val;
+    }
+
+  protected:
+
+    /// \brief Adds a new key to the map.
+    ///		
+    /// It adds a new key to the map. It called by the observer notifier
+    /// and it overrides the add() member function of the observer base.     
+    virtual void add(const Key& key) {
+      Notifier* nf = Parent::notifier();
+      int id = nf->id(key);
+      if (id >= capacity) {
+	int new_capacity = (capacity == 0 ? 1 : capacity);
+	while (new_capacity <= id) {
+	  new_capacity <<= 1;
+	}
+	Value* new_values = allocator.allocate(new_capacity);
+	Item it;
+	for (nf->first(it); it != INVALID; nf->next(it)) {
+	  int jd = nf->id(it);;
+	  if (id != jd) {
+	    allocator.construct(&(new_values[jd]), values[jd]);
+	    allocator.destroy(&(values[jd]));
+	  }
+	}
+	if (capacity != 0) allocator.deallocate(values, capacity);
+	values = new_values;
+	capacity = new_capacity;
+      }
+      allocator.construct(&(values[id]), Value());
+    }
+
+    /// \brief Adds more new keys to the map.
+    ///		
+    /// It adds more new keys to the map. It called by the observer notifier
+    /// and it overrides the add() member function of the observer base.     
+    virtual void add(const std::vector<Key>& keys) {
+      Notifier* nf = Parent::notifier();
+      int max_id = -1;
+      for (int i = 0; i < int(keys.size()); ++i) {
+	int id = nf->id(keys[i]);
+	if (id > max_id) {
+	  max_id = id;
+	}
+      }
+      if (max_id >= capacity) {
+	int new_capacity = (capacity == 0 ? 1 : capacity);
+	while (new_capacity <= max_id) {
+	  new_capacity <<= 1;
+	}
+	Value* new_values = allocator.allocate(new_capacity);
+	Item it;
+	for (nf->first(it); it != INVALID; nf->next(it)) {
+	  int id = nf->id(it);
+	  bool found = false;
+	  for (int i = 0; i < int(keys.size()); ++i) {
+	    int jd = nf->id(keys[i]);
+	    if (id == jd) {
+	      found = true;
+	      break;
+	    }
+	  }
+	  if (found) continue;
+	  allocator.construct(&(new_values[id]), values[id]);
+	  allocator.destroy(&(values[id]));
+	}
+	if (capacity != 0) allocator.deallocate(values, capacity);
+	values = new_values;
+	capacity = new_capacity;
+      }
+      for (int i = 0; i < int(keys.size()); ++i) {
+	int id = nf->id(keys[i]);
+	allocator.construct(&(values[id]), Value());
+      }
+    }
+		
+    /// \brief Erase a key from the map.
+    ///
+    /// Erase a key from the map. It called by the observer notifier
+    /// and it overrides the erase() member function of the observer base.     
+    virtual void erase(const Key& key) {
+      int id = Parent::notifier()->id(key);
+      allocator.destroy(&(values[id]));
+    }
+
+    /// \brief Erase more keys from the map.
+    ///
+    /// Erase more keys from the map. It called by the observer notifier
+    /// and it overrides the erase() member function of the observer base.     
+    virtual void erase(const std::vector<Key>& keys) {
+      for (int i = 0; i < int(keys.size()); ++i) {
+	int id = Parent::notifier()->id(keys[i]);
+	allocator.destroy(&(values[id]));
+      }
+    }
+
+    /// \brief Buildes the map.
+    ///	
+    /// It buildes the map. It called by the observer notifier
+    /// and it overrides the build() member function of the observer base. 
+    virtual void build() {
+      Notifier* nf = Parent::notifier();
+      allocate_memory();
+      Item it;
+      for (nf->first(it); it != INVALID; nf->next(it)) {
+	int id = nf->id(it);;
+	allocator.construct(&(values[id]), Value());
+      }								
+    }
+
+    /// \brief Clear the map.
+    ///
+    /// It erase all items from the map. It called by the observer notifier
+    /// and it overrides the clear() member function of the observer base.     
+    virtual void clear() {	
+      Notifier* nf = Parent::notifier();
+      if (capacity != 0) {
+	Item it;
+	for (nf->first(it); it != INVALID; nf->next(it)) {
+	  int id = nf->id(it);
+	  allocator.destroy(&(values[id]));
+	}								
+	allocator.deallocate(values, capacity);
+	capacity = 0;
+      }
+    }
+
+  private:
+      
+    void allocate_memory() {
+      int max_id = Parent::notifier()->maxId();
+      if (max_id == -1) {
+	capacity = 0;
+	values = 0;
+	return;
+      }
+      capacity = 1;
+      while (capacity <= max_id) {
+	capacity <<= 1;
+      }
+      values = allocator.allocate(capacity);	
+    }      
+
+    int capacity;
+    Value* values;
+    Allocator allocator;
+
+  };		
+
+}
+
+#endif 
Index: lemon/bits/base_extender.h
===================================================================
--- lemon/bits/base_extender.h	(revision 57)
+++ lemon/bits/base_extender.h	(revision 57)
@@ -0,0 +1,495 @@
+/* -*- 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_BITS_BASE_EXTENDER_H
+#define LEMON_BITS_BASE_EXTENDER_H
+
+#include <lemon/bits/invalid.h>
+#include <lemon/error.h>
+
+#include <lemon/bits/map_extender.h>
+#include <lemon/bits/default_map.h>
+
+#include <lemon/concept_check.h>
+#include <lemon/concepts/maps.h>
+
+///\ingroup digraphbits
+///\file
+///\brief Extenders for the digraph types
+namespace lemon {
+
+  /// \ingroup digraphbits
+  ///
+  /// \brief BaseDigraph to BaseGraph extender
+  template <typename Base>
+  class UndirDigraphExtender : public Base {
+
+  public:
+
+    typedef Base Parent;
+    typedef typename Parent::Arc Edge;
+    typedef typename Parent::Node Node;
+
+    typedef True UndirectedTag;
+
+    class Arc : public Edge {
+      friend class UndirDigraphExtender;
+
+    protected:
+      bool forward;
+
+      Arc(const Edge &ue, bool _forward) :
+        Edge(ue), forward(_forward) {}
+
+    public:
+      Arc() {}
+
+      /// Invalid arc constructor
+      Arc(Invalid i) : Edge(i), forward(true) {}
+
+      bool operator==(const Arc &that) const {
+	return forward==that.forward && Edge(*this)==Edge(that);
+      }
+      bool operator!=(const Arc &that) const {
+	return forward!=that.forward || Edge(*this)!=Edge(that);
+      }
+      bool operator<(const Arc &that) const {
+	return forward<that.forward ||
+	  (!(that.forward<forward) && Edge(*this)<Edge(that));
+      }
+    };
+
+
+
+    using Parent::source;
+
+    /// Source of the given Arc.
+    Node source(const Arc &e) const {
+      return e.forward ? Parent::source(e) : Parent::target(e);
+    }
+
+    using Parent::target;
+
+    /// Target of the given Arc.
+    Node target(const Arc &e) const {
+      return e.forward ? Parent::target(e) : Parent::source(e);
+    }
+
+    /// \brief Directed arc from an edge.
+    ///
+    /// Returns a directed arc corresponding to the specified Edge.
+    /// If the given bool is true the given edge and the
+    /// returned arc have the same source node.
+    static Arc direct(const Edge &ue, bool d) {
+      return Arc(ue, d);
+    }
+
+    /// Returns whether the given directed arc is same orientation as the
+    /// corresponding edge.
+    ///
+    /// \todo reference to the corresponding point of the undirected digraph
+    /// concept. "What does the direction of an edge mean?"
+    static bool direction(const Arc &e) { return e.forward; }
+
+
+    using Parent::first;
+    using Parent::next;
+
+    void first(Arc &e) const {
+      Parent::first(e);
+      e.forward=true;
+    }
+
+    void next(Arc &e) const {
+      if( e.forward ) {
+	e.forward = false;
+      }
+      else {
+	Parent::next(e);
+	e.forward = true;
+      }
+    }
+
+    void firstOut(Arc &e, const Node &n) const {
+      Parent::firstIn(e,n);
+      if( Edge(e) != INVALID ) {
+	e.forward = false;
+      }
+      else {
+	Parent::firstOut(e,n);
+	e.forward = true;
+      }
+    }
+    void nextOut(Arc &e) const {
+      if( ! e.forward ) {
+	Node n = Parent::target(e);
+	Parent::nextIn(e);
+	if( Edge(e) == INVALID ) {
+	  Parent::firstOut(e, n);
+	  e.forward = true;
+	}
+      }
+      else {
+	Parent::nextOut(e);
+      }
+    }
+
+    void firstIn(Arc &e, const Node &n) const {
+      Parent::firstOut(e,n);
+      if( Edge(e) != INVALID ) {
+	e.forward = false;
+      }
+      else {
+	Parent::firstIn(e,n);
+	e.forward = true;
+      }
+    }
+    void nextIn(Arc &e) const {
+      if( ! e.forward ) {
+	Node n = Parent::source(e);
+	Parent::nextOut(e);
+	if( Edge(e) == INVALID ) {
+	  Parent::firstIn(e, n);
+	  e.forward = true;
+	}
+      }
+      else {
+	Parent::nextIn(e);
+      }
+    }
+
+    void firstInc(Edge &e, bool &d, const Node &n) const {
+      d = true;
+      Parent::firstOut(e, n);
+      if (e != INVALID) return;
+      d = false;
+      Parent::firstIn(e, n);
+    }
+
+    void nextInc(Edge &e, bool &d) const {
+      if (d) {
+	Node s = Parent::source(e);
+	Parent::nextOut(e);
+	if (e != INVALID) return;
+	d = false;
+	Parent::firstIn(e, s);
+      } else {
+	Parent::nextIn(e);
+      }
+    }
+
+    Node nodeFromId(int ix) const {
+      return Parent::nodeFromId(ix);
+    }
+
+    Arc arcFromId(int ix) const {
+      return direct(Parent::arcFromId(ix >> 1), bool(ix & 1));
+    }
+
+    Edge edgeFromId(int ix) const {
+      return Parent::arcFromId(ix);
+    }
+
+    int id(const Node &n) const {
+      return Parent::id(n);
+    }
+
+    int id(const Edge &e) const {
+      return Parent::id(e);
+    }
+
+    int id(const Arc &e) const {
+      return 2 * Parent::id(e) + int(e.forward);
+    }
+
+    int maxNodeId() const {
+      return Parent::maxNodeId();
+    }
+
+    int maxArcId() const {
+      return 2 * Parent::maxArcId() + 1;
+    }
+
+    int maxEdgeId() const {
+      return Parent::maxArcId();
+    }
+
+
+    int arcNum() const {
+      return 2 * Parent::arcNum();
+    }
+
+    int edgeNum() const {
+      return Parent::arcNum();
+    }
+
+    Arc findArc(Node s, Node t, Arc p = INVALID) const {
+      if (p == INVALID) {
+	Edge arc = Parent::findArc(s, t);
+	if (arc != INVALID) return direct(arc, true);
+	arc = Parent::findArc(t, s);
+	if (arc != INVALID) return direct(arc, false);
+      } else if (direction(p)) {
+	Edge arc = Parent::findArc(s, t, p);
+	if (arc != INVALID) return direct(arc, true);
+	arc = Parent::findArc(t, s);
+	if (arc != INVALID) return direct(arc, false);	
+      } else {
+	Edge arc = Parent::findArc(t, s, p);
+	if (arc != INVALID) return direct(arc, false);	      
+      }
+      return INVALID;
+    }
+
+    Edge findEdge(Node s, Node t, Edge p = INVALID) const {
+      if (s != t) {
+        if (p == INVALID) {
+          Edge arc = Parent::findArc(s, t);
+          if (arc != INVALID) return arc;
+          arc = Parent::findArc(t, s);
+          if (arc != INVALID) return arc;
+        } else if (Parent::s(p) == s) {
+          Edge arc = Parent::findArc(s, t, p);
+          if (arc != INVALID) return arc;
+          arc = Parent::findArc(t, s);
+          if (arc != INVALID) return arc;	
+        } else {
+          Edge arc = Parent::findArc(t, s, p);
+          if (arc != INVALID) return arc;	      
+        }
+      } else {
+        return Parent::findArc(s, t, p);
+      }
+      return INVALID;
+    }
+  };
+
+  template <typename Base>
+  class BidirBpGraphExtender : public Base {
+  public:
+    typedef Base Parent;
+    typedef BidirBpGraphExtender Digraph;
+
+    typedef typename Parent::Node Node;
+    typedef typename Parent::Edge Edge;
+
+
+    using Parent::first;
+    using Parent::next;
+
+    using Parent::id;
+
+    class Red : public Node {
+      friend class BidirBpGraphExtender;
+    public:
+      Red() {}
+      Red(const Node& node) : Node(node) {
+	LEMON_ASSERT(Parent::red(node) || node == INVALID, 
+		     typename Parent::NodeSetError());
+      }
+      Red& operator=(const Node& node) {
+	LEMON_ASSERT(Parent::red(node) || node == INVALID, 
+		     typename Parent::NodeSetError());
+        Node::operator=(node);
+        return *this;
+      }
+      Red(Invalid) : Node(INVALID) {}
+      Red& operator=(Invalid) {
+        Node::operator=(INVALID);
+        return *this;
+      }
+    };
+
+    void first(Red& node) const {
+      Parent::firstRed(static_cast<Node&>(node));
+    }
+    void next(Red& node) const {
+      Parent::nextRed(static_cast<Node&>(node));
+    }
+
+    int id(const Red& node) const {
+      return Parent::redId(node);
+    }
+
+    class Blue : public Node {
+      friend class BidirBpGraphExtender;
+    public:
+      Blue() {}
+      Blue(const Node& node) : Node(node) {
+	LEMON_ASSERT(Parent::blue(node) || node == INVALID,
+		     typename Parent::NodeSetError());
+      }
+      Blue& operator=(const Node& node) {
+	LEMON_ASSERT(Parent::blue(node) || node == INVALID, 
+		     typename Parent::NodeSetError());
+        Node::operator=(node);
+        return *this;
+      }
+      Blue(Invalid) : Node(INVALID) {}
+      Blue& operator=(Invalid) {
+        Node::operator=(INVALID);
+        return *this;
+      }
+    };
+
+    void first(Blue& node) const {
+      Parent::firstBlue(static_cast<Node&>(node));
+    }
+    void next(Blue& node) const {
+      Parent::nextBlue(static_cast<Node&>(node));
+    }
+  
+    int id(const Blue& node) const {
+      return Parent::redId(node);
+    }
+
+    Node source(const Edge& arc) const {
+      return red(arc);
+    }
+    Node target(const Edge& arc) const {
+      return blue(arc);
+    }
+
+    void firstInc(Edge& arc, bool& dir, const Node& node) const {
+      if (Parent::red(node)) {
+	Parent::firstFromRed(arc, node);
+	dir = true;
+      } else {
+	Parent::firstFromBlue(arc, node);
+	dir = static_cast<Edge&>(arc) == INVALID;
+      }
+    }
+    void nextInc(Edge& arc, bool& dir) const {
+      if (dir) {
+	Parent::nextFromRed(arc);
+      } else {
+	Parent::nextFromBlue(arc);
+	if (arc == INVALID) dir = true;
+      }
+    }
+
+    class Arc : public Edge {
+      friend class BidirBpGraphExtender;
+    protected:
+      bool forward;
+
+      Arc(const Edge& arc, bool _forward)
+	: Edge(arc), forward(_forward) {}
+
+    public:
+      Arc() {}
+      Arc (Invalid) : Edge(INVALID), forward(true) {}
+      bool operator==(const Arc& i) const {
+	return Edge::operator==(i) && forward == i.forward;
+      }
+      bool operator!=(const Arc& i) const {
+	return Edge::operator!=(i) || forward != i.forward;
+      }
+      bool operator<(const Arc& i) const {
+	return Edge::operator<(i) || 
+	  (!(i.forward<forward) && Edge(*this)<Edge(i));
+      }
+    };
+
+    void first(Arc& arc) const {
+      Parent::first(static_cast<Edge&>(arc));
+      arc.forward = true;
+    }
+
+    void next(Arc& arc) const {
+      if (!arc.forward) {
+	Parent::next(static_cast<Edge&>(arc));
+      }
+      arc.forward = !arc.forward;
+    }
+
+    void firstOut(Arc& arc, const Node& node) const {
+      if (Parent::red(node)) {
+	Parent::firstFromRed(arc, node);
+	arc.forward = true;
+      } else {
+	Parent::firstFromBlue(arc, node);
+	arc.forward = static_cast<Edge&>(arc) == INVALID;
+      }
+    }
+    void nextOut(Arc& arc) const {
+      if (arc.forward) {
+	Parent::nextFromRed(arc);
+      } else {
+	Parent::nextFromBlue(arc);
+        arc.forward = static_cast<Edge&>(arc) == INVALID;
+      }
+    }
+
+    void firstIn(Arc& arc, const Node& node) const {
+      if (Parent::blue(node)) {
+	Parent::firstFromBlue(arc, node);
+	arc.forward = true;	
+      } else {
+	Parent::firstFromRed(arc, node);
+	arc.forward = static_cast<Edge&>(arc) == INVALID;
+      }
+    }
+    void nextIn(Arc& arc) const {
+      if (arc.forward) {
+	Parent::nextFromBlue(arc);
+      } else {
+	Parent::nextFromRed(arc);
+	arc.forward = static_cast<Edge&>(arc) == INVALID;
+      }
+    }
+
+    Node source(const Arc& arc) const {
+      return arc.forward ? Parent::red(arc) : Parent::blue(arc);
+    }
+    Node target(const Arc& arc) const {
+      return arc.forward ? Parent::blue(arc) : Parent::red(arc);
+    }
+
+    int id(const Arc& arc) const {
+      return (Parent::id(static_cast<const Edge&>(arc)) << 1) + 
+        (arc.forward ? 0 : 1);
+    }
+    Arc arcFromId(int ix) const {
+      return Arc(Parent::fromEdgeId(ix >> 1), (ix & 1) == 0);
+    }
+    int maxArcId() const {
+      return (Parent::maxEdgeId() << 1) + 1;
+    }
+
+    bool direction(const Arc& arc) const {
+      return arc.forward;
+    }
+
+    Arc direct(const Edge& arc, bool dir) const {
+      return Arc(arc, dir);
+    }
+
+    int arcNum() const {
+      return 2 * Parent::edgeNum();
+    }
+
+    int edgeNum() const {
+      return Parent::edgeNum();
+    }
+
+
+  };
+}
+
+#endif
Index: lemon/bits/default_map.h
===================================================================
--- lemon/bits/default_map.h	(revision 57)
+++ lemon/bits/default_map.h	(revision 57)
@@ -0,0 +1,181 @@
+/* -*- 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_BITS_DEFAULT_MAP_H
+#define LEMON_BITS_DEFAULT_MAP_H
+
+
+#include <lemon/bits/array_map.h>
+#include <lemon/bits/vector_map.h>
+//#include <lemon/bits/debug_map.h>
+
+///\ingroup graphbits
+///\file
+///\brief Graph maps that construct and destruct their elements dynamically.
+
+namespace lemon {
+  
+  
+  //#ifndef LEMON_USE_DEBUG_MAP
+
+  template <typename _Graph, typename _Item, typename _Value>
+  struct DefaultMapSelector {
+    typedef ArrayMap<_Graph, _Item, _Value> Map;
+  };
+
+  // bool
+  template <typename _Graph, typename _Item>
+  struct DefaultMapSelector<_Graph, _Item, bool> {
+    typedef VectorMap<_Graph, _Item, bool> Map;
+  };
+
+  // char
+  template <typename _Graph, typename _Item>
+  struct DefaultMapSelector<_Graph, _Item, char> {
+    typedef VectorMap<_Graph, _Item, char> Map;
+  };
+
+  template <typename _Graph, typename _Item>
+  struct DefaultMapSelector<_Graph, _Item, signed char> {
+    typedef VectorMap<_Graph, _Item, signed char> Map;
+  };
+
+  template <typename _Graph, typename _Item>
+  struct DefaultMapSelector<_Graph, _Item, unsigned char> {
+    typedef VectorMap<_Graph, _Item, unsigned char> Map;
+  };
+
+
+  // int
+  template <typename _Graph, typename _Item>
+  struct DefaultMapSelector<_Graph, _Item, signed int> {
+    typedef VectorMap<_Graph, _Item, signed int> Map;
+  };
+
+  template <typename _Graph, typename _Item>
+  struct DefaultMapSelector<_Graph, _Item, unsigned int> {
+    typedef VectorMap<_Graph, _Item, unsigned int> Map;
+  };
+
+
+  // short
+  template <typename _Graph, typename _Item>
+  struct DefaultMapSelector<_Graph, _Item, signed short> {
+    typedef VectorMap<_Graph, _Item, signed short> Map;
+  };
+
+  template <typename _Graph, typename _Item>
+  struct DefaultMapSelector<_Graph, _Item, unsigned short> {
+    typedef VectorMap<_Graph, _Item, unsigned short> Map;
+  };
+
+
+  // long
+  template <typename _Graph, typename _Item>
+  struct DefaultMapSelector<_Graph, _Item, signed long> {
+    typedef VectorMap<_Graph, _Item, signed long> Map;
+  };
+
+  template <typename _Graph, typename _Item>
+  struct DefaultMapSelector<_Graph, _Item, unsigned long> {
+    typedef VectorMap<_Graph, _Item, unsigned long> Map;
+  };
+
+
+#if defined __GNUC__ && !defined __STRICT_ANSI__
+
+  // long long
+  template <typename _Graph, typename _Item>
+  struct DefaultMapSelector<_Graph, _Item, signed long long> {
+    typedef VectorMap<_Graph, _Item, signed long long> Map;
+  };
+
+  template <typename _Graph, typename _Item>
+  struct DefaultMapSelector<_Graph, _Item, unsigned long long> {
+    typedef VectorMap<_Graph, _Item, unsigned long long> Map;
+  };
+
+#endif
+
+
+  // float
+  template <typename _Graph, typename _Item>
+  struct DefaultMapSelector<_Graph, _Item, float> {
+    typedef VectorMap<_Graph, _Item, float> Map;
+  };
+
+
+  // double
+  template <typename _Graph, typename _Item>
+  struct DefaultMapSelector<_Graph, _Item, double> {
+    typedef VectorMap<_Graph, _Item,  double> Map;
+  };
+
+
+  // long double
+  template <typename _Graph, typename _Item>
+  struct DefaultMapSelector<_Graph, _Item, long double> {
+    typedef VectorMap<_Graph, _Item, long double> Map;
+  };
+
+
+  // pointer
+  template <typename _Graph, typename _Item, typename _Ptr>
+  struct DefaultMapSelector<_Graph, _Item, _Ptr*> {
+    typedef VectorMap<_Graph, _Item, _Ptr*> Map;
+  };
+
+// #else 
+
+//   template <typename _Graph, typename _Item, typename _Value>
+//   struct DefaultMapSelector {
+//     typedef DebugMap<_Graph, _Item, _Value> Map;
+//   };
+
+// #endif  
+
+  /// \e
+  template <typename _Graph, typename _Item, typename _Value>
+  class DefaultMap 
+    : public DefaultMapSelector<_Graph, _Item, _Value>::Map {
+  public:
+    typedef typename DefaultMapSelector<_Graph, _Item, _Value>::Map Parent;
+    typedef DefaultMap<_Graph, _Item, _Value> Map;
+    
+    typedef typename Parent::Graph Graph;
+    typedef typename Parent::Value Value;
+
+    explicit DefaultMap(const Graph& graph) : Parent(graph) {}
+    DefaultMap(const Graph& graph, const Value& value) 
+      : Parent(graph, value) {}
+
+    DefaultMap& operator=(const DefaultMap& cmap) {
+      return operator=<DefaultMap>(cmap);
+    }
+
+    template <typename CMap>
+    DefaultMap& operator=(const CMap& cmap) {
+      Parent::operator=(cmap);
+      return *this;
+    }
+
+  };
+
+}
+
+#endif
Index: lemon/bits/graph_extender.h
===================================================================
--- lemon/bits/graph_extender.h	(revision 57)
+++ lemon/bits/graph_extender.h	(revision 57)
@@ -0,0 +1,747 @@
+/* -*- 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_BITS_GRAPH_EXTENDER_H
+#define LEMON_BITS_GRAPH_EXTENDER_H
+
+#include <lemon/bits/invalid.h>
+
+#include <lemon/bits/map_extender.h>
+#include <lemon/bits/default_map.h>
+
+#include <lemon/concept_check.h>
+#include <lemon/concepts/maps.h>
+
+///\ingroup graphbits
+///\file
+///\brief Extenders for the digraph types
+namespace lemon {
+
+  /// \ingroup graphbits
+  ///
+  /// \brief Extender for the Digraphs
+  template <typename Base>
+  class DigraphExtender : public Base {
+  public:
+
+    typedef Base Parent;
+    typedef DigraphExtender Digraph;
+
+    // Base extensions
+
+    typedef typename Parent::Node Node;
+    typedef typename Parent::Arc Arc;
+
+    int maxId(Node) const {
+      return Parent::maxNodeId();
+    }
+
+    int maxId(Arc) const {
+      return Parent::maxArcId();
+    }
+
+    Node fromId(int id, Node) const {
+      return Parent::nodeFromId(id);
+    }
+
+    Arc fromId(int id, Arc) const {
+      return Parent::arcFromId(id);
+    }
+
+    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);
+      else
+	return INVALID;
+    }
+
+    // Alterable extension
+
+    typedef AlterationNotifier<DigraphExtender, Node> NodeNotifier;
+    typedef AlterationNotifier<DigraphExtender, Arc> ArcNotifier;
+
+
+  protected:
+
+    mutable NodeNotifier node_notifier;
+    mutable ArcNotifier arc_notifier;
+
+  public:
+
+    NodeNotifier& notifier(Node) const {
+      return node_notifier;
+    }
+    
+    ArcNotifier& notifier(Arc) const {
+      return arc_notifier;
+    }
+
+    class NodeIt : public Node { 
+      const Digraph* digraph;
+    public:
+
+      NodeIt() {}
+
+      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) {}
+
+      NodeIt& operator++() { 
+	digraph->next(*this);
+	return *this; 
+      }
+
+    };
+
+
+    class ArcIt : public Arc { 
+      const Digraph* digraph;
+    public:
+
+      ArcIt() { }
+
+      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) { }
+
+      ArcIt& operator++() { 
+	digraph->next(*this);
+	return *this; 
+      }
+
+    };
+
+
+    class OutArcIt : public Arc { 
+      const Digraph* digraph;
+    public:
+
+      OutArcIt() { }
+
+      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& operator++() { 
+	digraph->nextOut(*this);
+	return *this; 
+      }
+
+    };
+
+
+    class InArcIt : public Arc { 
+      const Digraph* digraph;
+    public:
+
+      InArcIt() { }
+
+      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& operator++() { 
+	digraph->nextIn(*this);
+	return *this; 
+      }
+
+    };
+
+    /// \brief Base node of the iterator
+    ///
+    /// Returns the base node (i.e. the source in this case) of the iterator
+    Node baseNode(const OutArcIt &e) const {
+      return Parent::source(e);
+    }
+    /// \brief Running node of the iterator
+    ///
+    /// Returns the running node (i.e. the target in this case) of the
+    /// iterator
+    Node runningNode(const OutArcIt &e) const {
+      return Parent::target(e);
+    }
+
+    /// \brief Base node of the iterator
+    ///
+    /// Returns the base node (i.e. the target in this case) of the iterator
+    Node baseNode(const InArcIt &e) const {
+      return Parent::target(e);
+    }
+    /// \brief Running node of the iterator
+    ///
+    /// Returns the running node (i.e. the source in this case) of the
+    /// iterator
+    Node runningNode(const InArcIt &e) const {
+      return Parent::source(e);
+    }
+
+    
+    template <typename _Value>
+    class NodeMap 
+      : public MapExtender<DefaultMap<Digraph, Node, _Value> > {
+    public:
+      typedef DigraphExtender Digraph;
+      typedef MapExtender<DefaultMap<Digraph, Node, _Value> > Parent;
+
+      explicit NodeMap(const Digraph& digraph) 
+	: Parent(digraph) {}
+      NodeMap(const Digraph& digraph, const _Value& value) 
+	: Parent(digraph, value) {}
+
+      NodeMap& operator=(const NodeMap& cmap) {
+	return operator=<NodeMap>(cmap);
+      }
+
+      template <typename CMap>
+      NodeMap& operator=(const CMap& cmap) {
+        Parent::operator=(cmap);
+	return *this;
+      }
+
+    };
+
+    template <typename _Value>
+    class ArcMap 
+      : public MapExtender<DefaultMap<Digraph, Arc, _Value> > {
+    public:
+      typedef DigraphExtender Digraph;
+      typedef MapExtender<DefaultMap<Digraph, Arc, _Value> > Parent;
+
+      explicit ArcMap(const Digraph& digraph) 
+	: Parent(digraph) {}
+      ArcMap(const Digraph& digraph, const _Value& value) 
+	: Parent(digraph, value) {}
+
+      ArcMap& operator=(const ArcMap& cmap) {
+	return operator=<ArcMap>(cmap);
+      }
+
+      template <typename CMap>
+      ArcMap& operator=(const CMap& cmap) {
+        Parent::operator=(cmap);
+	return *this;
+      }
+    };
+
+
+    Node addNode() {
+      Node node = Parent::addNode();
+      notifier(Node()).add(node);
+      return node;
+    }
+    
+    Arc addArc(const Node& from, const Node& to) {
+      Arc arc = Parent::addArc(from, to);
+      notifier(Arc()).add(arc);
+      return arc;
+    }
+
+    void clear() {
+      notifier(Arc()).clear();
+      notifier(Node()).clear();
+      Parent::clear();
+    }
+
+    template <typename Digraph, typename NodeRefMap, typename ArcRefMap>
+    void build(const Digraph& digraph, NodeRefMap& nodeRef, ArcRefMap& arcRef) {
+      Parent::build(digraph, nodeRef, arcRef);
+      notifier(Node()).build();
+      notifier(Arc()).build();
+    }
+
+    void erase(const Node& node) {
+      Arc arc;
+      Parent::firstOut(arc, node);
+      while (arc != INVALID ) {
+	erase(arc);
+	Parent::firstOut(arc, node);
+      } 
+
+      Parent::firstIn(arc, node);
+      while (arc != INVALID ) {
+	erase(arc);
+	Parent::firstIn(arc, node);
+      }
+
+      notifier(Node()).erase(node);
+      Parent::erase(node);
+    }
+    
+    void erase(const Arc& arc) {
+      notifier(Arc()).erase(arc);
+      Parent::erase(arc);
+    }
+
+    DigraphExtender() {
+      node_notifier.setContainer(*this);
+      arc_notifier.setContainer(*this);
+    } 
+    
+
+    ~DigraphExtender() {
+      arc_notifier.clear();
+      node_notifier.clear();
+    }
+  };
+
+  /// \ingroup graphbits
+  ///
+  /// \brief Extender for the Graphs
+  template <typename Base> 
+  class GraphExtender : public Base {
+  public:
+    
+    typedef Base Parent;
+    typedef GraphExtender Digraph;
+
+    typedef typename Parent::Node Node;
+    typedef typename Parent::Arc Arc;
+    typedef typename Parent::Edge Edge;
+
+    // Graph extension    
+
+    int maxId(Node) const {
+      return Parent::maxNodeId();
+    }
+
+    int maxId(Arc) const {
+      return Parent::maxArcId();
+    }
+
+    int maxId(Edge) const {
+      return Parent::maxEdgeId();
+    }
+
+    Node fromId(int id, Node) const {
+      return Parent::nodeFromId(id);
+    }
+
+    Arc fromId(int id, Arc) const {
+      return Parent::arcFromId(id);
+    }
+
+    Edge fromId(int id, Edge) const {
+      return Parent::edgeFromId(id);
+    }
+
+    Node oppositeNode(const Node &n, const Edge &e) const {
+      if( n == Parent::source(e))
+	return Parent::target(e);
+      else if( n == Parent::target(e))
+	return Parent::source(e);
+      else
+	return INVALID;
+    }
+
+    Arc oppositeArc(const Arc &e) const {
+      return Parent::direct(e, !Parent::direction(e));
+    }
+
+    using Parent::direct;
+    Arc direct(const Edge &ue, const Node &s) const {
+      return Parent::direct(ue, Parent::source(ue) == s);
+    }
+
+    // Alterable extension
+
+    typedef AlterationNotifier<GraphExtender, Node> NodeNotifier;
+    typedef AlterationNotifier<GraphExtender, Arc> ArcNotifier;
+    typedef AlterationNotifier<GraphExtender, Edge> EdgeNotifier;
+
+
+  protected:
+
+    mutable NodeNotifier node_notifier;
+    mutable ArcNotifier arc_notifier;
+    mutable EdgeNotifier edge_notifier;
+
+  public:
+
+    NodeNotifier& notifier(Node) const {
+      return node_notifier;
+    }
+    
+    ArcNotifier& notifier(Arc) const {
+      return arc_notifier;
+    }
+
+    EdgeNotifier& notifier(Edge) const {
+      return edge_notifier;
+    }
+
+
+
+    class NodeIt : public Node { 
+      const Digraph* digraph;
+    public:
+
+      NodeIt() {}
+
+      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) {}
+
+      NodeIt& operator++() { 
+	digraph->next(*this);
+	return *this; 
+      }
+
+    };
+
+
+    class ArcIt : public Arc { 
+      const Digraph* digraph;
+    public:
+
+      ArcIt() { }
+
+      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) { }
+
+      ArcIt& operator++() { 
+	digraph->next(*this);
+	return *this; 
+      }
+
+    };
+
+
+    class OutArcIt : public Arc { 
+      const Digraph* digraph;
+    public:
+
+      OutArcIt() { }
+
+      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& operator++() { 
+	digraph->nextOut(*this);
+	return *this; 
+      }
+
+    };
+
+
+    class InArcIt : public Arc { 
+      const Digraph* digraph;
+    public:
+
+      InArcIt() { }
+
+      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& operator++() { 
+	digraph->nextIn(*this);
+	return *this; 
+      }
+
+    };
+
+
+    class EdgeIt : public Parent::Edge { 
+      const Digraph* digraph;
+    public:
+
+      EdgeIt() { }
+
+      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) { }
+
+      EdgeIt& operator++() { 
+	digraph->next(*this);
+	return *this; 
+      }
+
+    };
+
+    class IncArcIt : 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);
+	return *this; 
+      }
+    };
+
+    /// \brief Base node of the iterator
+    ///
+    /// 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));
+    }
+    /// \brief Running node of the iterator
+    ///
+    /// 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));
+    }
+
+    /// \brief Base node of the iterator
+    ///
+    /// 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));
+    }
+    /// \brief Running node of the iterator
+    ///
+    /// 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));
+    }
+
+    /// Base node of the iterator
+    ///
+    /// Returns the base node of the iterator
+    Node baseNode(const IncArcIt &e) const {
+      return e.direction ? source(e) : target(e);
+    }
+    /// 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);
+    }
+
+    // Mappable extension
+
+    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) {}
+
+      NodeMap& operator=(const NodeMap& cmap) {
+	return operator=<NodeMap>(cmap);
+      }
+
+      template <typename CMap>
+      NodeMap& operator=(const CMap& cmap) {
+        Parent::operator=(cmap);
+	return *this;
+      }
+
+    };
+
+    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) {}
+
+      ArcMap& operator=(const ArcMap& cmap) {
+	return operator=<ArcMap>(cmap);
+      }
+
+      template <typename CMap>
+      ArcMap& operator=(const CMap& cmap) {
+        Parent::operator=(cmap);
+	return *this;
+      }
+    };
+
+
+    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) {}
+
+      EdgeMap& operator=(const EdgeMap& cmap) {
+	return operator=<EdgeMap>(cmap);
+      }
+
+      template <typename CMap>
+      EdgeMap& operator=(const CMap& cmap) {
+        Parent::operator=(cmap);
+	return *this;
+      }
+
+    };
+
+    // Alteration extension
+
+    Node addNode() {
+      Node node = Parent::addNode();
+      notifier(Node()).add(node);
+      return node;
+    }
+
+    Edge addEdge(const Node& from, const Node& to) {
+      Edge edge = Parent::addEdge(from, to);
+      notifier(Edge()).add(edge);
+      std::vector<Arc> ev;
+      ev.push_back(Parent::direct(edge, true));
+      ev.push_back(Parent::direct(edge, false));      
+      notifier(Arc()).add(ev);
+      return edge;
+    }
+    
+    void clear() {
+      notifier(Arc()).clear();
+      notifier(Edge()).clear();
+      notifier(Node()).clear();
+      Parent::clear();
+    }
+
+    template <typename Digraph, typename NodeRefMap, typename EdgeRefMap>
+    void build(const Digraph& digraph, NodeRefMap& nodeRef, 
+               EdgeRefMap& edgeRef) {
+      Parent::build(digraph, nodeRef, edgeRef);
+      notifier(Node()).build();
+      notifier(Edge()).build();
+      notifier(Arc()).build();
+    }
+
+    void erase(const Node& node) {
+      Arc arc;
+      Parent::firstOut(arc, node);
+      while (arc != INVALID ) {
+	erase(arc);
+	Parent::firstOut(arc, node);
+      } 
+
+      Parent::firstIn(arc, node);
+      while (arc != INVALID ) {
+	erase(arc);
+	Parent::firstIn(arc, node);
+      }
+
+      notifier(Node()).erase(node);
+      Parent::erase(node);
+    }
+
+    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);
+      notifier(Edge()).erase(edge);
+      Parent::erase(edge);
+    }
+
+    GraphExtender() {
+      node_notifier.setContainer(*this); 
+      arc_notifier.setContainer(*this);
+      edge_notifier.setContainer(*this);
+    } 
+
+    ~GraphExtender() {
+      edge_notifier.clear();
+      arc_notifier.clear();
+      node_notifier.clear(); 
+    } 
+
+  };
+
+}
+
+#endif
Index: lemon/bits/map_extender.h
===================================================================
--- lemon/bits/map_extender.h	(revision 57)
+++ lemon/bits/map_extender.h	(revision 57)
@@ -0,0 +1,321 @@
+/* -*- 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_BITS_MAP_EXTENDER_H
+#define LEMON_BITS_MAP_EXTENDER_H
+
+#include <iterator>
+
+#include <lemon/bits/traits.h>
+
+#include <lemon/concept_check.h>
+#include <lemon/concepts/maps.h>
+
+///\file
+///\brief Extenders for iterable maps.
+
+namespace lemon {
+
+  /// \ingroup graphbits
+  /// 
+  /// \brief Extender for maps
+  template <typename _Map>
+  class MapExtender : public _Map {
+  public:
+
+    typedef _Map Parent;
+    typedef MapExtender Map;
+
+
+    typedef typename Parent::Graph Graph;
+    typedef typename Parent::Key Item;
+
+    typedef typename Parent::Key Key;
+    typedef typename Parent::Value Value;
+
+    class MapIt;
+    class ConstMapIt;
+
+    friend class MapIt;
+    friend class ConstMapIt;
+
+  public:
+
+    MapExtender(const Graph& graph) 
+      : Parent(graph) {}
+
+    MapExtender(const Graph& graph, const Value& value) 
+      : Parent(graph, value) {}
+
+    MapExtender& operator=(const MapExtender& cmap) {
+      return operator=<MapExtender>(cmap);
+    }
+
+    template <typename CMap>
+    MapExtender& operator=(const CMap& cmap) {
+      Parent::operator=(cmap);
+      return *this;
+    } 
+
+    class MapIt : public Item {
+    public:
+      
+      typedef Item Parent;
+      typedef typename Map::Value Value;
+      
+      MapIt() {}
+
+      MapIt(Invalid i) : Parent(i) { }
+
+      explicit MapIt(Map& _map) : map(_map) {
+        map.notifier()->first(*this);
+      }
+
+      MapIt(const Map& _map, const Item& item) 
+	: Parent(item), map(_map) {}
+
+      MapIt& operator++() { 
+	map.notifier()->next(*this);
+	return *this; 
+      }
+      
+      typename MapTraits<Map>::ConstReturnValue operator*() const {
+	return map[*this];
+      }
+
+      typename MapTraits<Map>::ReturnValue operator*() {
+	return map[*this];
+      }
+      
+      void set(const Value& value) {
+	map.set(*this, value);
+      }
+      
+    protected:
+      Map& map;
+      
+    };
+
+    class ConstMapIt : public Item {
+    public:
+
+      typedef Item Parent;
+
+      typedef typename Map::Value Value;
+      
+      ConstMapIt() {}
+
+      ConstMapIt(Invalid i) : Parent(i) { }
+
+      explicit ConstMapIt(Map& _map) : map(_map) {
+        map.notifier()->first(*this);
+      }
+
+      ConstMapIt(const Map& _map, const Item& item) 
+	: Parent(item), map(_map) {}
+
+      ConstMapIt& operator++() { 
+	map.notifier()->next(*this);
+	return *this; 
+      }
+
+      typename MapTraits<Map>::ConstReturnValue operator*() const {
+	return map[*this];
+      }
+
+    protected:
+      const Map& map;
+    };
+
+    class ItemIt : public Item {
+    public:
+      
+      typedef Item Parent;
+      
+      ItemIt() {}
+
+      ItemIt(Invalid i) : Parent(i) { }
+
+      explicit ItemIt(Map& _map) : map(_map) {
+        map.notifier()->first(*this);
+      }
+
+      ItemIt(const Map& _map, const Item& item) 
+	: Parent(item), map(_map) {}
+
+      ItemIt& operator++() { 
+	map.notifier()->next(*this);
+	return *this; 
+      }
+
+    protected:
+      const Map& map;
+      
+    };
+  };
+
+  /// \ingroup graphbits
+  /// 
+  /// \brief Extender for maps which use a subset of the items.
+  template <typename _Graph, typename _Map>
+  class SubMapExtender : public _Map {
+  public:
+
+    typedef _Map Parent;
+    typedef SubMapExtender Map;
+
+    typedef _Graph Graph;
+
+    typedef typename Parent::Key Item;
+
+    typedef typename Parent::Key Key;
+    typedef typename Parent::Value Value;
+
+    class MapIt;
+    class ConstMapIt;
+
+    friend class MapIt;
+    friend class ConstMapIt;
+
+  public:
+
+    SubMapExtender(const Graph& _graph) 
+      : Parent(_graph), graph(_graph) {}
+
+    SubMapExtender(const Graph& _graph, const Value& _value) 
+      : Parent(_graph, _value), graph(_graph) {}
+
+    SubMapExtender& operator=(const SubMapExtender& cmap) {
+      return operator=<MapExtender>(cmap);
+    }
+
+    template <typename CMap>
+    SubMapExtender& operator=(const CMap& cmap) {
+      checkConcept<concepts::ReadMap<Key, Value>, CMap>();
+      Item it;
+      for (graph.first(it); it != INVALID; graph.next(it)) {
+        Parent::set(it, cmap[it]);
+      }
+      return *this;
+    } 
+
+    class MapIt : public Item {
+    public:
+      
+      typedef Item Parent;
+      typedef typename Map::Value Value;
+      
+      MapIt() {}
+
+      MapIt(Invalid i) : Parent(i) { }
+
+      explicit MapIt(Map& _map) : map(_map) {
+        map.graph.first(*this);
+      }
+
+      MapIt(const Map& _map, const Item& item) 
+	: Parent(item), map(_map) {}
+
+      MapIt& operator++() { 
+	map.graph.next(*this);
+	return *this; 
+      }
+      
+      typename MapTraits<Map>::ConstReturnValue operator*() const {
+	return map[*this];
+      }
+
+      typename MapTraits<Map>::ReturnValue operator*() {
+	return map[*this];
+      }
+      
+      void set(const Value& value) {
+	map.set(*this, value);
+      }
+      
+    protected:
+      Map& map;
+      
+    };
+
+    class ConstMapIt : public Item {
+    public:
+
+      typedef Item Parent;
+
+      typedef typename Map::Value Value;
+      
+      ConstMapIt() {}
+
+      ConstMapIt(Invalid i) : Parent(i) { }
+
+      explicit ConstMapIt(Map& _map) : map(_map) {
+        map.graph.first(*this);
+      }
+
+      ConstMapIt(const Map& _map, const Item& item) 
+	: Parent(item), map(_map) {}
+
+      ConstMapIt& operator++() { 
+	map.graph.next(*this);
+	return *this; 
+      }
+
+      typename MapTraits<Map>::ConstReturnValue operator*() const {
+	return map[*this];
+      }
+
+    protected:
+      const Map& map;
+    };
+
+    class ItemIt : public Item {
+    public:
+      
+      typedef Item Parent;
+      
+      ItemIt() {}
+
+      ItemIt(Invalid i) : Parent(i) { }
+
+      explicit ItemIt(Map& _map) : map(_map) {
+        map.graph.first(*this);
+      }
+
+      ItemIt(const Map& _map, const Item& item) 
+	: Parent(item), map(_map) {}
+
+      ItemIt& operator++() { 
+	map.graph.next(*this);
+	return *this; 
+      }
+
+    protected:
+      const Map& map;
+      
+    };
+    
+  private:
+
+    const Graph& graph;
+    
+  };
+
+}
+
+#endif
Index: lemon/bits/traits.h
===================================================================
--- lemon/bits/traits.h	(revision 57)
+++ lemon/bits/traits.h	(revision 57)
@@ -0,0 +1,272 @@
+
+/* -*- 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_BITS_TRAITS_H
+#define LEMON_BITS_TRAITS_H
+
+#include <lemon/bits/utility.h>
+
+///\file
+///\brief Traits for graphs and maps
+///
+
+namespace lemon {
+  template <typename _Graph, typename _Item>
+  class ItemSetTraits {};
+  
+
+  template <typename Graph, typename Enable = void>
+  struct NodeNotifierIndicator {
+    typedef InvalidType Type;
+  };
+  template <typename Graph>
+  struct NodeNotifierIndicator<
+    Graph, 
+    typename enable_if<typename Graph::NodeNotifier::Notifier, void>::type
+  > { 
+    typedef typename Graph::NodeNotifier Type;
+  };
+
+  template <typename _Graph>
+  class ItemSetTraits<_Graph, typename _Graph::Node> {
+  public:
+    
+    typedef _Graph Graph;
+
+    typedef typename Graph::Node Item;
+    typedef typename Graph::NodeIt ItemIt;
+
+    typedef typename NodeNotifierIndicator<Graph>::Type ItemNotifier;
+
+    template <typename _Value>
+    class Map : public Graph::template NodeMap<_Value> {
+    public:
+      typedef typename Graph::template NodeMap<_Value> Parent; 
+      typedef typename Graph::template NodeMap<_Value> Type; 
+      typedef typename Parent::Value Value;
+
+      Map(const Graph& _digraph) : Parent(_digraph) {}
+      Map(const Graph& _digraph, const Value& _value) 
+	: Parent(_digraph, _value) {}
+
+     };
+
+  };
+
+  template <typename Graph, typename Enable = void>
+  struct ArcNotifierIndicator {
+    typedef InvalidType Type;
+  };
+  template <typename Graph>
+  struct ArcNotifierIndicator<
+    Graph, 
+    typename enable_if<typename Graph::ArcNotifier::Notifier, void>::type
+  > { 
+    typedef typename Graph::ArcNotifier Type;
+  };
+
+  template <typename _Graph>
+  class ItemSetTraits<_Graph, typename _Graph::Arc> {
+  public:
+    
+    typedef _Graph Graph;
+
+    typedef typename Graph::Arc Item;
+    typedef typename Graph::ArcIt ItemIt;
+
+    typedef typename ArcNotifierIndicator<Graph>::Type ItemNotifier;
+
+    template <typename _Value>
+    class Map : public Graph::template ArcMap<_Value> {
+    public:
+      typedef typename Graph::template ArcMap<_Value> Parent; 
+      typedef typename Graph::template ArcMap<_Value> Type; 
+      typedef typename Parent::Value Value;
+
+      Map(const Graph& _digraph) : Parent(_digraph) {}
+      Map(const Graph& _digraph, const Value& _value) 
+	: Parent(_digraph, _value) {}
+    };
+
+  };
+
+  template <typename Graph, typename Enable = void>
+  struct EdgeNotifierIndicator {
+    typedef InvalidType Type;
+  };
+  template <typename Graph>
+  struct EdgeNotifierIndicator<
+    Graph, 
+    typename enable_if<typename Graph::EdgeNotifier::Notifier, void>::type
+  > { 
+    typedef typename Graph::EdgeNotifier Type;
+  };
+
+  template <typename _Graph>
+  class ItemSetTraits<_Graph, typename _Graph::Edge> {
+  public:
+    
+    typedef _Graph Graph;
+
+    typedef typename Graph::Edge Item;
+    typedef typename Graph::EdgeIt ItemIt;
+
+    typedef typename EdgeNotifierIndicator<Graph>::Type ItemNotifier;
+
+    template <typename _Value>
+    class Map : public Graph::template EdgeMap<_Value> {
+    public:
+      typedef typename Graph::template EdgeMap<_Value> Parent; 
+      typedef typename Graph::template EdgeMap<_Value> Type; 
+      typedef typename Parent::Value Value;
+
+      Map(const Graph& _digraph) : Parent(_digraph) {}
+      Map(const Graph& _digraph, const Value& _value) 
+	: Parent(_digraph, _value) {}
+    };
+
+  };
+
+  template <typename Map, typename Enable = void>
+  struct MapTraits {
+    typedef False ReferenceMapTag;
+
+    typedef typename Map::Key Key;
+    typedef typename Map::Value Value;
+
+    typedef const Value ConstReturnValue;
+    typedef const Value ReturnValue;
+  };
+
+  template <typename Map>
+  struct MapTraits<
+    Map, typename enable_if<typename Map::ReferenceMapTag, void>::type > 
+  {
+    typedef True ReferenceMapTag;
+    
+    typedef typename Map::Key Key;
+    typedef typename Map::Value Value;
+
+    typedef typename Map::ConstReference ConstReturnValue;
+    typedef typename Map::Reference ReturnValue;
+
+    typedef typename Map::ConstReference ConstReference; 
+    typedef typename Map::Reference Reference;
+ };
+
+  template <typename MatrixMap, typename Enable = void>
+  struct MatrixMapTraits {
+    typedef False ReferenceMapTag;
+
+    typedef typename MatrixMap::FirstKey FirstKey;
+    typedef typename MatrixMap::SecondKey SecondKey;
+    typedef typename MatrixMap::Value Value;
+
+    typedef const Value ConstReturnValue;
+    typedef const Value ReturnValue;
+  };
+
+  template <typename MatrixMap>
+  struct MatrixMapTraits<
+    MatrixMap, typename enable_if<typename MatrixMap::ReferenceMapTag, 
+                                  void>::type > 
+  {
+    typedef True ReferenceMapTag;
+    
+    typedef typename MatrixMap::FirstKey FirstKey;
+    typedef typename MatrixMap::SecondKey SecondKey;
+    typedef typename MatrixMap::Value Value;
+
+    typedef typename MatrixMap::ConstReference ConstReturnValue;
+    typedef typename MatrixMap::Reference ReturnValue;
+
+    typedef typename MatrixMap::ConstReference ConstReference; 
+    typedef typename MatrixMap::Reference Reference;
+ };
+
+  // Indicators for the tags
+
+  template <typename Graph, typename Enable = void>
+  struct NodeNumTagIndicator {
+    static const bool value = false;
+  };
+
+  template <typename Graph>
+  struct NodeNumTagIndicator<
+    Graph, 
+    typename enable_if<typename Graph::NodeNumTag, void>::type
+  > {
+    static const bool value = true;
+  };
+
+  template <typename Graph, typename Enable = void>
+  struct ArcNumTagIndicator {
+    static const bool value = false;
+  };
+
+  template <typename Graph>
+  struct ArcNumTagIndicator<
+    Graph, 
+    typename enable_if<typename Graph::ArcNumTag, void>::type
+  > {
+    static const bool value = true;
+  };
+
+  template <typename Graph, typename Enable = void>
+  struct FindArcTagIndicator {
+    static const bool value = false;
+  };
+
+  template <typename Graph>
+  struct FindArcTagIndicator<
+    Graph, 
+    typename enable_if<typename Graph::FindArcTag, void>::type
+  > {
+    static const bool value = true;
+  };
+
+  template <typename Graph, typename Enable = void>
+  struct UndirectedTagIndicator {
+    static const bool value = false;
+  };
+
+  template <typename Graph>
+  struct UndirectedTagIndicator<
+    Graph, 
+    typename enable_if<typename Graph::UndirectedTag, void>::type
+  > {
+    static const bool value = true;
+  };
+
+  template <typename Graph, typename Enable = void>
+  struct BuildTagIndicator {
+    static const bool value = false;
+  };
+
+  template <typename Graph>
+  struct BuildTagIndicator<
+    Graph, 
+    typename enable_if<typename Graph::BuildTag, void>::type
+  > {
+    static const bool value = true;
+  };
+
+}
+
+#endif
Index: lemon/bits/vector_map.h
===================================================================
--- lemon/bits/vector_map.h	(revision 57)
+++ lemon/bits/vector_map.h	(revision 57)
@@ -0,0 +1,243 @@
+/* -*- 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_BITS_VECTOR_MAP_H
+#define LEMON_BITS_VECTOR_MAP_H
+
+#include <vector>
+#include <algorithm>
+
+#include <lemon/bits/traits.h>
+#include <lemon/bits/utility.h>
+
+#include <lemon/bits/alteration_notifier.h>
+
+#include <lemon/concept_check.h>
+#include <lemon/concepts/maps.h>
+
+///\ingroup graphbits
+///
+///\file
+///\brief Vector based graph maps.
+namespace lemon {
+
+  /// \ingroup graphbits
+  ///
+  /// \brief Graph map based on the std::vector storage.
+  ///
+  /// The VectorMap template class is graph map structure what
+  /// automatically updates the map when a key is added to or erased from
+  /// the map. This map type uses the std::vector to store the values.
+  ///
+  /// \param Notifier The AlterationNotifier that will notify this map.
+  /// \param Item The item type of the graph items.
+  /// \param Value The value type of the map.
+  /// 
+  /// \author Balazs Dezso  	
+  template <typename _Graph, typename _Item, typename _Value>
+  class VectorMap 
+    : public ItemSetTraits<_Graph, _Item>::ItemNotifier::ObserverBase {
+  private:
+		
+    /// The container type of the map.
+    typedef std::vector<_Value> Container;	
+
+  public:
+
+    /// The graph type of the map. 
+    typedef _Graph Graph;
+    /// The item type of the map.
+    typedef _Item Item;
+    /// The reference map tag.
+    typedef True ReferenceMapTag;
+
+    /// The key type of the map.
+    typedef _Item Key;
+    /// The value type of the map.
+    typedef _Value Value;
+
+    /// The notifier type.
+    typedef typename ItemSetTraits<_Graph, _Item>::ItemNotifier Notifier;
+
+    /// The map type.
+    typedef VectorMap Map;
+    /// The base class of the map.
+    typedef typename Notifier::ObserverBase Parent;
+
+    /// The reference type of the map;
+    typedef typename Container::reference Reference;
+    /// The const reference type of the map;
+    typedef typename Container::const_reference ConstReference;
+
+
+    /// \brief Constructor to attach the new map into the notifier.
+    ///
+    /// It constructs a map and attachs it into the notifier.
+    /// It adds all the items of the graph to the map.
+    VectorMap(const Graph& graph) {
+      Parent::attach(graph.notifier(Item()));
+      container.resize(Parent::notifier()->maxId() + 1);
+    }
+
+    /// \brief Constructor uses given value to initialize the map. 
+    ///
+    /// It constructs a map uses a given value to initialize the map. 
+    /// It adds all the items of the graph to the map.
+    VectorMap(const Graph& graph, const Value& value) {
+      Parent::attach(graph.notifier(Item()));
+      container.resize(Parent::notifier()->maxId() + 1, value);
+    }
+
+    /// \brief Copy constructor
+    ///
+    /// Copy constructor.
+    VectorMap(const VectorMap& _copy) : Parent() {
+      if (_copy.attached()) {
+	Parent::attach(*_copy.notifier());
+	container = _copy.container;
+      }
+    }
+
+    /// \brief Assign operator.
+    ///
+    /// This operator assigns for each item in the map the
+    /// value mapped to the same item in the copied map.  
+    /// The parameter map should be indiced with the same
+    /// itemset because this assign operator does not change
+    /// the container of the map. 
+    VectorMap& operator=(const VectorMap& cmap) {
+      return operator=<VectorMap>(cmap);
+    }
+
+
+    /// \brief Template assign operator.
+    ///
+    /// The given parameter should be conform to the ReadMap
+    /// concecpt and could be indiced by the current item set of
+    /// the NodeMap. In this case the value for each item
+    /// is assigned by the value of the given ReadMap. 
+    template <typename CMap>
+    VectorMap& operator=(const CMap& cmap) {
+      checkConcept<concepts::ReadMap<Key, _Value>, CMap>();
+      const typename Parent::Notifier* nf = Parent::notifier();
+      Item it;
+      for (nf->first(it); it != INVALID; nf->next(it)) {
+        set(it, cmap[it]);
+      }
+      return *this;
+    }
+    
+  public:
+
+    /// \brief The subcript operator.
+    ///
+    /// The subscript operator. The map can be subscripted by the
+    /// actual items of the graph.      
+    Reference operator[](const Key& key) {
+      return container[Parent::notifier()->id(key)];
+    } 
+		
+    /// \brief The const subcript operator.
+    ///
+    /// The const subscript operator. The map can be subscripted by the
+    /// actual items of the graph. 
+    ConstReference operator[](const Key& key) const {
+      return container[Parent::notifier()->id(key)];
+    }
+
+
+    /// \brief The setter function of the map.
+    ///
+    /// It the same as operator[](key) = value expression.
+    void set(const Key& key, const Value& value) {
+      (*this)[key] = value;
+    }
+
+  protected:
+
+    /// \brief Adds a new key to the map.
+    ///		
+    /// It adds a new key to the map. It called by the observer notifier
+    /// and it overrides the add() member function of the observer base.     
+    virtual void add(const Key& key) {
+      int id = Parent::notifier()->id(key);
+      if (id >= int(container.size())) {
+	container.resize(id + 1);
+      }
+    }
+
+    /// \brief Adds more new keys to the map.
+    ///		
+    /// It adds more new keys to the map. It called by the observer notifier
+    /// and it overrides the add() member function of the observer base.     
+    virtual void add(const std::vector<Key>& keys) {
+      int max = container.size() - 1;
+      for (int i = 0; i < int(keys.size()); ++i) {
+        int id = Parent::notifier()->id(keys[i]);
+        if (id >= max) {
+          max = id;
+        }
+      }
+      container.resize(max + 1);
+    }
+
+    /// \brief Erase a key from the map.
+    ///
+    /// Erase a key from the map. It called by the observer notifier
+    /// and it overrides the erase() member function of the observer base.     
+    virtual void erase(const Key& key) {
+      container[Parent::notifier()->id(key)] = Value();
+    }
+
+    /// \brief Erase more keys from the map.
+    ///
+    /// Erase more keys from the map. It called by the observer notifier
+    /// and it overrides the erase() member function of the observer base.     
+    virtual void erase(const std::vector<Key>& keys) {
+      for (int i = 0; i < int(keys.size()); ++i) {
+	container[Parent::notifier()->id(keys[i])] = Value();
+      }
+    }
+    
+    /// \brief Buildes the map.
+    ///	
+    /// It buildes the map. It called by the observer notifier
+    /// and it overrides the build() member function of the observer base.
+    virtual void build() { 
+      int size = Parent::notifier()->maxId() + 1;
+      container.reserve(size);
+      container.resize(size);
+    }
+
+    /// \brief Clear the map.
+    ///
+    /// It erase all items from the map. It called by the observer notifier
+    /// and it overrides the clear() member function of the observer base.     
+    virtual void clear() { 
+      container.clear();
+    }
+    
+  private:
+		
+    Container container;
+
+  };
+
+}
+
+#endif
