Index: src/hugo/array_map_factory.h
===================================================================
--- src/hugo/array_map_factory.h	(revision 782)
+++ src/hugo/array_map_factory.h	(revision 782)
@@ -0,0 +1,366 @@
+// -*- c++ -*-
+#ifndef ARRAY_MAP_FACTORY_H
+#define ARRAY_MAP_FACTORY_H
+
+#include <memory>
+
+#include <hugo/extended_pair.h>
+
+namespace hugo {
+	
+  template <typename MapRegistry> class ArrayMapFactory {
+		
+  public:
+		
+    typedef typename MapRegistry::Graph Graph;
+    typedef typename MapRegistry::Key Key;
+    typedef typename MapRegistry::KeyIt KeyIt;
+
+    typedef typename MapRegistry::MapBase MapBase;
+		
+    template <typename V, typename A = std::allocator<V> > 
+    class Map : public MapBase {
+    
+      public:
+
+      typedef V Value;
+      typedef A Allocator;
+
+	
+      Map() : values(0), capacity(0) {}
+			
+      Map(const Graph& g, MapRegistry& r) : MapBase(g, r) {
+	allocate_memory();
+	for (KeyIt it(*MapBase::getGraph()); it != INVALID; ++it) {
+	  int id = MapBase::getGraph()->id(it);
+	  allocator.construct(&(values[id]), Value());
+	}								
+      }
+
+      Map(const Graph& g, MapRegistry& r, const Value& v) : MapBase(g, r) {
+	allocate_memory();
+	for (KeyIt it(*MapBase::getGraph()); it != INVALID; ++it) {
+	  int id = MapBase::getGraph()->id(it);
+	  allocator.construct(&(values[id]), v);
+	}								
+      }
+
+      Map(const Map& copy) : MapBase(*copy.graph, *copy.registry) {
+	capacity = copy.capacity;
+	if (capacity == 0) return;
+	values = allocator.allocate(capacity);
+	for (KeyIt it(*MapBase::getGraph()); it != INVALID; ++it) {
+	  int id = MapBase::getGraph()->id(it);
+	  allocator.construct(&(values[id]), copy.values[id]);
+	}
+      }
+
+      template <typename CMap> Map(const CMap& copy) 
+	: capacity(0), values(0), MapBase(copy) {
+	if (MapBase::getGraph()) {
+	  allocate_memory();
+	  for (KeyIt it(*MapBase::getGraph()); it != INVALID; ++it) {
+	    set(it, copy[it]);
+	  }
+	}
+      }
+
+      Map& operator=(const Map& copy) {
+	if (&copy == this) return *this;
+	if (capacity != 0) {
+	  MapBase::destroy();
+	  allocator.deallocate(values, capacity);
+	}
+	capacity = copy.capacity;
+	if (capacity == 0) return *this;
+	values = allocator.allocate(capacity);
+	for (KeyIt it(*MapBase::getGraph()); it != INVALID; ++it) {
+	  int id = MapBase::getGraph()->id(it);
+	  allocator.construct(&(values[id]), copy.values[id]);
+	}
+	return *this;
+      }
+
+      template <typename CMap> Map& operator=(const CMap& copy) {
+	if (MapBase::getGraph()) {
+	  MapBase::destroy();
+	} 
+	MapBase::operator=(copy);
+	if (MapBase::getGraph()) {
+	  allocate_memory();
+	  for (KeyIt it(*MapBase::getGraph()); it != INVALID; ++it) {
+	    set(it, copy[it]);
+	  }
+	}
+	return *this;
+      }
+				
+      virtual ~Map() {
+	if (capacity != 0) {
+	  MapBase::destroy();
+	  allocator.deallocate(values, capacity);
+	}
+      }
+	
+	
+      Value& operator[](const Key& key) {
+	int id = MapBase::getGraph()->id(key);
+	return values[id];
+      } 
+		
+      const Value& operator[](const Key& key) const {
+	int id = MapBase::getGraph()->id(key);
+	return values[id];
+      }
+	
+      const Value& get(const Key& key) const {
+	int id = MapBase::getGraph()->id(key);
+	return values[id];
+      } 
+		
+      void set(const Key& key, const Value& val) {
+	int id = MapBase::getGraph()->id(key);
+	values[id] = val;
+      }
+		
+      void add(const Key& key) {
+	int id = MapBase::getGraph()->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);;
+	  for (KeyIt it(*MapBase::getGraph()); it != INVALID; ++it) {
+	    int jd = MapBase::getGraph()->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());
+      }
+		
+      void erase(const Key& key) {
+	int id = MapBase::getGraph()->id(key);
+	allocator.destroy(&(values[id]));
+      }
+
+      void clear() {	
+	if (capacity != 0) {
+	  MapBase::destroy();
+	  allocator.deallocate(values, capacity);
+	  capacity = 0;
+	}
+      }
+	
+      class iterator {
+	friend class Map;
+	friend class const_iterator;
+      private:
+
+	/** Private constructor to initalize the the iterators returned
+	 *  by the begin() and end().
+	 */
+	iterator (Map& pmap, const KeyIt& pit) : map(&pmap), it(pit) {}
+
+      public:
+
+	/** Default constructor. 
+	 */
+	iterator() {}
+
+	typedef extended_pair<const Key&, const Key&, 
+			      Value&, Value&> Reference;
+
+	/** Dereference operator for map.
+	 */	 
+	Reference operator*() {
+	  return Reference(it, (*map)[it]);
+	}
+
+	class Pointer {
+	  friend class iterator;
+	private:
+	  Reference data;
+	  Pointer(const Key& key, Value& val) : data(key, val) {}
+	public:
+	  Reference* operator->() {return &data;}
+	};
+
+	/** Arrow operator for map.
+	 */	 
+	Pointer operator->() {
+	  return Pointer(it, ((*map)[it])); 
+	}
+
+	/** The pre increment operator of the map.
+	 */
+	iterator& operator++() { 
+	  ++it; 
+	  return *this; 
+	}
+
+	/** The post increment operator of the map.
+	 */
+	iterator operator++(int) { 
+	  iterator tmp(it); 
+	  ++it; 
+	  return tmp; 
+	}
+
+	/** The equality operator of the map.
+	 */
+	bool operator==(const_iterator p_it) {
+	  return p_it.it == it;
+	}
+	
+	/** The not-equality operator of the map.
+	 */
+	bool operator!=(const_iterator p_it) {
+	  return !(*this == p_it);
+	}
+
+	
+      private:
+	Map* map;
+	KeyIt it;
+      };
+
+      /** Returns the begin iterator of the map.
+       */
+      iterator begin() {
+	return iterator(*this, KeyIt(*MapBase::getGraph()));
+      }
+
+      /** Returns the end iterator of the map.
+       */
+      iterator end() {
+	return iterator(*this, INVALID);
+      }
+
+      class const_iterator {
+	friend class Map;
+	friend class iterator;
+      private:
+
+	/** Private constructor to initalize the the iterators returned
+	 *  by the begin() and end().
+	 */
+	const_iterator (const Map& pmap, const KeyIt& pit) 
+	  : map(&pmap), it(pit) {}
+
+      public:
+
+	/** Default constructor. 
+	 */
+	const_iterator() {}
+
+	/** Constructor to convert iterator to const_iterator.
+	 */
+	const_iterator(iterator p_it) : map(p_it.map), it(p_it.it) {}
+      
+	typedef extended_pair<const Key&, const Key&, 
+	  const Value&, const Value&> Reference;
+
+	/** Dereference operator for map.
+	 */	 
+	Reference operator*() {
+	  return Reference(it, (*map)[it]);
+	}
+
+
+	class Pointer {
+	  friend class const_iterator;
+	private:
+	  Reference data;
+	  Pointer(const Key& key, const Value& val) : data(key, val) {}
+	public:
+	  Reference* operator->() {return &data;}
+	};
+
+	/** Arrow operator for map.
+	 */	 
+	Pointer operator->() {
+	  return Pointer(it, ((*map)[it])); 
+	}
+
+	/** The pre increment operator of the map.
+	 */
+	const_iterator& operator++() { 
+	  ++it; 
+	  return *this; 
+	}
+
+	/** The post increment operator of the map.
+	 */
+	const_iterator operator++(int) { 
+	  const_iterator tmp(it); 
+	  ++it; 
+	  return tmp; 
+	}
+
+	/** The equality operator of the map.
+	 */
+	bool operator==(const_iterator p_it) {
+	  return p_it.it == it;
+	}
+	
+	/** The not-equality operator of the map.
+	 */
+	bool operator!=(const_iterator p_it) {
+	  return !(*this == p_it);
+	}
+	
+
+      private:
+	const Map* map;
+	KeyIt it;
+      };
+
+      /** Returns the begin const_iterator of the map.
+       */
+      const_iterator begin() const {
+	return const_iterator(*this, KeyIt(*MapBase::getGraph()));
+      }
+
+      /** Returns the end const_iterator of the map.
+       */
+      const_iterator end() const {
+	return const_iterator(*this, INVALID);
+      }
+
+    private:
+      
+      void allocate_memory() {
+	int max_id = -1;
+	for (KeyIt it(*MapBase::getGraph()); it != INVALID; ++it) {
+	  int id = MapBase::getGraph()->id(it);
+	  if (id > max_id) {
+	    max_id = id;
+	  }			
+	}
+	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: src/hugo/extended_pair.h
===================================================================
--- src/hugo/extended_pair.h	(revision 782)
+++ src/hugo/extended_pair.h	(revision 782)
@@ -0,0 +1,65 @@
+// -*- c++ -*-
+#ifndef EXTENDED_PAIR_H
+#define EXTENDED_PAIR_H
+
+template <typename T1, typename A1, typename T2, typename A2>
+struct extended_pair {
+  typedef T1 first_type;
+  typedef T2 second_type;
+
+  extended_pair() : first(), second() {}
+
+  extended_pair(A1 f, A2 s) : first(f), second(s) {}
+
+  template <class Pair>
+  extended_pair(const Pair& pair) : first(pair.first), second(pair.second) {}
+
+  T1 first;
+  T2 second;
+};
+
+template <typename T1, typename T2, 
+	  typename LA1, typename LA2, typename RA1, typename RA2>
+bool operator==(const extended_pair<T1, LA1, T2, LA2>& left, 
+		const extended_pair<T1, RA1, T2, RA2>& right) {
+  return left.first == right.first && left.second == right.second;
+}
+
+template <typename T1, typename T2, 
+	  typename LA1, typename LA2, typename RA1, typename RA2>
+bool operator!=(const extended_pair<T1, LA1, T2, LA2>& left, 
+		const extended_pair<T1, RA1, T2, RA2>& right) {
+  return  !(left == right);
+}
+
+template <typename T1, typename T2, 
+	  typename LA1, typename LA2, typename RA1, typename RA2>
+bool operator<(const extended_pair<T1, LA1, T2, LA2>& left, 
+		const extended_pair<T1, RA1, T2, RA2>& right) {
+  if (left.first == right.first) return left.second == right.second;
+  return left.first < right.first;
+}
+
+template <typename T1, typename T2, 
+	  typename LA1, typename LA2, typename RA1, typename RA2>
+bool operator>(const extended_pair<T1, LA1, T2, LA2>& left, 
+		const extended_pair<T1, RA1, T2, RA2>& right) {
+  return right < left;
+}
+
+template <typename T1, typename T2, 
+	  typename LA1, typename LA2, typename RA1, typename RA2>
+bool operator<=(const extended_pair<T1, LA1, T2, LA2>& left, 
+		const extended_pair<T1, RA1, T2, RA2>& right) {
+  return !(right > left);
+}
+
+template <typename T1, typename T2, 
+	  typename LA1, typename LA2, typename RA1, typename RA2>
+bool operator>=(const extended_pair<T1, LA1, T2, LA2>& left, 
+		const extended_pair<T1, RA1, T2, RA2>& right) {
+  return !(right < left);
+}
+
+
+#endif
Index: src/hugo/full_graph.h
===================================================================
--- src/hugo/full_graph.h	(revision 774)
+++ src/hugo/full_graph.h	(revision 782)
@@ -9,7 +9,10 @@
 
 #include <vector>
-#include <limits.h>
+#include <climits>
 
 #include <hugo/invalid.h>
+
+#include <hugo/map_registry.h>
+#include <hugo/array_map_factory.h>
 
 namespace hugo {
@@ -34,9 +37,10 @@
     int EdgeNum;
   public:
-    template <typename T> class EdgeMap;
-    template <typename T> class NodeMap;
+
+    typedef FullGraph Graph;
 
     class Node;
     class Edge;
+
     class NodeIt;
     class EdgeIt;
@@ -44,6 +48,6 @@
     class InEdgeIt;
     
-    template <typename T> class NodeMap;
-    template <typename T> class EdgeMap;
+    CREATE_MAP_REGISTRIES;
+    CREATE_MAPS(ArrayMapFactory);
     
   public:
@@ -86,5 +90,5 @@
     Edge findEdge(Node u,Node v, Edge prev = INVALID) 
     {
-      return prev.n==-1?Edge(*this,u.n,v.n):INVALID;
+      return prev.n == -1 ? Edge(*this, u.n, v.n) : INVALID;
     }
     
@@ -188,108 +192,4 @@
     };
 
-    template <typename T> class NodeMap
-    {
-      std::vector<T> container;
-
-    public:
-      typedef T ValueType;
-      typedef Node KeyType;
-
-      NodeMap(const FullGraph &_G) : container(_G.NodeNum) { }
-      NodeMap(const FullGraph &_G,const T &t) : container(_G.NodeNum,t) { }
-      NodeMap(const NodeMap<T> &m) : container(m.container) { }
-
-      template<typename TT> friend class NodeMap;
-      ///\todo It can copy between different types.
-      template<typename TT> NodeMap(const NodeMap<TT> &m)
-	: container(m.container.size())
-      {
-	typename std::vector<TT>::const_iterator i;
-	for(typename std::vector<TT>::const_iterator i=m.container.begin();
-	    i!=m.container.end();
-	    i++)
-	  container.push_back(*i);
-      }
-      void set(Node n, T a) { container[n.n]=a; }
-      //'T& operator[](Node n)' would be wrong here
-      typename std::vector<T>::reference
-      operator[](Node n) { return container[n.n]; }
-      //'const T& operator[](Node n)' would be wrong here
-      typename std::vector<T>::const_reference 
-      operator[](Node n) const { return container[n.n]; }
-
-      ///\warning There is no safety check at all!
-      ///Using operator = between maps attached to different graph may
-      ///cause serious problem.
-      ///\todo Is this really so?
-      ///\todo It can copy between different types.
-      const NodeMap<T>& operator=(const NodeMap<T> &m)
-      {
-	container = m.container;
-	return *this;
-      }
-      template<typename TT>
-      const NodeMap<T>& operator=(const NodeMap<TT> &m)
-      {
-	std::copy(m.container.begin(), m.container.end(), container.begin());
-	return *this;
-      }
-      
-      void update() {}    //Useless for Dynamic Maps
-      void update(T a) {}  //Useless for Dynamic Maps
-    };
-    
-    template <typename T> class EdgeMap
-    {
-      std::vector<T> container;
-
-    public:
-      typedef T ValueType;
-      typedef Edge KeyType;
-
-      EdgeMap(const FullGraph &_G) : container(_G.EdgeNum) { }
-      EdgeMap(const FullGraph &_G,const T &t) : container(_G.EdgeNum,t) { } 
-      EdgeMap(const EdgeMap<T> &m) : container(m.container) { }
-
-      template<typename TT> friend class EdgeMap;
-      ///\todo It can copy between different types. 
-      ///\todo We could use 'copy'
-      template<typename TT> EdgeMap(const EdgeMap<TT> &m) :
-	container(m.container.size())
-      {
-	typename std::vector<TT>::const_iterator i;
-	for(typename std::vector<TT>::const_iterator i=m.container.begin();
-	    i!=m.container.end();
-	    i++)
-	  container.push_back(*i);
-      }
-      void set(Edge n, T a) { container[n.n]=a; }
-      //T get(Edge n) const { return container[n.n]; }
-      typename std::vector<T>::reference
-      operator[](Edge n) { return container[n.n]; }
-      typename std::vector<T>::const_reference
-      operator[](Edge n) const { return container[n.n]; }
-
-      ///\warning There is no safety check at all!
-      ///Using operator = between maps attached to different graph may
-      ///cause serious problem.
-      ///\todo Is this really so?
-      ///\todo It can copy between different types.
-      const EdgeMap<T>& operator=(const EdgeMap<T> &m)
-      {
-	container = m.container;
-	return *this;
-      }
-      template<typename TT>
-      const EdgeMap<T>& operator=(const EdgeMap<TT> &m)
-      {
-	std::copy(m.container.begin(), m.container.end(), container.begin());
-	return *this;
-      }
-
-      void update() {}
-      void update(T a) {}
-    };
-
   };
 
Index: src/hugo/list_graph.h
===================================================================
--- src/hugo/list_graph.h	(revision 774)
+++ src/hugo/list_graph.h	(revision 782)
@@ -9,7 +9,15 @@
 
 #include <vector>
-#include <limits.h>
+#include <climits>
 
 #include <hugo/invalid.h>
+
+#include <hugo/map_registry.h>
+#include <hugo/array_map_factory.h>
+
+#include <hugo/sym_map_factory.h>
+
+#include <hugo/map_defines.h>
+
 
 namespace hugo {
@@ -18,5 +26,5 @@
 /// @{
 
-  class SymListGraph;
+//  class SymListGraph;
 
   ///A list graph class.
@@ -57,34 +65,11 @@
     int first_free_edge;
     
-  protected:
-    
-    template <typename Key> class DynMapBase
-    {
-    protected:
-      const ListGraph* G; 
-    public:
-      virtual void add(const Key k) = 0;
-      virtual void erase(const Key k) = 0;
-      DynMapBase(const ListGraph &_G) : G(&_G) {}
-      virtual ~DynMapBase() {}
-      friend class ListGraph;
-    };
-    
-  public:
-    template <typename T> class EdgeMap;
-    template <typename T> class NodeMap;
+  public:
+    
+    typedef ListGraph Graph;
     
     class Node;
     class Edge;
 
-    //  protected:
-    // HELPME:
-  protected:
-    ///\bug It must be public because of SymEdgeMap.
-    ///
-    mutable std::vector<DynMapBase<Node> * > dyn_node_maps;
-    ///\bug It must be public because of SymEdgeMap.
-    ///
-    mutable std::vector<DynMapBase<Edge> * > dyn_edge_maps;
     
   public:
@@ -94,22 +79,19 @@
     class OutEdgeIt;
     class InEdgeIt;
-    
-  public:
-
-    ListGraph() : nodes(), first_node(-1),
-		  first_free_node(-1), edges(), first_free_edge(-1) {}
-    ListGraph(const ListGraph &_g) : nodes(_g.nodes), first_node(_g.first_node),
-				     first_free_node(_g.first_free_node),
-				     edges(_g.edges),
-				     first_free_edge(_g.first_free_edge) {}
-    
-    ~ListGraph()
-    {
-      for(std::vector<DynMapBase<Node> * >::iterator i=dyn_node_maps.begin();
-	  i!=dyn_node_maps.end(); ++i) (**i).G=NULL;
-      for(std::vector<DynMapBase<Edge> * >::iterator i=dyn_edge_maps.begin();
-	  i!=dyn_edge_maps.end(); ++i) (**i).G=NULL;
-    }
-
+
+    CREATE_MAP_REGISTRIES;
+    CREATE_MAPS(ArrayMapFactory);
+
+  public:
+
+    ListGraph() 
+      : nodes(), first_node(-1),
+	first_free_node(-1), edges(), first_free_edge(-1) {}
+
+    ListGraph(const ListGraph &_g) 
+      : nodes(_g.nodes), first_node(_g.first_node),
+	first_free_node(_g.first_free_node), edges(_g.edges),
+	first_free_edge(_g.first_free_edge) {}
+    
     int nodeNum() const { return nodes.size(); }  //FIXME: What is this?
     int edgeNum() const { return edges.size(); }  //FIXME: What is this?
@@ -171,6 +153,5 @@
 
       //Update dynamic maps
-      for(std::vector<DynMapBase<Node> * >::iterator i=dyn_node_maps.begin();
-	  i!=dyn_node_maps.end(); ++i) (**i).add(nn);
+      node_maps.add(nn);
 
       return nn;
@@ -203,6 +184,5 @@
 
       //Update dynamic maps
-      for(std::vector<DynMapBase<Edge> * >::iterator i=dyn_edge_maps.begin();
-	  i!=dyn_edge_maps.end(); ++i) (**i).add(e);
+      edge_maps.add(e);
 
       return e;
@@ -245,6 +225,6 @@
       //Update dynamic maps
       Edge e; e.n=n;
-      for(std::vector<DynMapBase<Edge> * >::iterator i=dyn_edge_maps.begin();
-	  i!=dyn_edge_maps.end(); ++i) (**i).erase(e);
+      edge_maps.erase(e);
+
     }
       
@@ -266,14 +246,15 @@
 
       //Update dynamic maps
-      for(std::vector<DynMapBase<Node> * >::iterator i=dyn_node_maps.begin();
-	  i!=dyn_node_maps.end(); ++i) (**i).erase(nn);
+      node_maps.erase(nn);
+
     }
     
     void erase(Edge e) { eraseEdge(e.n); }
 
-    ///\bug Dynamic maps must be updated!
-    ///
     void clear() {
-      nodes.clear();edges.clear();
+      edge_maps.clear();
+      edges.clear();
+      node_maps.clear();
+      nodes.clear();
       first_node=first_free_node=first_free_edge=-1;
     }
@@ -411,186 +392,4 @@
       //      operator bool() { return Edge::operator bool(); }      
     };
