Index: c/work/deba/edge_map_base.h
===================================================================
--- src/work/deba/edge_map_base.h	(revision 377)
+++ 	(revision )
@@ -1,121 +1,0 @@
-#ifndef EDGE_MAP_BASE_H
-#define EDGE_MAP_BASE_H
-
-/**
-	Template base class for implementing mapping on edges.
-	\param The first template parameter is the Graph class. The Graph
-		must have an \emp edge_maps member with \emp EdgeMapRegistry class.
-	\param The second template parameter is the Edge type of the class.
-	
-*/
-
-template <typename G, typename K>
-class EdgeMapBase {
-
-#include "edge_map_registry.h"
-
-public:
-	typedef G Graph;
-	friend class EdgeMapRegistry<G, K>;
-
-	typedef K KeyType;
-	
-	/** 
-		Default constructor.
-	*/	
-	
-	EdgeMapBase() : graph(0) {}
-
-	/** 
-		Simple constructor to register into a graph.
-	*/
-	
-	EdgeMapBase(Graph& g) : graph(&g) {
-		graph->edge_maps.add(*this);
-	}
-
-	/** 
-		Copy constructor with registering into the map.
-	*/	
-	
-	EdgeMapBase(const EdgeMapBase& copy) : graph(copy.graph) {
-		if (graph) {
-			graph->edge_maps.add(*this);
-		}
-	} 
-	
-	/** 
-		Assign operator.
-	*/	
-
-	const EdgeMapBase& operator=(const EdgeMapBase& copy) {
-		if (graph) {
-			graph.edge_maps.erase(*this);
-		}
-		graph = copy.graph;
-		if (graph) {
-			graph->edge_maps.add(*this);
-		}
-		
-	}
-	
-
-	/** 
-		Destructor.
-	*/	
-
-	virtual ~EdgeMapBase() {
-		if (graph) {
-			graph.edge_maps.erase(*this);
-		}
-	}
-	
-protected:
-	
-	Graph* graph;
-
-	int graph_index;
-	
-	/**
-		Helper function to implement the default constructor in the subclasses.
-	*/
-	
-	void init() {
-		for (typename Graph::EdgeIt it(g); g.valid(it); g.next(it)) {
-			add(it);
-		}
-	}
-	
-	/**
-		Helper function to implement the destructor in the subclasses.
-	*/
-	
-	void destroy() {
-		for (typename Graph::EdgeIt it(g); g.valid(it); g.next(it)) {
-			erase(it);
-		}
-	}
-	
-	/** 
-		The add member function should be overloaded in the subclasses.
-		\e Add extends the map with the new edge.
-	*/
-	
-	virtual void add(const KeyType&) = 0;
-	
-	/** 
-		The erase member function should be overloaded in the subclasses.
-		\e Erase removes the edge from the map.
-	*/
-	
-	virtual void erase(const KeyType&) = 0;
-	
-	/**
-		Exception class to throw at unsupported operation.
-	*/
-	
-	class NotSupportedOperationException {};
-
-};
-
-#endif
Index: c/work/deba/edge_map_registry.h
===================================================================
--- src/work/deba/edge_map_registry.h	(revision 377)
+++ 	(revision )
@@ -1,65 +1,0 @@
-#ifndef EDGE_MAP_REGISTRY_H
-#define EDGE_MAP_REGISTRY_H
-
-#include <vector>
-
-template <typename G, typename K>
-class EdgeMapRegistry;
-
-#include "edge_map_base.h"
-
-template <typename G, typename K>
-class EdgeMapRegistry {
-public:
-	typedef G Graph;
-	typedef K Edge;
-	
-	typedef EdgeMapBase<Graph, Edge> MapBase;
-	friend class MapBase;
-
-protected:
-	
-	Graph* graph;
-
-	typedef std::vector<MapBase*> Container; 
-	
-	Container container;
-
-public:
-
-	EdgeMapRegistry(Graph g) : graph(&g) {}
-
-	void add(MapBase& map_base) {
-		if (map_base.graph) {
-			map_base.graph->edge_maps.erase(map_base);
-		}
-		container.push_back(&map_base);
-		map_base.graph = graph;
-		map_base.graph_index = container.size()-1;
-	} 
-	
-	void erase(MapBase& map_base) {
-		container.back()->graph_index = map_base.graph_index; 
-		container[map_base.graph_index] = container.back();
-		container.pop_back();
-		map_base.graph = 0;
-	}
-
-	
-	void add(Edge& edge) {
-		typename Container::iterator it;
-		for (it = container.begin(); it != container.end(); ++it) {
-			(*it)->add(edge);
-		}
-	}
-	
-	void erase(Edge& edge) {
-		typename Container::iterator it;
-		for (it = container.begin(); it != container.end(); ++it) {
-			(*it)->erase(edge);
-		}
-	}
-
-};
-
-#endif
Index: src/work/deba/invalid.h
===================================================================
--- src/work/deba/invalid.h	(revision 378)
+++ src/work/deba/invalid.h	(revision 378)
@@ -0,0 +1,33 @@
+// -*- mode:C++ -*-
+
+#ifndef HUGO_INVALID_H
+#define HUGO_INVALID_H
+
+///\file
+///\brief Definition of INVALID.
+
+namespace hugo {
+
+  /// Dummy type to make it easier to make invalid iterators.
+  
+  /// See \ref INVALID, how to use it.
+  
+  struct Invalid {};
+  
+  /// Invalid iterators.
+  
+  /// \ref Invalid is a global type that converts to each iterator
+  /// in such a way that the value of the target iterator will be invalid.
+
+  // It is also used to convert the \c INVALID constant to the
+  // node iterator that makes is possible to write 
+
+  //extern Invalid INVALID;
+
+  //const Invalid &INVALID = *(Invalid *)0;
+  const Invalid INVALID = Invalid();
+
+};
+
+#endif
+  
Index: src/work/deba/main.cpp
===================================================================
--- src/work/deba/main.cpp	(revision 378)
+++ src/work/deba/main.cpp	(revision 378)
@@ -0,0 +1,15 @@
+#include <iostream>
+#include "test_graph.h"
+
+using namespace std;
+using namespace hugo;
+
+
+int main() {
+	ListGraph g;
+	ListGraph::NodeMap<int> map(g);
+	ListGraph::Node node = g.addNode();
+	map[node] = 12;	
+	return 0;
+}
+
Index: src/work/deba/map_base.h
===================================================================
--- src/work/deba/map_base.h	(revision 378)
+++ src/work/deba/map_base.h	(revision 378)
@@ -0,0 +1,132 @@
+#ifndef MAP_BASE_H
+#define MAP_BASE_H
+
+/**
+	Template base class for implementing mapping on nodes.
+	\param The first template parameter is the Graph class. The Graph
+		must have an \emp node_maps member with \emp MapRegistry class.
+	\param The second template parameter is the  type of the class.
+	
+*/
+
+
+namespace hugo {
+	template <typename G, typename K, typename KIt>
+	class MapBase;
+}
+
+#include "map_registry.h"
+
+namespace hugo {
+
+	template <typename G, typename K, typename KIt>
+	class MapBase {
+	public:
+		typedef G Graph;
+		typedef MapRegistry<G, K, KIt> Registry;
+		typedef K KeyType;
+		typedef KIt KeyIt;
+	
+		friend class Registry;
+		
+		/** 
+			Default constructor.
+		*/	
+		
+		MapBase() : registry(0) {}
+
+		/** 
+			Simple constructor to register into a graph registry.
+		*/
+	
+		MapBase(Registry& r) : registry(0) {
+			registry->add(*this);
+		}
+
+		/** 
+			Copy constructor with registering into the map.
+		*/	
+	
+		MapBase(const MapBase& copy) : registry(0) {
+			if (registry) {
+				registry->add(*this);
+			}
+		} 
+	
+		/** 
+			Assign operator.
+		*/	
+
+		const MapBase& operator=(const MapBase& copy) {
+			if (registry) {
+				registry->erase(*this);
+			}
+			registry = copy.registry;
+			if (registry) {
+				registry->add(*this);
+			}
+		}
+	
+
+		/** 
+			Destructor.
+		*/		
+
+		virtual ~MapBase() {
+			if (registry) {
+				registry->erase(*this);
+			}
+		}
+	
+	protected:
+		
+		Registry* registry;
+
+		int registry_index;
+	
+		/**
+			Helper function to implement the default constructor in the subclasses.
+		*/
+	
+		virtual void init(Graph& g) {
+
+			for (KeyIt it(g); g.valid(it); g.next(it)) {
+				add(it);
+			}
+		}
+	
+		/**
+			Helper function to implement the destructor in the subclasses.
+		*/
+	
+		virtual void destroy(Graph& g) {
+			for (KeyIt it(g); g.valid(it); g.next(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 KeyType&) = 0;
+	
+		/** 
+			The erase member function should be overloaded in the subclasses.
+			\e Erase removes the node from the map.
+		*/
+	
+		virtual void erase(const KeyType&) = 0;
+	
+		/**
+			Exception class to throw at unsupported operation.
+		*/
+	
+		class NotSupportedOperationException {};
+
+	};
+	
+}
+
+#endif
Index: src/work/deba/map_registry.h
===================================================================
--- src/work/deba/map_registry.h	(revision 378)
+++ src/work/deba/map_registry.h	(revision 378)
@@ -0,0 +1,94 @@
+#ifndef MAP_REGISTRY_H
+#define MAP_REGISTRY_H
+
+#include <vector>
+
+
+namespace hugo {
+	template <typename G, typename K, typename KIt>
+	class MapRegistry;
+}
+
+#include "map_base.h"
+
+namespace hugo {
+
+	template <typename G, typename K, typename KIt>
+	class MapRegistry {
+	public:
+		typedef G Graph;
+		typedef K Key;
+		typedef KIt KeyIt;
+	
+		typedef MapBase<Graph, Key, KIt> Map;
+		friend class Base;
+	
+	protected:
+	
+		typedef std::vector<Map*> Container; 
+	  Container container;
+
+		Graph* graph;		
+		
+		
+	public:
+	
+		MapRegistry(Graph& g) : container(0), graph(&g) {}
+				
+		~MapRegistry() {
+			typename Container::iterator it;
+			for (it = container.begin(); it != container.end(); ++it) {
+				(*it)->destroy(*graph);
+				(*it)->registry = 0;
+			}
+		}
+	
+	private:
+		MapRegistry(const MapRegistry& ) {}
+		MapRegistry& operator=(const MapRegistry& ) {}
+	
+	public:
+	
+		void add(Map& map) {
+			if (map.registry) {
+				map.registry->erase(map);
+			}
+			container.push_back(&map);
+			map.registry = this;
+			map.registry_index = container.size()-1;
+			map.init(*graph);
+		} 
+	
+		void erase(Map& map_base) {
+			map_base.destroy(*graph);
+			container.back()->registry_index = map_base.registry_index; 
+			container[map_base.registry_index] = container.back();
+			container.pop_back();
+			map_base.registry = 0;
+		}
+	
+		
+		void add(Key& key) {
+			typename Container::iterator it;
+			for (it = container.begin(); it != container.end(); ++it) {
+				(*it)->add(key);
+			}
+		}	
+		
+		void erase(Key& key) {
+			typename Container::iterator it;
+			for (it = container.begin(); it != container.end(); ++it) {
+				(*it)->erase(key);
+			}
+		}
+
+		Graph& getGraph() {
+			return *graph;
+		}
+
+
+	};
+
+}
+
+#endif
Index: c/work/deba/node_map_base.h
===================================================================
--- src/work/deba/node_map_base.h	(revision 377)
+++ 	(revision )
@@ -1,121 +1,0 @@
-#ifndef NODE_MAP_BASE_H
-#define NODE_MAP_BASE_H
-
-/**
-	Template base class for implementing mapping on nodes.
-	\param The first template parameter is the Graph class. The Graph
-		must have an \emp node_maps member with \emp NodeMapRegistry class.
-	\param The second template parameter is the Node type of the class.
-	
-*/
-
-template <typename G, typename K>
-class NodeMapBase {
-
-#include "node_map_registry.h"
-
-public:
-	typedef G Graph;
-	friend class NodeMapRegistry<G, K>;
-
-	typedef K KeyType;
-	
-	/** 
-		Default constructor.
-	*/	
-	
-	NodeMapBase() : graph(0) {}
-
-	/** 
-		Simple constructor to register into a graph.
-	*/
-	
-	NodeMapBase(Graph& g) : graph(&g) {
-		graph->node_maps.add(*this);
-	}
-
-	/** 
-		Copy constructor with registering into the map.
-	*/	
-	
-	NodeMapBase(const NodeMapBase& copy) : graph(copy.graph) {
-		if (graph) {
-			graph->node_maps.add(*this);
-		}
-	} 
-	
-	/** 
-		Assign operator.
-	*/	
-
-	const NodeMapBase& operator=(const NodeMapBase& copy) {
-		if (graph) {
-			graph.node_maps.erase(*this);
-		}
-		graph = copy.graph;
-		if (graph) {
-			graph->node_maps.add(*this);
-		}
-		
-	}
-	
-
-	/** 
-		Destructor.
-	*/	
-
-	virtual ~NodeMapBase() {
-		if (graph) {
-			graph->node_maps.erase(*this);
-		}
-	}
-	
-protected:
-	
-	Graph* graph;
-
-	int graph_index;
-	
-	/**
-		Helper function to implement the default constructor in the subclasses.
-	*/
-	
-	void init() {
-		for (typename Graph::NodeIt it(g); g.valid(it); g.next(it)) {
-			add(it);
-		}
-	}
-	
-	/**
-		Helper function to implement the destructor in the subclasses.
-	*/
-	
-	void destroy() {
-		for (typename Graph::NodeIt it(g); g.valid(it); g.next(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 KeyType&) = 0;
-	
-	/** 
-		The erase member function should be overloaded in the subclasses.
-		\e Erase removes the node from the map.
-	*/
-	
-	virtual void erase(const KeyType&) = 0;
-	
-	/**
-		Exception class to throw at unsupported operation.
-	*/
-	
-	class NotSupportedOperationException {};
-
-};
-
-#endif
Index: c/work/deba/node_map_registry.h
===================================================================
--- src/work/deba/node_map_registry.h	(revision 377)
+++ 	(revision )
@@ -1,65 +1,0 @@
-#ifndef NODE_MAP_REGISTRY_H
-#define NODE_MAP_REGISTRY_H
-
-#include <vector>
-
-template <typename G, typename K>
-class NodeMapRegistry;
-
-#include "node_map_base.h"
-
-template <typename G, typename K>
-class NodeMapRegistry {
-public:
-	typedef G Graph;
-	typedef K Node;
-	
-	typedef NodeMapBase<Graph, Node> MapBase;
-	friend class MapBase;
-
-protected:
-	
-	Graph* graph;
-
-	typedef std::vector<MapBase*> Container; 
-	
-	Container container;
-
-public:
-
-	NodeMapRegistry(Graph g) : graph(&g) {}
-
-	void add(MapBase& map_base) {
-		if (map_base.graph) {
-			map_base.graph->node_maps.erase(map_base);
-		}
-		container.push_back(&map_base);
-		map_base.graph = graph;
-		map_base.graph_index = container.size()-1;
-	} 
-	
-	void erase(MapBase& map_base) {
-		container.back()->graph_index = map_base.graph_index; 
-		container[map_base.graph_index] = container.back();
-		container.pop_back();
-		map_base.graph = 0;
-	}
-
-	
-	void add(Node& node) {
-		typename Container::iterator it;
-		for (it = container.begin(); it != container.end(); ++it) {
-			(*it)->add(node);
-		}
-	}
-	
-	void erase(Node& node) {
-		typename Container::iterator it;
-		for (it = container.begin(); it != container.end(); ++it) {
-			(*it)->erase(node);
-		}
-	}
-
-};
-
-#endif
Index: src/work/deba/test_graph.h
===================================================================
--- src/work/deba/test_graph.h	(revision 377)
+++ src/work/deba/test_graph.h	(revision 378)
@@ -8,8 +8,4 @@
 #include "invalid.h"
 
-#include "edge_map_registry.h"
-#include "node_map_registry.h"
-#include "edge_map_base.h"
-#include "node_map_base.h"
 #include "vector_map.h"
 
@@ -43,6 +39,9 @@
   private:
 
-		NodeMapRegistry<ListGraph, Node> node_maps(*this);
-		EdgeMapRegistry<ListGraph, Edge> edge_maps(*this);
+		typedef MapRegistry<ListGraph, Node, NodeIt> NodeMapRegistry;
+		NodeMapRegistry node_maps;
+		
+		typedef MapRegistry<ListGraph, Edge, EdgeIt> EdgeMapRegistry;
+		EdgeMapRegistry edge_maps;
  
 	public:
@@ -50,13 +49,14 @@
 
     template <typename T>
-    class NodeMap : public VectorMap<ListGraph, Node, T, NodeMapBase> {
+    class NodeMap : public VectorMap<ListGraph, Node, NodeIt, T> {
 		public:
-			NodeMap(ListGraph& g) : VectorMap<ListGraph, Node, T, NodeMapBase>(g) {}
+			NodeMap(ListGraph& g) : VectorMap<ListGraph, Node, NodeIt, T>(g.node_maps) {}
 		};
 		
-		EdgeMapRegistry<ListGraph, Edge> edge_maps;
-
     template <typename T>
-    class EdgeMap : public VectorMap<ListGraph, Edge, T, EdgeMapBase> {};
+    class EdgeMap : public VectorMap<ListGraph, Edge, EdgeIt, T> {
+		public:
+			EdgeMap(ListGraph& g) : VectorMap<ListGraph, Edge, EdgeIt, T>(g.edge_maps) {}
+		};
 
 
@@ -216,5 +216,6 @@
     /* default constructor */
 
-    ListGraph() : node_id(0), edge_id(0), _node_num(0), _edge_num(0), _first_node(0), _last_node(0) { }
+    ListGraph() : node_id(0), edge_id(0), _node_num(0), _edge_num(0), _first_node(0), _last_node(0),
+			edge_maps(*this), node_maps(*this) { }
     
     ~ListGraph() { 
Index: c/work/deba/vector_edge_map.h
===================================================================
--- src/work/deba/vector_edge_map.h	(revision 262)
+++ 	(revision )
@@ -1,29 +1,0 @@
-#ifndef VECTOR_EDGE_MAP_H
-#define VECTOR_EDGE_MAP_H
-
-#include <vector>
-
-#include "edge_map_base.h"
-
-template <typename G, typename E, typename V> 
-class VectorEdgeMap : public EdgeMapBase<G, E>{
-public:
-	typedef V ValueType;
-	
-	VectorEdgeMap(Graph& g) : EdgeMapBase<G, E>(g) {}
-	
-	void add(const E& edge) {
-		if (edge->id >= container.size()) {
-			container.resize(edge->id);
-		}
-	}
-	
-	void erase(const E&) {}
-
-private:
-	typedef vector<ValueType> Container;
-	
-	Container container;
-}
-
-#endif
Index: src/work/deba/vector_map.h
===================================================================
--- src/work/deba/vector_map.h	(revision 377)
+++ src/work/deba/vector_map.h	(revision 378)
@@ -3,48 +3,56 @@
 
 #include <vector>
+#include <iostream>
 
-template <typename G, typename K, typename V, template <typename, typename> class MapBase > 
-class VectorMap : public MapBase<G, K> {
-public:
-	typedef V ValueType;
+#include "map_base.h"
+
+namespace hugo {
+
+	template <typename G, typename K, typename KIt, typename V> 
+	class VectorMap : public MapBase<G, K, KIt> {
+	public:
+		typedef V ValueType;
 	
-	VectorMap() {}
-	VectorMap(G& g) : MapBase<G, K>(g) {
-		init();
-	}
+		VectorMap() {}
+		VectorMap(typename MapBase<G, K, KIt>::Registry& r) : MapBase<G, K, KIt>(r) {}
 	
-	~VectorMap() {
-//		destroy();
-	} 
 	
-	ValueType& operator[](const K& key) {
-		return container[key->id];
-	} 
+		ValueType& operator[](const K& key) {
+			int id = registry->getGraph().id(key);
+			return container[id];
+		} 
 	
-	const ValueType& operator[](const K& key) const {
-		return container[key->id];
-	}
+		const ValueType& operator[](const K& key) const {
+			int id = registry->getGraph().id(key);
+			return container[id];
+		}
 	
-	const ValueType& get(const K& key) const {
-		return container[key->id];
-	} 
+		const ValueType& get(const K& key) const {
+			int id = registry->getGraph().id(key);
+			return container[id];
+		} 
 	
-	void set(const K& key, const ValueType& val) {
-		container[key->id] = val;
-	}
+		void set(const K& key, const ValueType& val) {
+			int id = registry->getGraph().id(key);
+			container[id] = val;
+		}
 	
-	void add(const K& key) {
-		if (key->id() >= container.size()) {
-			container.resize(key->id() + 1);
+		void add(const K& key) {
+			int id = registry->getGraph().id(key);
+			std::cerr << id << std::endl;
+			if (id >= container.size()) {
+				container.resize(id + 1);
+			}
 		}
-	}
 	
-	void erase(const K& key) {}
+		void erase(const K& key) {}
 
-private:
-	typedef std::vector<ValueType> Container;
+	private:
+		typedef std::vector<ValueType> Container;
 	
-	Container container;
-};
+		Container container;
+	};
+
+}
 
 #endif