-
-    template <typename T> class NodeMap : public DynMapBase<Node>
-    {
-      std::vector<T> container;
-
-    public:
-      typedef T ValueType;
-      typedef Node KeyType;
-
-      NodeMap(const ListGraph &_G) :
-	DynMapBase<Node>(_G), container(_G.maxNodeId())
-      {
-	G->dyn_node_maps.push_back(this);
-      }
-      NodeMap(const ListGraph &_G,const T &t) :
-	DynMapBase<Node>(_G), container(_G.maxNodeId(),t)
-      {
-	G->dyn_node_maps.push_back(this);
-      }
-      
-      NodeMap(const NodeMap<T> &m) :
- 	DynMapBase<Node>(*m.G), container(m.container)
-      {
- 	G->dyn_node_maps.push_back(this);
-      }
-
-      template<typename TT> friend class NodeMap;
- 
-      ///\todo It can copy between different types.
-      ///
-      template<typename TT> NodeMap(const NodeMap<TT> &m) :
-	DynMapBase<Node>(*m.G), container(m.container.size())
-
-      {
-	G->dyn_node_maps.push_back(this);
-	typename std::vector<TT>::const_iterator i;
-	for(typename std::vector<TT>::const_iterator i=m.container.begin();
-	    i!=m.container.end();
-	    i++)
-	  container.push_back(*i);
-      }
-      ~NodeMap()
-      {
-	if(G) {
-	  std::vector<DynMapBase<Node>* >::iterator i;
-	  for(i=G->dyn_node_maps.begin();
-	      i!=G->dyn_node_maps.end() && *i!=this; ++i) ;
-	  //if(*i==this) G->dyn_node_maps.erase(i); //FIXME: Way too slow...
-	  //A better way to do that: (Is this really important?)
-	  if(*i==this) {
-	    *i=G->dyn_node_maps.back();
-	    G->dyn_node_maps.pop_back();
-	  }
-	}
-      }
-
-      void add(const Node k) 
-      {
-	if(k.n>=int(container.size())) container.resize(k.n+1);
-      }
-
-      void erase(const Node) { }
-      
-      void set(Node n, T a) { container[n.n]=a; }
-      //'T& operator[](Node n)' would be wrong here
-      typename std::vector<T>::reference
-      operator[](Node n) { return container[n.n]; }
-      //'const T& operator[](Node n)' would be wrong here
-      typename std::vector<T>::const_reference 
-      operator[](Node n) const { return container[n.n]; }
-
-      ///\warning There is no safety check at all!
-      ///Using operator = between maps attached to different graph may
-      ///cause serious problem.
-      ///\todo Is this really so?
-      ///\todo It can copy between different types.
-      const NodeMap<T>& operator=(const NodeMap<T> &m)
-      {
-	container = m.container;
-	return *this;
-      }
-      template<typename TT>
-      const NodeMap<T>& operator=(const NodeMap<TT> &m)
-      {
-	std::copy(m.container.begin(), m.container.end(), container.begin());
-	return *this;
-      }
-      
-      void update() {}    //Useless for Dynamic Maps
-      void update(T a) {}  //Useless for Dynamic Maps
-    };
-    
-    template <typename T> class EdgeMap : public DynMapBase<Edge>
-    {
-    protected:
-      std::vector<T> container;
-
-    public:
-      typedef T ValueType;
-      typedef Edge KeyType;
-
-      EdgeMap(const ListGraph &_G) :
-	DynMapBase<Edge>(_G), container(_G.maxEdgeId())
-      {
-	//FIXME: What if there are empty Id's?
-	//FIXME: Can I use 'this' in a constructor?
-	G->dyn_edge_maps.push_back(this);
-      }
-      EdgeMap(const ListGraph &_G,const T &t) :
-	DynMapBase<Edge>(_G), container(_G.maxEdgeId(),t)
-      {
-	G->dyn_edge_maps.push_back(this);
-      } 
-      EdgeMap(const EdgeMap<T> &m) :
- 	DynMapBase<Edge>(*m.G), container(m.container)
-      {
- 	G->dyn_edge_maps.push_back(this);
-      }
-
-      template<typename TT> friend class EdgeMap;
-
-      ///\todo It can copy between different types.
-      ///
-      template<typename TT> EdgeMap(const EdgeMap<TT> &m) :
-	DynMapBase<Edge>(*m.G), container(m.container.size())
-      {
-	G->dyn_edge_maps.push_back(this);
-	typename std::vector<TT>::const_iterator i;
-	for(typename std::vector<TT>::const_iterator i=m.container.begin();
-	    i!=m.container.end();
-	    i++)
-	  container.push_back(*i);
-      }
-      ~EdgeMap()
-      {
-	if(G) {
-	  std::vector<DynMapBase<Edge>* >::iterator i;
-	  for(i=G->dyn_edge_maps.begin();
-	      i!=G->dyn_edge_maps.end() && *i!=this; ++i) ;
-	  //if(*i==this) G->dyn_edge_maps.erase(i); //Way too slow...
-	  //A better way to do that: (Is this really important?)
-	  if(*i==this) {
-	    *i=G->dyn_edge_maps.back();
-	    G->dyn_edge_maps.pop_back();
-	  }
-	}
-      }
-      
-      void add(const Edge k) 
-      {
-	if(k.n>=int(container.size())) container.resize(k.n+1);
-      }
-      void erase(const Edge) { }
-      
-      void set(Edge n, T a) { container[n.n]=a; }
-      //T get(Edge n) const { return container[n.n]; }
-      typename std::vector<T>::reference
-      operator[](Edge n) { return container[n.n]; }
-      typename std::vector<T>::const_reference
-      operator[](Edge n) const { return container[n.n]; }
-
-      ///\warning There is no safety check at all!
-      ///Using operator = between maps attached to different graph may
-      ///cause serious problem.
-      ///\todo Is this really so?
-      ///\todo It can copy between different types.
-      const EdgeMap<T>& operator=(const EdgeMap<T> &m)
-      {
-	container = m.container;
-	return *this;
-      }
-      template<typename TT>
-      const EdgeMap<T>& operator=(const EdgeMap<TT> &m)
-      {
-	std::copy(m.container.begin(), m.container.end(), container.begin());
-	return *this;
-      }
-      
-      void update() {}    //Useless for DynMaps
-      void update(T a) {}  //Useless for DynMaps
-    };
-
   };
 
@@ -616,10 +415,17 @@
   ///\todo this date structure need some reconsiderations. Maybe it
   ///should be implemented independently from ListGraph.
-
+  
   class SymListGraph : public ListGraph
   {
   public:
-    template<typename T> class SymEdgeMap;
-    template<typename T> friend class SymEdgeMap;
+
+    typedef SymListGraph Graph;
+
+    KEEP_NODE_MAP(ListGraph);
+    KEEP_EDGE_MAP(ListGraph);
+
+    CREATE_SYM_EDGE_MAP_REGISTRY;
+    CREATE_SYM_EDGE_MAP_FACTORY(ArrayMapFactory);
+    IMPORT_SYM_EDGE_MAP(SymEdgeMapFactory);
 
     SymListGraph() : ListGraph() { }
@@ -629,9 +435,12 @@
     {
       Edge e = ListGraph::addEdge(u,v);
-      ListGraph::addEdge(v,u);
+      Edge f = ListGraph::addEdge(v,u);
+      sym_edge_maps.add(e);
+      sym_edge_maps.add(f);
+      
       return e;
     }
 
-    void erase(Node n) { ListGraph::erase(n); }
+    void erase(Node n) { ListGraph::erase(n);}
     ///The oppositely directed edge.
 
@@ -647,107 +456,12 @@
     ///Removes a pair of oppositely directed edges to the graph.
     void erase(Edge e) {
-      ListGraph::erase(opposite(e));
+      Edge f = opposite(e);
+      sym_edge_maps.erase(e);
+      sym_edge_maps.erase(f);
+      ListGraph::erase(f);
       ListGraph::erase(e);
-    }
-    
-    ///Common data storage for the edge pairs.
-
-    ///This map makes it possible to store data shared by the oppositely
-    ///directed pairs of edges.
-    template <typename T> class SymEdgeMap : public DynMapBase<Edge>
-    {
-      std::vector<T> container;
-      
-    public:
-      typedef T ValueType;
-      typedef Edge KeyType;
-
-      SymEdgeMap(const SymListGraph &_G) :
-	DynMapBase<Edge>(_G), container(_G.maxEdgeId()/2)
-      {
-	static_cast<const SymListGraph*>(G)->dyn_edge_maps.push_back(this);
-      }
-      SymEdgeMap(const SymListGraph &_G,const T &t) :
-	DynMapBase<Edge>(_G), container(_G.maxEdgeId()/2,t)
-      {
-	G->dyn_edge_maps.push_back(this);
-      }
-
-      SymEdgeMap(const SymEdgeMap<T> &m) :
- 	DynMapBase<SymEdge>(*m.G), container(m.container)
-      {
- 	G->dyn_node_maps.push_back(this);
-      }
-
-      //      template<typename TT> friend class SymEdgeMap;
-
-      ///\todo It can copy between different types.
-      ///
-
-      template<typename TT> SymEdgeMap(const SymEdgeMap<TT> &m) :
-	DynMapBase<SymEdge>(*m.G), container(m.container.size())
-      {
-	G->dyn_node_maps.push_back(this);
-	typename std::vector<TT>::const_iterator i;
-	for(typename std::vector<TT>::const_iterator i=m.container.begin();
-	    i!=m.container.end();
-	    i++)
-	  container.push_back(*i);
-      }
- 
-      ~SymEdgeMap()
-      {
-	if(G) {
-	  std::vector<DynMapBase<Edge>* >::iterator i;
-	  for(i=static_cast<const SymListGraph*>(G)->dyn_edge_maps.begin();
-	      i!=static_cast<const SymListGraph*>(G)->dyn_edge_maps.end()
-		&& *i!=this; ++i) ;
-	  //if(*i==this) G->dyn_edge_maps.erase(i); //Way too slow...
-	  //A better way to do that: (Is this really important?)
-	  if(*i==this) {
-	    *i=static_cast<const SymListGraph*>(G)->dyn_edge_maps.back();
-	    static_cast<const SymListGraph*>(G)->dyn_edge_maps.pop_back();
-	  }
-	}
-      }
-      
-      void add(const Edge k) 
-      {
-	if(!k.idref()%2&&k.idref()/2>=int(container.size()))
-	  container.resize(k.idref()/2+1);
-      }
-      void erase(const Edge k) { }
-      
-      void set(Edge n, T a) { container[n.idref()/2]=a; }
-      //T get(Edge n) const { return container[n.idref()/2]; }
-      typename std::vector<T>::reference
-      operator[](Edge n) { return container[n.idref()/2]; }
-      typename std::vector<T>::const_reference
-      operator[](Edge n) const { return container[n.idref()/2]; }
-
-      ///\warning There is no safety check at all!
-      ///Using operator = between maps attached to different graph may
-      ///cause serious problem.
-      ///\todo Is this really so?
-      ///\todo It can copy between different types.
-      const SymEdgeMap<T>& operator=(const SymEdgeMap<T> &m)
-      {
-	container = m.container;
-	return *this;
-      }
-      template<typename TT>
-      const SymEdgeMap<T>& operator=(const SymEdgeMap<TT> &m)
-      {
-	std::copy(m.container.begin(), m.container.end(), container.begin());
-	return *this;
-      }
-      
-      void update() {}    //Useless for DynMaps
-      void update(T a) {}  //Useless for DynMaps
-
-    };
-
+    }    
   };
-  
+
 
   ///A graph class containing only nodes.
@@ -780,33 +494,11 @@
     int first_free_node;
     
-  protected:
-    
-    template <typename Key> class DynMapBase
-    {
-    protected:
-      const NodeSet* G; 
-    public:
-      virtual void add(const Key k) = 0;
-      virtual void erase(const Key k) = 0;
-      DynMapBase(const NodeSet &_G) : G(&_G) {}
-      virtual ~DynMapBase() {}
-      friend class NodeSet;
-    };
-    
-  public:
-    template <typename T> class EdgeMap;
-    template <typename T> class NodeMap;
+  public:
+
+    typedef NodeSet Graph;
     
     class Node;
     class Edge;
 
-    //  protected:
-    // HELPME:
-  protected:
-    ///\bug It must be public because of SymEdgeMap.
-    ///
-    mutable std::vector<DynMapBase<Node> * > dyn_node_maps;
-    //mutable std::vector<DynMapBase<Edge> * > dyn_edge_maps;
-    
   public:
 
@@ -816,24 +508,17 @@
     class InEdgeIt;
     
-    template <typename T> class NodeMap;
-    template <typename T> class EdgeMap;
+    CREATE_MAP_REGISTRIES;
+    CREATE_MAPS(ArrayMapFactory);
     
   public:
 
     ///Default constructor
-    NodeSet() : nodes(), first_node(-1),
-		  first_free_node(-1) {}
+    NodeSet() 
+      : nodes(), first_node(-1), first_free_node(-1) {}
     ///Copy constructor
-    NodeSet(const NodeSet &_g) : nodes(_g.nodes), first_node(_g.first_node),
-				     first_free_node(_g.first_free_node) {}
-    
-    ~NodeSet()
-    {
-      for(std::vector<DynMapBase<Node> * >::iterator i=dyn_node_maps.begin();
-	  i!=dyn_node_maps.end(); ++i) (**i).G=NULL;
-      //for(std::vector<DynMapBase<Edge> * >::iterator i=dyn_edge_maps.begin();
-      //	  i!=dyn_edge_maps.end(); ++i) (**i).G=NULL;
-    }
-
+    NodeSet(const NodeSet &_g) 
+      : nodes(_g.nodes), first_node(_g.first_node),
+	first_free_node(_g.first_free_node) {}
+    
     int nodeNum() const { return nodes.size(); }  //FIXME: What is this?
     int edgeNum() const { return 0; }  //FIXME: What is this?
@@ -888,6 +573,5 @@
 
       //Update dynamic maps
-      for(std::vector<DynMapBase<Node> * >::iterator i=dyn_node_maps.begin();
-	  i!=dyn_node_maps.end(); ++i) (**i).add(nn);
+      node_maps.add(nn);
 
       return nn;
@@ -905,6 +589,5 @@
 
       //Update dynamic maps
-      for(std::vector<DynMapBase<Node> * >::iterator i=dyn_node_maps.begin();
-	  i!=dyn_node_maps.end(); ++i) (**i).erase(nn);
+      node_maps.erase(nn);
     }
     
@@ -915,7 +598,6 @@
     }
     
-    ///\bug Dynamic maps must be updated!
-    ///
     void clear() {
+      node_maps.clear();
       nodes.clear();
       first_node = first_free_node = -1;
@@ -1013,126 +695,4 @@
     };
 
-    template <typename T> class NodeMap : public DynMapBase<Node>
-    {
-      std::vector<T> container;
-
-    public:
-      typedef T ValueType;
-      typedef Node KeyType;
-
-      NodeMap(const NodeSet &_G) :
-	DynMapBase<Node>(_G), container(_G.maxNodeId())
-      {
-	G->dyn_node_maps.push_back(this);
-      }
-      NodeMap(const NodeSet &_G,const T &t) :
-	DynMapBase<Node>(_G), container(_G.maxNodeId(),t)
-      {
-	G->dyn_node_maps.push_back(this);
-      }
-      
-      NodeMap(const NodeMap<T> &m) :
- 	DynMapBase<Node>(*m.G), container(m.container)
-      {
- 	G->dyn_node_maps.push_back(this);
-      }
-
-      template<typename TT> friend class NodeMap;
- 
-      ///\todo It can copy between different types.
-      ///
-      template<typename TT> NodeMap(const NodeMap<TT> &m) :
-	DynMapBase<Node>(*m.G), container(m.container.size())
-      {
-	G->dyn_node_maps.push_back(this);
-	typename std::vector<TT>::const_iterator i;
-	for(typename std::vector<TT>::const_iterator i=m.container.begin();
-	    i!=m.container.end();
-	    i++)
-	  container.push_back(*i);
-      }
-      ~NodeMap()
-      {
-	if(G) {
-	  std::vector<DynMapBase<Node>* >::iterator i;
-	  for(i=G->dyn_node_maps.begin();
-	      i!=G->dyn_node_maps.end() && *i!=this; ++i) ;
-	  //if(*i==this) G->dyn_node_maps.erase(i); //FIXME: Way too slow...
-	  //A better way to do that: (Is this really important?)
-	  if(*i==this) {
-	    *i=G->dyn_node_maps.back();
-	    G->dyn_node_maps.pop_back();
-	  }
-	}
-      }
-
-      void add(const Node k) 
-      {
-	if(k.n>=int(container.size())) container.resize(k.n+1);
-      }
-
-      void erase(const Node) { }
-      
-      void set(Node n, T a) { container[n.n]=a; }
-      //'T& operator[](Node n)' would be wrong here
-      typename std::vector<T>::reference
-      operator[](Node n) { return container[n.n]; }
-      //'const T& operator[](Node n)' would be wrong here
-      typename std::vector<T>::const_reference 
-      operator[](Node n) const { return container[n.n]; }
-
-      ///\warning There is no safety check at all!
-      ///Using operator = between maps attached to different graph may
-      ///cause serious problem.
-      ///\todo Is this really so?
-      ///\todo It can copy between different types.
-      const NodeMap<T>& operator=(const NodeMap<T> &m)
-      {
-	container = m.container;
-	return *this;
-      }
-      template<typename TT>
-      const NodeMap<T>& operator=(const NodeMap<TT> &m)
-      {
-	std::copy(m.container.begin(), m.container.end(), container.begin());
-	return *this;
-      }
-      
-      void update() {}    //Useless for Dynamic Maps
-      void update(T a) {}  //Useless for Dynamic Maps
-    };
-    
-    template <typename T> class EdgeMap
-    {
-    public:
-      typedef T ValueType;
-      typedef Edge KeyType;
-
-      EdgeMap(const NodeSet &) { }
-      EdgeMap(const NodeSet &,const T &) { }
-      EdgeMap(const EdgeMap<T> &) { }
-      //      template<typename TT> friend class EdgeMap;
-
-      ///\todo It can copy between different types.
-      ///
-      template<typename TT> EdgeMap(const EdgeMap<TT> &) { }
-      ~EdgeMap() { }
-
-      void add(const Edge  ) { }
-      void erase(const Edge) { }
-      
-      void set(Edge, T) { }
-      //T get(Edge n) const { return container[n.n]; }
-      ValueType &operator[](Edge) { return *((T*)(NULL)); }
-      const ValueType &operator[](Edge) const { return *((T*)(NULL)); }
-
-      const EdgeMap<T>& operator=(const EdgeMap<T> &) { return *this; }
-    
-      template<typename TT>
-      const EdgeMap<T>& operator=(const EdgeMap<TT> &m) { return *this; }
-      
-      void update() {}
-      void update(T a) {}
-    };
   };
 
@@ -1167,4 +727,5 @@
 
   public:
+
     class Node;
     class Edge;
@@ -1172,4 +733,7 @@
     class InEdgeIt;
     class SymEdge;
+
+    typedef EdgeSet Graph;
+
     int id(Node v) const; 
 
@@ -1230,34 +794,8 @@
     int first_free_edge;
     
-  protected:
-    
-    template <typename Key> class DynMapBase
-    {
-    protected:
-      const EdgeSet* G; 
-    public:
-      virtual void add(const Key k) = 0;
-      virtual void erase(const Key k) = 0;
-      DynMapBase(const EdgeSet &_G) : G(&_G) {}
-      virtual ~DynMapBase() {}
-      friend class EdgeSet;
-    };
-    
-  public:
-    //template <typename T> class NodeMap;
-    template <typename T> class EdgeMap;
+  public:
     
     class Node;
     class Edge;
-
-    //  protected:
-    // HELPME:
-  protected:
-    // mutable std::vector<DynMapBase<Node> * > dyn_node_maps;
-    ///\bug It must be public because of SymEdgeMap.
-    ///
-    mutable std::vector<DynMapBase<Edge> * > dyn_edge_maps;
-    
-  public:
 
     class NodeIt;
@@ -1265,7 +803,10 @@
     class OutEdgeIt;
     class InEdgeIt;
-    
-    template <typename T> class NodeMap;
-    template <typename T> class EdgeMap;
+
+
+    CREATE_EDGE_MAP_REGISTRY;
+    CREATE_EDGE_MAP_FACTORY(ArrayMapFactory);
+    IMPORT_EDGE_MAP(EdgeMapFactory);
+    
     
   public:
@@ -1276,23 +817,15 @@
     ///\param _G the base graph.
     ///\todo It looks like a copy constructor, but it isn't.
-    EdgeSet(NodeGraphType &_G) : G(_G),
-				 nodes(_G), edges(),
-				 first_free_edge(-1) { }
+    EdgeSet(NodeGraphType &_G) 
+      : G(_G), nodes(_G), edges(),
+	first_free_edge(-1) {}
     ///Copy constructor
 
     ///Makes a copy of an EdgeSet.
     ///It will be based on the same graph.
-    EdgeSet(const EdgeSet &_g) : G(_g.G), nodes(_g.G), edges(_g.edges),
-				 first_free_edge(_g.first_free_edge) { }
-    
-    ~EdgeSet()
-    {
-      // for(std::vector<DynMapBase<Node> * >::iterator i=dyn_node_maps.begin();
-      //  i!=dyn_node_maps.end(); ++i) (**i).G=NULL;
-      for(typename std::vector<DynMapBase<Edge> * >::iterator
-	    i=dyn_edge_maps.begin();
-	  i!=dyn_edge_maps.end(); ++i) (**i).G=NULL;
-    }
-
+    EdgeSet(const EdgeSet &_g) 
+      : G(_g.G), nodes(_g.G), edges(_g.edges),
+	first_free_edge(_g.first_free_edge) {}
+    
     int nodeNum() const { return G.nodeNum(); }  //FIXME: What is this?
     int edgeNum() const { return edges.size(); }  //FIXME: What is this?
@@ -1348,7 +881,5 @@
 
       //Update dynamic maps
-      for(typename std::vector<DynMapBase<Edge> * >::iterator
-	    i=dyn_edge_maps.begin();
-	  i!=dyn_edge_maps.end(); ++i) (**i).add(e);
+      edge_maps.add(e);
 
       return e;
@@ -1390,8 +921,6 @@
 
       //Update dynamic maps
-      Edge e; e.n=n;
-      for(typename std::vector<DynMapBase<Edge> * >::iterator
-	    i=dyn_edge_maps.begin();
-	  i!=dyn_edge_maps.end(); ++i) (**i).erase(e);
+      Edge e; e.n = n;
+      edge_maps.erase(e);
     }
       
@@ -1409,4 +938,5 @@
     ///Clear all edges. (Doesn't clear the nodes!)
     void clear() {
+      edge_maps.clear();
       edges.clear();
       first_free_edge=-1;
@@ -1414,15 +944,4 @@
 
 
-//     //\bug Dynamic maps must be updated!
-//     //
-//     void clear() {
-//       nodes.clear();edges.clear();
-//       first_node=first_free_node=first_free_edge=-1;
-//     }
-
-  public:
-    template <typename T> class EdgeMap;
-    
-    ///
     class Edge {
     public:
@@ -1491,5 +1010,5 @@
       OutEdgeIt(const EdgeSet& _G,const Node v) :
 	Edge(_G.nodes[v].first_out), G(&_G) { }
-      OutEdgeIt &operator++() { n=G->edges[n].next_out; return *this; }
+      OutEdgeIt &operator++() { n = G->edges[n].next_out; return *this; }
     };
     
@@ -1506,124 +1025,39 @@
     };
 
-    template <typename T> class NodeMap : 
-      public NodeGraphType::template NodeMap<T>
+    
+    template <typename V> class NodeMap 
+      : public NodeGraphType::template NodeMap<V>
     {
       //This is a must, the constructors need it.
-      typedef typename NodeGraphType::template NodeMap<T> ParentNodeMap;
-    public:
-      NodeMap(const EdgeSet &_G) : ParentNodeMap(_G.G) { }
-      NodeMap(const EdgeSet &_G,const T &t) : ParentNodeMap(_G.G,t) { }
-      //It is unnecessary
-      NodeMap(const typename NodeGraphType::template NodeMap<T> &m) :
-	ParentNodeMap(m) { }
-
-      ///\todo It can copy between different types.
-      ///
-      template<typename TT>
-      NodeMap(const typename NodeGraphType::template NodeMap<TT> &m)
-	: ParentNodeMap(m) { }
-    };
-    
-    ///
-    template <typename T> class EdgeMap : public DynMapBase<Edge>
-    {
-    protected:
-    public:
-      ///\bug It should be at least protected
-      ///
-      std::vector<T> container;
-
-    public:
-      typedef T ValueType;
-      typedef Edge KeyType;
-
-      EdgeMap(const EdgeSet &_G) :
-	DynMapBase<Edge>(_G), container(_G.maxEdgeId())
-      {
-	//FIXME: What if there are empty Id's?
-	//FIXME: Can I use 'this' in a constructor?
-	this->G->dyn_edge_maps.push_back(this);
-      }
-      EdgeMap(const EdgeSet &_G,const T &t) :
-	DynMapBase<Edge>(_G), container(_G.maxEdgeId(),t)
-      {
-	this->G->dyn_edge_maps.push_back(this);
-      } 
-      EdgeMap(const EdgeMap<T> &m) :
- 	DynMapBase<Edge>(*m.G), container(m.container)
-      {
- 	this->G->dyn_edge_maps.push_back(this);
-      }
-
-      ///\todo It can copy between different types.
-      ///
-      template<typename TT> EdgeMap(const EdgeMap<TT> &m) :
-	DynMapBase<Edge>(*m.G), container(m.container.size())
-      {
-	this->G->dyn_edge_maps.push_back(this);
-	typename std::vector<TT>::const_iterator i;
-	for(typename std::vector<TT>::const_iterator i=m.container.begin();
-	    i!=m.container.end();
-	    i++)
-	  container.push_back(*i);
-      }
-      ~EdgeMap()
-      {
-	if(this->G) {
-	  typename std::vector<DynMapBase<Edge>* >::iterator i;
-	  for(i=this->G->dyn_edge_maps.begin();
-	      i!=this->G->dyn_edge_maps.end() && *i!=this; ++i) ;
-	  //if(*i==this) G->dyn_edge_maps.erase(i); //Way too slow...
-	  //A better way to do that: (Is this really important?)
-	  if(*i==this) {
-	    *i=this->G->dyn_edge_maps.back();
-	    this->G->dyn_edge_maps.pop_back();
-	  }
-	}
-      }
-      
-      void add(const Edge k) 
-      {
-	if(k.n>=int(container.size())) container.resize(k.n+1);
-      }
-      void erase(const Edge) { }
-      
-      ///\bug This doesn't work. Why?
-      ///      void set(Edge n, T a) { container[n.n]=a; }
-      void set(Edge n, T a) { container[this->G->id(n)]=a; }
-      //T get(Edge n) const { return container[n.n]; }
-      typename std::vector<T>::reference
-      ///\bug This doesn't work. Why?
-      ///      operator[](Edge n) { return container[n.n]; }
-      operator[](Edge n) { return container[this->G->id(n)]; }
-      typename std::vector<T>::const_reference
-      ///\bug This doesn't work. Why?
-      ///      operator[](Edge n) const { return container[n.n]; }
-      operator[](Edge n) const { return container[this->G->id(n)]; }
-
-      ///\warning There is no safety check at all!
-      ///Using operator = between maps attached to different graph may
-      ///cause serious problem.
-      ///\todo Is this really so?
-      ///\todo It can copy between different types.
-      const EdgeMap<T>& operator=(const EdgeMap<T> &m)
-      {
-	container = m.container;
+      typedef typename NodeGraphType::template NodeMap<V> MapImpl;
+      typedef V Value;
+    public:
+      NodeMap() : MapImpl() {}
+      
+      NodeMap(const EdgeSet& graph) 
+	: MapImpl(graph.G) { }
+
+      NodeMap(const EdgeSet& graph, const Value& value) 
+	: MapImpl(graph.G, value) { }
+
+      NodeMap(const NodeMap& copy) 
+	: MapImpl(static_cast<const MapImpl&>(copy)) {}
+
+      template<typename CMap>
+      NodeMap(const CMap& copy)
+	: MapImpl(copy) { }
+
+      NodeMap& operator=(const NodeMap& copy) {
+	MapImpl::operator=(static_cast<const MapImpl&>(copy));
 	return *this;
       }
-      
-      template<typename TT> friend class EdgeMap;
-
-      template<typename TT>
-      const EdgeMap<T>& operator=(const EdgeMap<TT> &m)
-      {
-	std::copy(m.container.begin(), m.container.end(), container.begin());
+
+      template <typename CMap>
+      NodeMap& operator=(const CMap& copy) {
+	MapImpl::operator=(copy);
 	return *this;
       }
-      
-      void update() {}    //Useless for DynMaps
-      void update(T a) {}  //Useless for DynMaps
-    };
-
+
+    };
   };
 
Index: src/hugo/map_defines.h
===================================================================
--- src/hugo/map_defines.h	(revision 782)
+++ src/hugo/map_defines.h	(revision 782)
@@ -0,0 +1,212 @@
+// -*- c++ -*-
+#ifndef MAP_DEFINES_H
+#define MAP_DEFINES_H
+
+/** Creates the EdgeMapRegistry type an declare a mutable instance 
+ *  named edge_maps.
+ */
+#define CREATE_EDGE_MAP_REGISTRY \
+typedef MapRegistry<Graph, Edge, EdgeIt> EdgeMapRegistry; \
+mutable EdgeMapRegistry edge_maps;
+
+/** Creates the NodeMapRegistry type an declare a mutable instance 
+ *  named node_maps.
+ */
+#define CREATE_NODE_MAP_REGISTRY \
+typedef MapRegistry<Graph, Node, NodeIt> NodeMapRegistry; \
+mutable NodeMapRegistry node_maps;
+
+/** Creates both map registries.
+ */
+#define CREATE_MAP_REGISTRIES \
+CREATE_NODE_MAP_REGISTRY \
+CREATE_EDGE_MAP_REGISTRY
+
+/** Creates a concrete factory type from a template map
+ *  factory to use as node map factory.
+ */
+#define CREATE_NODE_MAP_FACTORY(TemplateFactory) \
+typedef TemplateFactory<NodeMapRegistry> NodeMapFactory;
+
+/** Creates a concrete factory type from a template map
+ *  factory to use as edge map factory.
+ */
+#define CREATE_EDGE_MAP_FACTORY(TemplateFactory) \
+typedef TemplateFactory<EdgeMapRegistry> EdgeMapFactory;
+
+/** Creates both map factories.
+ */
+#define CREATE_MAP_FACTORIES(TemplateFactory) \
+CREATE_NODE_MAP_FACTORY(TemplateFactory) \
+CREATE_EDGE_MAP_FACTORY(TemplateFactory) 
+
+/** Import a map from a concrete map factory. The import method is
+ *  an overloading of the map type.
+ *  The reason to use these macro is that the c++ does not support
+ *  the template typedefs. If a future release of the c++ 
+ *  supports this feature it should be fixed.
+ */
+#define IMPORT_NODE_MAP(Factory) \
+template <typename V> \
+class NodeMap : public Factory::template Map<V> { \
+typedef typename Factory::template Map<V> MapImpl; \
+public: \
+NodeMap() {} \
+NodeMap(const Graph& g) : MapImpl(g, g.node_maps) {} \
+NodeMap(const Graph& g, const V& v) : MapImpl(g, g.node_maps, v) {} \
+NodeMap(const NodeMap& copy) : MapImpl(static_cast<const MapImpl&>(copy)) {} \
+template <typename CMap> NodeMap(const CMap& copy) : MapImpl(copy) {} \
+NodeMap& operator=(const NodeMap& copy) { \
+  MapImpl::operator=(static_cast<const MapImpl&>(copy));\
+  return *this; \
+} \
+template <typename CMap> NodeMap& operator=(const CMap& copy) { \
+  MapImpl::operator=(copy);\
+  return *this; \
+} \
+};
+
+/** Import a map from a concrete map factory. The import method is
+ *  an overloading of the map type.
+ *  The reason to use these macro is that the c++ does not support
+ *  the template typedefs. If a future release of the c++ 
+ *  supports this feature it should be fixed.
+ */
+#define IMPORT_EDGE_MAP(Factory) \
+template <typename V> \
+class EdgeMap : public Factory::template Map<V> { \
+typedef typename Factory::template Map<V> MapImpl; \
+public: \
+EdgeMap() {} \
+EdgeMap(const Graph& g) : MapImpl(g, g.edge_maps) {} \
+EdgeMap(const Graph& g, const V& v) : MapImpl(g, g.edge_maps, v) {} \
+EdgeMap(const EdgeMap& copy) : MapImpl(static_cast<const MapImpl&>(copy)) {} \
+template <typename CMap> EdgeMap(const CMap& copy) : MapImpl(copy) {} \
+EdgeMap& operator=(const EdgeMap& copy) { \
+  MapImpl::operator=(static_cast<const MapImpl&>(copy));\
+  return *this; \
+} \
+template <typename CMap> EdgeMap& operator=(const CMap& copy) { \
+  MapImpl::operator=(copy);\
+  return *this; \
+} \
+};
+
+/** This macro creates both map factories and imports both maps.
+ */
+#define CREATE_MAPS(TemplateFactory) \
+CREATE_MAP_FACTORIES(TemplateFactory) \
+IMPORT_NODE_MAP(NodeMapFactory) \
+IMPORT_EDGE_MAP(EdgeMapFactory)
+
+/** This macro creates MapRegistry for Symmetric Edge Maps.
+ */
+#define CREATE_SYM_EDGE_MAP_REGISTRY \
+typedef SymEdgeIt<Graph, Edge, EdgeIt> SymEdgeIt; \
+typedef MapRegistry<Graph, Edge, SymEdgeIt> SymEdgeMapRegistry; \
+mutable EdgeMapRegistry sym_edge_maps;
+
+/** Creates a concrete factory type from a template map
+ *  factory to use as edge map factory.
+ */
+#define CREATE_SYM_EDGE_MAP_FACTORY(TemplateFactory) \
+typedef SymMapFactory<SymEdgeMapRegistry, TemplateFactory > \
+SymEdgeMapFactory;
+
+/** Import a map from a concrete map factory. The import method is
+ *  an overloading of the map type.
+ *  The reason to use these macro is that the c++ does not support
+ *  the template typedefs. If a future release of the c++ 
+ *  supports this feature it should be fixed.
+ */
+#define IMPORT_SYM_EDGE_MAP(Factory) \
+template <typename V> \
+class SymEdgeMap : public Factory::template Map<V> { \
+typedef typename Factory::template Map<V> MapImpl; \
+public: \
+SymEdgeMap() {} \
+SymEdgeMap(const Graph& g) : MapImpl(g, g.sym_edge_maps) {} \
+SymEdgeMap(const Graph& g, const V& v) : MapImpl(g, g.sym_edge_maps, v) {} \
+SymEdgeMap(const SymEdgeMap& copy) \
+  : MapImpl(static_cast<const MapImpl&>(copy)) {} \
+template <typename CMap> SymEdgeMap(const CMap& copy) : MapImpl(copy) {} \
+SymEdgeMap& operator=(const SymEdgeMap& copy) { \
+  MapImpl::operator=(static_cast<const MapImpl&>(copy));\
+  return *this; \
+} \
+template <typename CMap> SymEdgeMap& operator=(const CMap& copy) { \
+  MapImpl::operator=(copy);\
+  return *this; \
+} \
+};
+
+
+#define KEEP_NODE_MAP(GraphBase) \
+    template <typename V> class NodeMap \
+      : public GraphBase::template NodeMap<V> \
+    { \
+      typedef typename GraphBase::template NodeMap<V> MapImpl; \
+      typedef V Value; \
+    public: \
+      NodeMap() : MapImpl() {} \
+\
+      NodeMap(const Graph& graph) \
+	: MapImpl(static_cast<const GraphBase&>(graph)) { } \
+\
+      NodeMap(const Graph& graph, const Value& value) \
+	: MapImpl(static_cast<const GraphBase&>(graph), value) { } \
+\
+      NodeMap(const NodeMap& copy) \
+	: MapImpl(static_cast<const MapImpl&>(copy)) {} \
+\
+      template<typename CMap> \
+      NodeMap(const CMap& copy) \
+	: MapImpl(copy) {} \
+\
+      NodeMap& operator=(const NodeMap& copy) { \
+	MapImpl::operator=(static_cast<const MapImpl&>(copy)); \
+	return *this; \
+      } \
+\
+      template <typename CMap> \
+      NodeMap& operator=(const CMap& copy) { \
+	MapImpl::operator=(copy); \
+	return *this; \
+      } \
+    };
+
+#define KEEP_EDGE_MAP(GraphBase) \
+    template <typename V> class EdgeMap \
+      : public GraphBase::template EdgeMap<V> \
+    { \
+      typedef typename GraphBase::template EdgeMap<V> MapImpl; \
+      typedef V Value; \
+    public: \
+      EdgeMap() : MapImpl() {} \
+\
+      EdgeMap(const Graph& graph) \
+	: MapImpl(static_cast<const GraphBase&>(graph)) { } \
+\
+      EdgeMap(const Graph& graph, const Value& value) \
+	: MapImpl(static_cast<const GraphBase&>(graph), value) { } \
+\
+      EdgeMap(const EdgeMap& copy) \
+	: MapImpl(static_cast<const MapImpl&>(copy)) {} \
+\
+      template<typename CMap> \
+      EdgeMap(const CMap& copy) \
+	: MapImpl(copy) {} \
+\
+      EdgeMap& operator=(const EdgeMap& copy) { \
+	MapImpl::operator=(static_cast<const MapImpl&>(copy)); \
+	return *this; \
+      } \
+\
+      template <typename CMap> \
+      EdgeMap& operator=(const CMap& copy) { \
+	MapImpl::operator=(copy); \
+	return *this; \
+      } \
+    };
+
+#endif
Index: src/hugo/map_registry.h
===================================================================
--- src/hugo/map_registry.h	(revision 782)
+++ src/hugo/map_registry.h	(revision 782)
@@ -0,0 +1,265 @@
+// -*- c++ -*-
+#ifndef MAP_REGISTRY_H
+#define MAP_REGISTRY_H
+
+#include <vector>
+
+using namespace std;
+
+namespace hugo {
+
+/** 
+ * Registry class to register edge or node maps into the graph. The
+ * registry helps you to implement an observer pattern. If you add
+ * or erase an edge or node you must notify all the maps about the
+ * event.
+*/
+  template <typename G, typename K, typename KIt>
+  class MapRegistry {
+  public:
+    typedef G Graph;
+    typedef K Key;
+    typedef KIt KeyIt;
+	
+
+
+    /**
+     * MapBase is the base class of the registered maps.
+     * It defines the core modification operations on the maps and
+     * implements some helper functions. 
+     */
+    class MapBase {
+    public:
+      typedef G Graph;
+      typedef K Key;
+      typedef KIt KeyIt;
+
+      typedef MapRegistry<G, K, KIt> Registry;
+	
+      friend class MapRegistry<G, K, KIt>;
+
+      /**
+       * Default constructor for MapBase.
+       */
+
+      MapBase() : graph(0), registry(0) {}
+		
+      /** 
+       * Simple constructor to register into a graph registry.
+      */
+	
+      MapBase(const Graph& g, Registry& r) : graph(&g), registry(0) {
+	r.attach(*this);
+      }
+
+      /** 
+       * Copy constructor to register into the registry.
+      */	
+	
+      MapBase(const MapBase& copy) : registry(0), graph(copy.graph) {
+	if (copy.registry) {
+	  copy.registry->attach(*this);
+	}
+      } 
+	
+      /** 
+       * Assign operator.
+      */	
+
+      const MapBase& operator=(const MapBase& copy) {
+	if (registry) {
+	  registry->detach(*this);
+	}
+	graph = copy.graph;
+	if (copy.registry) {
+	  copy.registry->attach(*this);
+	}
+      }
+	
+
+      /** 
+       * Destructor. 
+      */		
+
+      virtual ~MapBase() {
+	if (registry) {
+	  registry->detach(*this);
+	}
+      }
+
+      /*
+       * Returns the graph that the map belongs to.
+      */
+
+      const Graph* getGraph() const { return graph; }
+	
+    protected:
+		
+      const Graph* graph;     
+      Registry* registry;
+
+      int registry_index;
+
+    protected:
+	
+      /**
+	 Helper function to implement constructors in the subclasses.
+      */
+	
+      virtual void init() {
+	for (KeyIt it(*graph); it != INVALID; ++it) {
+	  add(it);
+	}
+      }
+	
+      /**
+	 Helper function to implement the destructor in the subclasses.
+      */
+	
+      virtual void destroy() {
+	for (KeyIt it(*getGraph()); it != INVALID; ++it) {
+	  erase(it);
+	}
+      }
+	
+      /** 
+	  The add member function should be overloaded in the subclasses.
+	  \e Add extends the map with the new node.
+      */
+	
+      virtual void add(const Key&) = 0;	
+      /** 
+	  The erase member function should be overloaded in the subclasses.
+	  \e Erase removes the node from the map.
+      */
+	
+      virtual void erase(const Key&) = 0;
+
+      /**
+       *  The clear member function should be overloaded in the subclasses.
+       *  \e Clear makes empty the data structure.
+       */
+
+      virtual void clear() = 0;
+	
+      /**
+	 Exception class to throw at unsupported operation.
+      */
+	
+      class NotSupportedOperationException {};
+
+    };
+	
+  protected:
+	
+    /** 
+     * The container type of the maps.
+     */
+    typedef std::vector<MapBase*> Container; 
+
+    /**
+     * The container of the registered maps.
+     */
+    Container container;
+
+		
+  public:
+	
+    /**
+     * Default Constructor of the MapRegistry. It creates an empty registry.
+     */
+    MapRegistry() {}
+	
+    /**
+     * Copy Constructor of the MapRegistry. The new registry does not steal
+     * the maps from the right value. The new registry will be an empty.
+     */
+    MapRegistry(const MapRegistry&) {}
+		
+    /**
+     * Assign operator. The left value does not steal the maps 
+     * from the right value. The left value will be an empty registry.
+     */
+    MapRegistry& operator=(const MapRegistry&) {
+      typename Container::iterator it;
+      for (it = container.begin(); it != container.end(); ++it) {
+	(*it)->destroy();
+	(*it)->graph = 0;
+	(*it)->registry = 0;
+      }
+    }
+				
+    /**
+     * Destructor of the MapRegistry.
+     */
+    ~MapRegistry() {
+      typename Container::iterator it;
+      for (it = container.begin(); it != container.end(); ++it) {
+	(*it)->destroy();
+	(*it)->registry = 0;
+	(*it)->graph = 0;
+      }
+    }
+	
+	
+    public:
+	
+    /**
+     * Attach a map into thr registry. If the map has been attached
+     * into an other registry it is detached from that automaticly.
+     */
+    void attach(MapBase& map) {
+      if (map.registry) {
+	map.registry->detach(map);
+      }
+      container.push_back(&map);
+      map.registry = this;
+      map.registry_index = container.size()-1;
+    } 
+	
+    /**
+     * Detach the map from the registry.
+     */
+    void detach(MapBase& map) {
+      container.back()->registry_index = map.registry_index; 
+      container[map.registry_index] = container.back();
+      container.pop_back();
+      map.registry = 0;
+      map.graph = 0;
+    }
+	
+		
+    /**
+     * Notify all the registered maps about a Key added.
+     */
+    virtual void add(Key& key) {
+      typename Container::iterator it;
+      for (it = container.begin(); it != container.end(); ++it) {
+	(*it)->add(key);
+      }
+    }	
+		
+    /**
+     * Notify all the registered maps about a Key erased.
+     */ 
+    virtual void erase(Key& key) {
+      typename Container::iterator it;
+      for (it = container.begin(); it != container.end(); ++it) {
+	(*it)->erase(key);
+      }
+    }
+
+    /**
+     * Notify all the registered maps about the map should be cleared.
+     */ 
+    virtual void clear() {
+      typename Container::iterator it;
+      for (it = container.begin(); it != container.end(); ++it) {
+	(*it)->clear();
+      }
+    }
+  };
+
+}
+
+#endif
Index: src/hugo/smart_graph.h
===================================================================
--- src/hugo/smart_graph.h	(revision 774)
+++ src/hugo/smart_graph.h	(revision 782)
@@ -9,7 +9,13 @@
 
 #include <vector>
-#include <limits.h>
+#include <climits>
 
 #include <hugo/invalid.h>
+
+#include <hugo/array_map_factory.h>
+#include <hugo/sym_map_factory.h>
+#include <hugo/map_registry.h>
+
+#include <hugo/map_defines.h>
 
 namespace hugo {
@@ -17,5 +23,5 @@
 /// \addtogroup graphs
 /// @{
-  class SymSmartGraph;
+//  class SymSmartGraph;
 
   ///A smart graph class.
@@ -54,37 +60,11 @@
     std::vector<EdgeT> edges;
     
-    protected:
-    
-    template <typename Key> class DynMapBase
-    {
-    protected:
-      const SmartGraph* G; 
-    public:
-      virtual void add(const Key k) = 0;
-      virtual void erase(const Key k) = 0;
-      DynMapBase(const SmartGraph &_G) : G(&_G) {}
-      virtual ~DynMapBase() {}
-      friend class SmartGraph;
-    };
     
   public:
-    template <typename T> class EdgeMap;
-    template <typename T> class NodeMap;
+
+    typedef SmartGraph Graph;
 
     class Node;
     class Edge;
-
-    //  protected:
-    // HELPME:
-  protected:
-    ///\bug It must be public because of SymEdgeMap.
-    ///
-    mutable std::vector<DynMapBase<Node> * > dyn_node_maps;
-    ///\bug It must be public because of SymEdgeMap.
-    ///
-    mutable std::vector<DynMapBase<Edge> * > dyn_edge_maps;
-    
-  public:
-
 
     class NodeIt;
@@ -93,6 +73,6 @@
     class InEdgeIt;
     
-    template <typename T> class NodeMap;
-    template <typename T> class EdgeMap;
+    CREATE_MAP_REGISTRIES;
+    CREATE_MAPS(ArrayMapFactory);
     
   public:
@@ -101,12 +81,4 @@
     SmartGraph(const SmartGraph &_g) : nodes(_g.nodes), edges(_g.edges) { }
     
-    ~SmartGraph()
-    {
-      for(std::vector<DynMapBase<Node> * >::iterator i=dyn_node_maps.begin();
-	  i!=dyn_node_maps.end(); ++i) (**i).G=NULL;
-      for(std::vector<DynMapBase<Edge> * >::iterator i=dyn_edge_maps.begin();
-	  i!=dyn_edge_maps.end(); ++i) (**i).G=NULL;
-    }
-
     int nodeNum() const { return nodes.size(); }  //FIXME: What is this?
     int edgeNum() const { return edges.size(); }  //FIXME: What is this?
@@ -138,7 +110,6 @@
       nodes.push_back(NodeT()); //FIXME: Hmmm...
 
-      for(std::vector<DynMapBase<Node> * >::iterator i=dyn_node_maps.begin();
-	  i!=dyn_node_maps.end(); ++i) (**i).add(n);
-
+      
+      node_maps.add(n);
       return n;
     }
@@ -151,6 +122,5 @@
       nodes[u.n].first_out=nodes[v.n].first_in=e.n;
 
-      for(std::vector<DynMapBase<Edge> * >::iterator i=dyn_edge_maps.begin();
-	  i!=dyn_edge_maps.end(); ++i) (**i).add(e);
+      edge_maps.add(e);
 
       return e;
@@ -173,5 +143,10 @@
     }
     
-    void clear() {nodes.clear();edges.clear();}
+    void clear() {
+      edge_maps.clear();
+      edges.clear();
+      node_maps.clear();
+      nodes.clear();
+    }
 
     class Node {
@@ -289,182 +264,4 @@
 //       ///Validity check
 //       operator bool() { return Edge::operator bool(); }      
-    };
-
-    template <typename T> class NodeMap : public DynMapBase<Node>
-    {
-      std::vector<T> container;
-
-    public:
-      typedef T ValueType;
-      typedef Node KeyType;
-
-      NodeMap(const SmartGraph &_G) :
-	DynMapBase<Node>(_G), container(_G.maxNodeId())
-      {
-	G->dyn_node_maps.push_back(this);
-      }
-      NodeMap(const SmartGraph &_G,const T &t) :
-	DynMapBase<Node>(_G), container(_G.maxNodeId(),t)
-      {
-	G->dyn_node_maps.push_back(this);
-      }
-      
-      NodeMap(const NodeMap<T> &m) :
- 	DynMapBase<Node>(*m.G), container(m.container)
-      {
- 	G->dyn_node_maps.push_back(this);
-      }
-
-      template<typename TT> friend class NodeMap;
- 
-      ///\todo It can copy between different types.
-      ///\todo We could use 'copy'
-      template<typename TT> NodeMap(const NodeMap<TT> &m) :
-	DynMapBase<Node>(*m.G), container(m.container.size())
-      {
-	G->dyn_node_maps.push_back(this);
-	typename std::vector<TT>::const_iterator i;
-	for(typename std::vector<TT>::const_iterator i=m.container.begin();
-	    i!=m.container.end();
-	    i++)
-	  container.push_back(*i);
-      }
-      ~NodeMap()
-      {
-	if(G) {
-	  std::vector<DynMapBase<Node>* >::iterator i;
-	  for(i=G->dyn_node_maps.begin();
-	      i!=G->dyn_node_maps.end() && *i!=this; ++i) ;
-	  //if(*i==this) G->dyn_node_maps.erase(i); //FIXME: Way too slow...
-	  //A better way to do that: (Is this really important?)
-	  if(*i==this) {
-	    *i=G->dyn_node_maps.back();
-	    G->dyn_node_maps.pop_back();
-	  }
-	}
-      }
-
-      void add(const Node k) 
-      {
-	if(k.n>=int(container.size())) container.resize(k.n+1);
-      }
-
-      void erase(const Node) { }
-      
-      void set(Node n, T a) { container[n.n]=a; }
-      //'T& operator[](Node n)' would be wrong here
-      typename std::vector<T>::reference
-      operator[](Node n) { return container[n.n]; }
-      //'const T& operator[](Node n)' would be wrong here
-      typename std::vector<T>::const_reference 
-      operator[](Node n) const { return container[n.n]; }
-
-      ///\warning There is no safety check at all!
-      ///Using operator = between maps attached to different graph may
-      ///cause serious problem.
-      ///\todo Is this really so?
-      ///\todo It can copy between different types.
-      const NodeMap<T>& operator=(const NodeMap<T> &m)
-      {
-	container = m.container;
-	return *this;
-      }
-      template<typename TT>
-      const NodeMap<T>& operator=(const NodeMap<TT> &m)
-      {
-	std::copy(m.container.begin(), m.container.end(), container.begin());
-	return *this;
-      }
-      
-      void update() {}    //Useless for Dynamic Maps
-      void update(T a) {}  //Useless for Dynamic Maps
-    };
-    
-    template <typename T> class EdgeMap : public DynMapBase<Edge>
-    {
-      std::vector<T> container;
-
-    public:
-      typedef T ValueType;
-      typedef Edge KeyType;
-
-      EdgeMap(const SmartGraph &_G) :
-	DynMapBase<Edge>(_G), container(_G.maxEdgeId())
-      {
-	//FIXME: What if there are empty Id's?
-	//FIXME: Can I use 'this' in a constructor?
-	G->dyn_edge_maps.push_back(this);
-      }
-      EdgeMap(const SmartGraph &_G,const T &t) :
-	DynMapBase<Edge>(_G), container(_G.maxEdgeId(),t)
-      {
-	G->dyn_edge_maps.push_back(this);
-      } 
-      EdgeMap(const EdgeMap<T> &m) :
- 	DynMapBase<Edge>(*m.G), container(m.container)
-      {
- 	G->dyn_edge_maps.push_back(this);
-      }
-
-      template<typename TT> friend class EdgeMap;
-
-      ///\todo It can copy between different types.
-      template<typename TT> EdgeMap(const EdgeMap<TT> &m)
-	: DynMapBase<Edge>(*m.G), container(m.container.size())
-      {
-	G->dyn_edge_maps.push_back(this);
-	typename std::vector<TT>::const_iterator i;
-	for(typename std::vector<TT>::const_iterator i=m.container.begin();
-	    i!=m.container.end();
-	    i++)
-	  container.push_back(*i);
-      }
-      ~EdgeMap()
-      {
-	if(G) {
-	  std::vector<DynMapBase<Edge>* >::iterator i;
-	  for(i=G->dyn_edge_maps.begin();
-	      i!=G->dyn_edge_maps.end() && *i!=this; ++i) ;
-	  //if(*i==this) G->dyn_edge_maps.erase(i); //Way too slow...
-	  //A better way to do that: (Is this really important?)
-	  if(*i==this) {
-	    *i=G->dyn_edge_maps.back();
-	    G->dyn_edge_maps.pop_back();
-	  }
-	}
-      }
-      
-      void add(const Edge k) 
-      {
-	if(k.n>=int(container.size())) container.resize(k.n+1);
-      }
-      void erase(const Edge) { }
-      
-      void set(Edge n, T a) { container[n.n]=a; }
-      //T get(Edge n) const { return container[n.n]; }
-      typename std::vector<T>::reference
-      operator[](Edge n) { return container[n.n]; }
-      typename std::vector<T>::const_reference
-      operator[](Edge n) const { return container[n.n]; }
-
-      ///\warning There is no safety check at all!
-      ///Using operator = between maps attached to different graph may
-      ///cause serious problem.
-      ///\todo Is this really so?
-      ///\todo It can copy between different types.
-      const EdgeMap<T>& operator=(const EdgeMap<T> &m)
-      {
-	container = m.container;
-	return *this;
-      }
-      template<typename TT>
-      const EdgeMap<T>& operator=(const EdgeMap<TT> &m)
-      {
-	std::copy(m.container.begin(), m.container.end(), container.begin());
-	return *this;
-      }
-      
-      void update() {}    //Useless for DynMaps
-      void update(T a) {}  //Useless for DynMaps
     };
 
@@ -494,6 +291,12 @@
   {
   public:
-    template<typename T> class SymEdgeMap;
-    template<typename T> friend class SymEdgeMap;
+    typedef SymSmartGraph Graph;
+
+    KEEP_NODE_MAP(SmartGraph);
+    KEEP_EDGE_MAP(SmartGraph);
+
+    CREATE_SYM_EDGE_MAP_REGISTRY;
+    CREATE_SYM_EDGE_MAP_FACTORY(ArrayMapFactory);
+    IMPORT_SYM_EDGE_MAP(SymEdgeMapFactory);
 
     SymSmartGraph() : SmartGraph() { }
@@ -518,105 +321,8 @@
     }
     
-    ///Common data storage for the edge pairs.
-
-    ///This map makes it possible to store data shared by the oppositely
-    ///directed pairs of edges.
-    template <typename T> class SymEdgeMap : public DynMapBase<Edge>
-    {
-      std::vector<T> container;
-      
-    public:
-      typedef T ValueType;
-      typedef Edge KeyType;
-
-      SymEdgeMap(const SymSmartGraph &_G) :
-	DynMapBase<Edge>(_G), container(_G.maxEdgeId()/2)
-      {
-	static_cast<const SymSmartGraph*>(G)->dyn_edge_maps.push_back(this);
-      }
-      SymEdgeMap(const SymSmartGraph &_G,const T &t) :
-	DynMapBase<Edge>(_G), container(_G.maxEdgeId()/2,t)
-      {
-	G->dyn_edge_maps.push_back(this);
-      }
-
-      SymEdgeMap(const SymEdgeMap<T> &m) :
- 	DynMapBase<SymEdge>(*m.G), container(m.container)
-      {
- 	G->dyn_node_maps.push_back(this);
-      }
-
-      //      template<typename TT> friend class SymEdgeMap;
-
-      ///\todo It can copy between different types.
-      ///
-
-      template<typename TT> SymEdgeMap(const SymEdgeMap<TT> &m)
-	: DynMapBase<SymEdge>(*m.G), container(m.container.size())
-      {
-	G->dyn_node_maps.push_back(this);
-	typename std::vector<TT>::const_iterator i;
-	for(typename std::vector<TT>::const_iterator i=m.container.begin();
-	    i!=m.container.end();
-	    i++)
-	  container.push_back(*i);
-      }
- 
-      ~SymEdgeMap()
-      {
-	if(G) {
-	  std::vector<DynMapBase<Edge>* >::iterator i;
-	  for(i=static_cast<const SymSmartGraph*>(G)->dyn_edge_maps.begin();
-	      i!=static_cast<const SymSmartGraph*>(G)->dyn_edge_maps.end()
-		&& *i!=this; ++i) ;
-	  //if(*i==this) G->dyn_edge_maps.erase(i); //Way too slow...
-	  //A better way to do that: (Is this really important?)
-	  if(*i==this) {
-	    *i=static_cast<const SymSmartGraph*>(G)->dyn_edge_maps.back();
-	    static_cast<const SymSmartGraph*>(G)->dyn_edge_maps.pop_back();
-	  }
-	}
-      }
-      
-      void add(const Edge k) 
-      {
-	if(!k.idref()%2&&k.idref()/2>=int(container.size()))
-	  container.resize(k.idref()/2+1);
-      }
-      void erase(const Edge k) { }
-      
-      void set(Edge n, T a) { container[n.idref()/2]=a; }
-      //T get(Edge n) const { return container[n.idref()/2]; }
-      typename std::vector<T>::reference
-      operator[](Edge n) { return container[n.idref()/2]; }
-      typename std::vector<T>::const_reference
-      operator[](Edge n) const { return container[n.idref()/2]; }
-
-      ///\warning There is no safety check at all!
-      ///Using operator = between maps attached to different graph may
-      ///cause serious problem.
-      ///\todo Is this really so?
-      ///\todo It can copy between different types.
-      const SymEdgeMap<T>& operator=(const SymEdgeMap<T> &m)
-      {
-	container = m.container;
-	return *this;
-      }
-      template<typename TT>
-      const SymEdgeMap<T>& operator=(const SymEdgeMap<TT> &m)
-      {
-	std::copy(m.container.begin(), m.container.end(), container.begin());
-	return *this;
-      }
-      
-      void update() {}    //Useless for DynMaps
-      void update(T a) {}  //Useless for DynMaps
-
-    };
 
   };
   
   /// @}  
-
 } //namespace hugo
 
Index: src/hugo/sym_map_factory.h
===================================================================
--- src/hugo/sym_map_factory.h	(revision 782)
+++ src/hugo/sym_map_factory.h	(revision 782)
@@ -0,0 +1,107 @@
+// -*- c++ -*-
+#ifndef SYM_MAP_FACTORY_H
+#define SYM_MAP_FACTORY_H
+
+namespace hugo {
+
+  template <typename Graph, typename Edge, typename EdgeIt>
+  class SymEdgeIt : public EdgeIt {
+  public:
+
+    SymEdgeIt() 
+      : EdgeIt() {}
+
+    SymEdgeIt(const Graph& graph) 
+      : EdgeIt(graph) {}
+
+    SymEdgeIt(Invalid invalid) 
+      : EdgeIt(invalid) {}
+
+    SymEdgeIt(const Graph& graph, Edge edge)
+      : EdgeIt(graph, edge) {}
+
+    SymEdgeIt& operator++() {
+      EdgeIt::operator++();
+      while ( n != -1 && (n & 1)) {
+	EdgeIt::operator++();
+      }
+      return *this;
+    }
+  };
+
+  template <typename MapRegistry, template <typename> class MapFactory>
+  class SymMapFactory {
+
+  public:
+		
+    typedef typename MapRegistry::Graph Graph;
+    typedef typename MapRegistry::Key Key;
+    typedef typename MapRegistry::KeyIt KeyIt;
+
+    typedef typename MapRegistry::MapBase MapBase;
+
+    template <typename V>
+    class Map : public MapFactory<MapRegistry>::template Map<V> {
+
+      typedef typename MapFactory<MapRegistry>::template Map<V> MapImpl;
+    public:
+
+      typedef V Value;
+
+      Map() : MapImpl() {}
+
+      Map(const Graph& g, MapRegistry& r) : MapImpl(g, r) {}
+
+      Map(const Graph& g, MapRegistry& r, const Value& v) : MapImpl(g, r, v) {}
+
+      Map(const Map& copy) : MapImpl(static_cast<const MapImpl&>(copy)) {}
+
+      template <typename CMap> Map(const CMap& copy) : MapImpl(copy) {}
+
+      Map& operator=(const Map& copy) {
+	MapImpl::operator=(static_cast<const MapImpl&>(copy));
+	return *this;
+      }
+
+      template <typename CMap> Map& operator=(const CMap& copy) {
+	MapImpl::operator=(copy);
+	return *this;
+      }
+   
+      Value& operator[](const Key& key) {
+	int id = MapBase::getGraph()->id(key);	
+	return MapImpl::operator[](id >> 1);
+      } 
+		
+      const Value& operator[](const Key& key) const {
+	int id = MapBase::getGraph()->id(key);
+	return MapImpl::operator[](id >> 1);
+      }
+	
+      const Value& get(const Key& key) const {
+	int id = MapBase::getGraph()->id(key);
+	return MapImpl::operator[](id >> 1);
+      } 
+		
+      void set(const Key& key, const Value& val) {
+	int id = MapBase::getGraph()->id(key);
+	MapImpl::operator[](id >> 1) = val;
+      }
+		
+      void add(const Key& key) {
+	int id = MapBase::getGraph()->id(key);
+	if (id & 1) return;
+	MapImpl::add(key);
+      }
+		
+      void erase(const Key& key) {
+	int id = MapBase::getGraph()->id(key);
+	if (id & 1) return;
+	MapImpl::add(key);
+      }
+
+
+    };  
+  };
+}
+#endif
Index: src/hugo/vector_map_factory.h
===================================================================
--- src/hugo/vector_map_factory.h	(revision 782)
+++ src/hugo/vector_map_factory.h	(revision 782)
@@ -0,0 +1,338 @@
+// -*- c++ -*-
+#ifndef VECTOR_MAP_H
+#define VECTOR_MAP_H
+
+#include <vector>
+
+#include <hugo/extended_pair.h>
+
+namespace hugo {
+
+  /** The VectorMapFactory template class is a factory class
+   *  to create maps for the edge and nodes. This map factory
+   *  use the std::vector to implement the container function.
+   *
+   *  The template parameter is the MapRegistry that the maps
+   *  will belong to.
+   */
+	
+  template <typename MapRegistry>
+  class VectorMapFactory {
+  public:
+		
+    /// The graph type of the maps. 
+    typedef typename MapRegistry::Graph Graph;
+    /// The key type of the maps.
+    typedef typename MapRegistry::Key Key;
+    /// The iterator to iterate on the keys.
+    typedef typename MapRegistry::KeyIt KeyIt;
+
+    /// The MapBase of the Map which imlements the core regisitry function.
+    typedef typename MapRegistry::MapBase MapBase;
+
+		
+    /** The template Map type.
+     */
+    template <typename V> 
+    class Map : public MapBase {
+    public:
+
+      /// The value type of the map.
+      typedef V Value;
+
+      typedef std::vector<Value> Container;	
+
+      /** Default constructor for the map.
+       */
+      Map() {}
+		
+      /** Graph and Registry initialized map constructor.
+       */
+      Map(const Graph& g, MapRegistry& r) : MapBase(g, r) {
+	init();
+      }
+
+      /** Constructor to use default value to initialize the map. 
+       */
+      Map(const Graph& g, MapRegistry& r, const Value& v) : MapBase(g, r) {
+	for (KeyIt it(*getGraph()); it != INVALID; ++it) {
+          int id = getGraph()->id(it);
+	  if (id >= container.size()) {
+	    container.resize(id + 1);
+	  }
+	  set(it, v);
+        }
+      }
+
+      /** Constructor to copy a map of an other map type.
+       */
+      template <typename CMap> Map(const CMap& copy) : MapBase(copy) {
+	if (getGraph()) {
+	  for (KeyIt it(*getGraph()); it != INVALID; ++it) {
+	    int id = getGraph()->id(it);
+	    if (id >= container.size()) {
+	      container.resize(id + 1);
+	    }
+	    set(it, copy[it]);
+	  }
+	}
+      }
+
+      /** Assign operator to copy a map an other map type.
+       */
+      template <typename CMap> Map& operator=(const CMap& copy) {
+	if (getGraph()) {
+	  destroy();
+	} 
+	this->MapBase::operator=(copy);
+	if (getGraph()) {
+	  for (KeyIt it(*getGraph()); it != INVALID; ++it) {
+	    int id = getGraph()->id(it);
+	    if (id >= container.size()) {
+	      container.resize(id + 1);
+	    }
+	    set(it, copy[it]);
+	  }
+	}
+      }
+
+      /** The destructor of the map.
+       */
+      virtual ~Map() {
+      }
+		
+      /**
+       * The subscript operator. The map can be subscripted by the
+       * actual keys of the graph. 
+       */
+      typename Container::reference operator[](const Key& key) {
+	int id = getGraph()->id(key);
+	return container[id];
+      } 
+		
+      /**
+       * The const subscript operator. The map can be subscripted by the
+       * actual keys of the graph. 
+       */
+      typename Container::const_reference operator[](const Key& key) const {
+	int id = getGraph()->id(key);
+	return container[id];
+      }
+
+      /** 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) {
+	int id = getGraph()->id(key);
+	container[id] = val;
+      }
+		
+      /** Add a new key to the map. It called by the map registry.
+       */
+      void add(const Key& key) {
+	int id = getGraph()->id(key);
+	if (id >= container.size()) {
+	  container.resize(id + 1);
+	}
+      }
+		
+      /** Erase a key from the map. It called by the map registry.
+       */
+      void erase(const Key& key) {}
+
+      /** Clear the data structure.
+       */
+      void clear() { 
+	container.clear();
+      }
+
+      /** Compatible iterator with the stl maps' iterators.
+       *  It iterates on pairs of a key and a value.
+       */
+      class iterator {
+	friend class Map;
+	friend class const_iterator;
+      private:
+
+	/** Private constructor to initalize the the iterators returned
+	 *  by the begin() and end().
+	 */
+	iterator (Map& pmap, const KeyIt& pit) : map(&pmap), it(pit) {}
+
+      public:
+
+	/** Default constructor. 
+	 */
+	iterator() {}
+
+	typedef extended_pair<const Key&, const Key&, 
+			      Value&, Value&> Reference;
+
+	/** Dereference operator for map.
+	 */	 
+	Reference operator*() {
+	  return Reference(it, (*map)[it]);
+	}
+
+	class Pointer {
+	  friend class iterator;
+	private:
+	  Reference data;
+	  Pointer(const Key& key, Value& val) : data(key, val) {}
+	public:
+	  Reference* operator->() {return &data;}
+	};
+
+	/** Arrow operator for map.
+	 */	 
+	Pointer operator->() {
+	  return Pointer(it, ((*map)[it])); 
+	}
+
+	/** The pre increment operator of the map.
+	 */
+	iterator& operator++() { 
+	  ++it; 
+	  return *this; 
+	}
+
+	/** The post increment operator of the map.
+	 */
+	iterator operator++(int) { 
+	  iterator tmp(it); 
+	  ++it; 
+	  return tmp; 
+	}
+
+	/** The equality operator of the map.
+	 */
+	bool operator==(const_iterator p_it) {
+	  return p_it.it == it;
+	}
+	
+	/** The not-equality operator of the map.
+	 */
+	bool operator!=(const_iterator p_it) {
+	  return !(*this == p_it);
+	}
+
+	
+      private:
+	Map* map;
+	KeyIt it;
+      };
+
+      /** Returns the begin iterator of the map.
+       */
+      iterator begin() {
+	return iterator(*this, KeyIt(*getGraph()));
+      }
+
+      /** Returns the end iterator of the map.
+       */
+      iterator end() {
+	return iterator(*this, INVALID);
+      }
+
+      class const_iterator {
+	friend class Map;
+	friend class iterator;
+      private:
+
+	/** Private constructor to initalize the the iterators returned
+	 *  by the begin() and end().
+	 */
+	const_iterator (const Map& pmap, const KeyIt& pit) 
+	  : map(&pmap), it(pit) {}
+
+      public:
+
+	/** Default constructor. 
+	 */
+	const_iterator() {}
+
+	/** Constructor to convert iterator to const_iterator.
+	 */
+	const_iterator(iterator p_it) : map(p_it.map), it(p_it.it) {}
+      
+	typedef extended_pair<const Key&, const Key&, 
+	  const Value&, const Value&> Reference;
+
+	/** Dereference operator for map.
+	 */	 
+	Reference operator*() {
+	  return Reference(it, (*map)[it]);
+	}
+
+
+	class Pointer {
+	  friend class const_iterator;
+	private:
+	  Reference data;
+	  Pointer(const Key& key, const Value& val) : data(key, val) {}
+	public:
+	  Reference* operator->() {return &data;}
+	};
+
+	/** Arrow operator for map.
+	 */	 
+	Pointer operator->() {
+	  return Pointer(it, ((*map)[it])); 
+	}
+
+	/** The pre increment operator of the map.
+	 */
+	const_iterator& operator++() { 
+	  ++it; 
+	  return *this; 
+	}
+
+	/** The post increment operator of the map.
+	 */
+	const_iterator operator++(int) { 
+	  const_iterator tmp(it); 
+	  ++it; 
+	  return tmp; 
+	}
+
+	/** The equality operator of the map.
+	 */
+	bool operator==(const_iterator p_it) {
+	  return p_it.it == it;
+	}
+	
+	/** The not-equality operator of the map.
+	 */
+	bool operator!=(const_iterator p_it) {
+	  return !(*this == p_it);
+	}
+	
+
+      private:
+	const Map* map;
+	KeyIt it;
+      };
+
+      /** Returns the begin const_iterator of the map.
+       */
+      const_iterator begin() const {
+	return const_iterator(*this, KeyIt(*getGraph()));
+      }
+
+      /** Returns the end const_iterator of the map.
+       */
+      const_iterator end() const {
+	return const_iterator(*this, INVALID);
+      }
+
+      private:
+		
+      Container container;
+
+    };
+		
+  };
+
+}
+
+#endif
