Index: src/work/deba/edge_map_base.h
===================================================================
--- src/work/deba/edge_map_base.h	(revision 340)
+++ src/work/deba/edge_map_base.h	(revision 377)
@@ -12,6 +12,10 @@
 template <typename G, typename K>
 class EdgeMapBase {
+
+#include "edge_map_registry.h"
+
 public:
 	typedef G Graph;
+	friend class EdgeMapRegistry<G, K>;
 
 	typedef K KeyType;
@@ -78,5 +82,5 @@
 	
 	void init() {
-		for (Graph::EdgeIt it(g); g.valid(it); g.next(it)) {
+		for (typename Graph::EdgeIt it(g); g.valid(it); g.next(it)) {
 			add(it);
 		}
@@ -88,5 +92,5 @@
 	
 	void destroy() {
-		for (Graph::EdgeIt it(g); g.valid(it); g.next(it)) {
+		for (typename Graph::EdgeIt it(g); g.valid(it); g.next(it)) {
 			erase(it);
 		}
@@ -113,5 +117,4 @@
 	class NotSupportedOperationException {};
 
-	friend class Graph;
 };
 
Index: src/work/deba/edge_map_register.h
===================================================================
--- src/work/deba/edge_map_register.h	(revision 262)
+++ 	(revision )
@@ -1,52 +1,0 @@
-#ifndef EDGE_MAP_REGISTER_H
-#define EDGE_MAP_REGISTER_H
-
-#include <vector>
-
-template <typename G, typename E>
-class EdgeMapRegister {
-public:
-	typedef G Graph;
-	typedef E Edge
-	
-	typedef EdgeMapBase<Graph, Edge> EdgeMapBase;
-
-protected:
-	typedef std::vector<EdgeMapBase*> Container; 
-	
-	Container container;
-	
-	void add(EdgeMapBase& map_base) {
-		if (map_base.graph) {
-			map_base.graph->edge_maps.erase(map_base);
-		}
-		container.push_back(&map_base);
-		map_base.graph_index = container.size()-1;
-	} 
-	
-	void erase(EdgeMapBase& map_base) {
-		if (map_base.graph != this) return;
-		container.back()->graph_index = map_base.graph_index; 
-		container[map_base.graph_index] = container.back();
-		container.pop_back();
-		map_base.graph = 0;
-	}
-	
-	void addEdge(Edge& edge) {
-		typename Container::iterator it;
-		for (it = container.begin(); it != container.end(); ++it) {
-			(*it)->add(edge);
-		}
-	}
-	
-	void eraseEdge(Edge& edge) {
-		typename Container::iterator it;
-		for (it = container.begin(); it != container.end(); ++it) {
-			(*it)->erase(edge);
-		}
-	}
-
-	friend class EdgeMapBase;
-};
-
-#endif
Index: src/work/deba/edge_map_registry.h
===================================================================
--- src/work/deba/edge_map_registry.h	(revision 340)
+++ src/work/deba/edge_map_registry.h	(revision 377)
@@ -4,19 +4,30 @@
 #include <vector>
 
+template <typename G, typename K>
+class EdgeMapRegistry;
+
 #include "edge_map_base.h"
 
-template <typename G, typename E>
+template <typename G, typename K>
 class EdgeMapRegistry {
 public:
 	typedef G Graph;
-	typedef E Edge
+	typedef K Edge;
 	
 	typedef EdgeMapBase<Graph, Edge> MapBase;
+	friend class MapBase;
 
 protected:
-	typedef std::vector<EdgeMapBase*> Container; 
+	
+	Graph* graph;
+
+	typedef std::vector<MapBase*> Container; 
 	
 	Container container;
-	
+
+public:
+
+	EdgeMapRegistry(Graph g) : graph(&g) {}
+
 	void add(MapBase& map_base) {
 		if (map_base.graph) {
@@ -24,10 +35,9 @@
 		}
 		container.push_back(&map_base);
-		map_base.graph = this;
+		map_base.graph = graph;
 		map_base.graph_index = container.size()-1;
 	} 
 	
 	void erase(MapBase& map_base) {
-		if (map_base.graph != this) return;
 		container.back()->graph_index = map_base.graph_index; 
 		container[map_base.graph_index] = container.back();
@@ -35,4 +45,5 @@
 		map_base.graph = 0;
 	}
+
 	
 	void add(Edge& edge) {
@@ -50,5 +61,4 @@
 	}
 
-	friend class MapBase;
 };
 
Index: src/work/deba/mapbase.h
===================================================================
--- src/work/deba/mapbase.h	(revision 261)
+++ 	(revision )
@@ -1,31 +1,0 @@
-#ifndef MAPBASE_H
-#define MAPBASE_H
-
-template <class GB, class K>
-class MapBase {
-public:
-	typedef GB GraphBase;
-	typedef MappedGraph<GraphBase> Graph;
-
-	typedef K KeyType;
-	
-
-	MapBase() : graph(0) {}
-	MapBase(Graph& g) : graph(&g) {graph.add(*this);}
-
-	virtual ~MapBase() {graph.erase(*this);}	
-
-protected:
-	
-	Graph* graph;
-
-	int graph_index;
-	
-	
-	virtual void add(const KeyType&) = 0;
-	virtual void erase(const KeyType&) = 0;
-
-	friend class Graph;
-};
-
-#endif
Index: src/work/deba/mappedgraph.h
===================================================================
--- src/work/deba/mappedgraph.h	(revision 261)
+++ 	(revision )
@@ -1,88 +1,0 @@
-#ifndef MAPPEDGRAPH_H
-#define MAPPEDGRAPH_H
-
-#include <vector>
-
-template <typename GB, typename K>
-class MapBase;
-
-template <typename GB>
-class MappedGraph : public GB {
-public:
-	typedef GB GraphBase;
-	
-	typedef MapBase<GB, typename GB::Edge> EdgeMapBase;
-	typedef MapBase<GB, typename GB::Node> NodeMapBase;
-
-protected:
-	typedef std::vector<EdgeMapBase*> EdgeMaps; 
-	typedef std::vector<NodeMapBase*> NodeMaps;
-	
-	EdgeMaps edge_maps;
-	NodeMaps node_maps;
-	
-	void add(EdgeMapBase& map_base) {
-		if (map_base.graph) {
-			map_base.graph->erase(map_base);
-		}
-		edge_maps.push_back(&map_base);
-		map_base.graph_index = map_base.size()-1;
-	} 
-	
-	void erase(EdgeMapBase& map_base) {
-		if (map_base.graph != this) return;
-		edge_maps.back()->graph_index = map_base.graph_index; 
-		edge_maps[map_base.graph_index] = edge_maps.back();
-		edge_maps.pop_back();
-		map_base.graph = 0;
-	}
-	
-	void addEdge(typename GB::Edge& edge) {
-		typename EdgeMaps::iterator it;
-		for (it = edge_maps.begin(); it != edge_maps.end(); ++it) {
-			(*it)->add(edge);
-		}
-	}
-	
-	void eraseEdge(typename GB::Edge& edge) {
-		typename EdgeMaps::iterator it;
-		for (it = edge_maps.begin(); it != edge_maps.end(); ++it) {
-			(*it)->erase(edge);
-		}
-	}
-
-	void add(NodeMapBase& map_base) {
-		if (map_base.graph) {
-			map_base.graph->erase(map_base);
-		}
-		node_maps.push_back(&map_base);
-		map_base.graph_index = node_maps.size()-1;
-	} 
-	
-	void erase(NodeMapBase& map_base) {
-		if (map_base.graph != this) return;
-		node_maps.back()->graph_index = map_base.graph_index; 
-		node_maps[map_base.graph_index] = node_maps.back();
-		node_maps.pop_back();
-		map_base.graph = 0;
-	}
-
-	void addNode(typename GB::Node& node) {
-		typename NodeMaps::iterator it;
-		for (it = node_maps.begin(); it != node_maps.end(); ++it) {
-			(*it)->add(node);
-		}
-	}
-	
-	void eraseNode(typename GB::Node& node) {
-		typename NodeMaps::iterator it;
-		for (it = node_maps.begin(); it != node_maps.end(); ++it) {
-			(*it)->erase(node);
-		}
-	}
-	
-	friend class EdgeMapBase;
-	friend class NodeMapBase;
-};
-
-#endif
Index: src/work/deba/node_map_base.h
===================================================================
--- src/work/deba/node_map_base.h	(revision 340)
+++ src/work/deba/node_map_base.h	(revision 377)
@@ -12,6 +12,10 @@
 template <typename G, typename K>
 class NodeMapBase {
+
+#include "node_map_registry.h"
+
 public:
 	typedef G Graph;
+	friend class NodeMapRegistry<G, K>;
 
 	typedef K KeyType;
@@ -63,5 +67,5 @@
 	virtual ~NodeMapBase() {
 		if (graph) {
-			graph.node_maps.erase(*this);
+			graph->node_maps.erase(*this);
 		}
 	}
@@ -78,5 +82,5 @@
 	
 	void init() {
-		for (Graph::NodeIt it(g); g.valid(it); g.next(it)) {
+		for (typename Graph::NodeIt it(g); g.valid(it); g.next(it)) {
 			add(it);
 		}
@@ -88,5 +92,5 @@
 	
 	void destroy() {
-		for (Graph::NodeIt it(g); g.valid(it); g.next(it)) {
+		for (typename Graph::NodeIt it(g); g.valid(it); g.next(it)) {
 			erase(it);
 		}
@@ -113,5 +117,4 @@
 	class NotSupportedOperationException {};
 
-	friend class Graph;
 };
 
Index: src/work/deba/node_map_registry.h
===================================================================
--- src/work/deba/node_map_registry.h	(revision 340)
+++ src/work/deba/node_map_registry.h	(revision 377)
@@ -4,30 +4,40 @@
 #include <vector>
 
+template <typename G, typename K>
+class NodeMapRegistry;
+
 #include "node_map_base.h"
 
-template <typename G, typename E>
+template <typename G, typename K>
 class NodeMapRegistry {
 public:
 	typedef G Graph;
-	typedef E Node
+	typedef K Node;
 	
-	typedef NodeMapBase<Graph, Node> NodeMapBase;
+	typedef NodeMapBase<Graph, Node> MapBase;
+	friend class MapBase;
 
 protected:
-	typedef std::vector<NodeMapBase*> Container; 
+	
+	Graph* graph;
+
+	typedef std::vector<MapBase*> Container; 
 	
 	Container container;
-	
-	void add(NodeMapBase& map_base) {
+
+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 = this;
+		map_base.graph = graph;
 		map_base.graph_index = container.size()-1;
 	} 
 	
-	void erase(NodeMapBase& map_base) {
-		if (map_base.graph != this) return;
+	void erase(MapBase& map_base) {
 		container.back()->graph_index = map_base.graph_index; 
 		container[map_base.graph_index] = container.back();
@@ -35,4 +45,5 @@
 		map_base.graph = 0;
 	}
+
 	
 	void add(Node& node) {
@@ -50,5 +61,4 @@
 	}
 
-	friend class NodeMapBase;
 };
 
Index: src/work/deba/slowgraph.h
===================================================================
--- src/work/deba/slowgraph.h	(revision 261)
+++ 	(revision )
@@ -1,17 +1,0 @@
-#ifndef SLOWGRAPH_H
-#define SLOWGRAPH_H
-
-class SlowGraphBase {
-private:
-	typedef vector<int> EdgeVector;
-  typedef vector<EdgeVector> NodeVector;
-	
-  NodeVector in_nodes, out_nodes;
-
-public:
-	typedef Edge
-};
-
-typedef MappedGraph<SlowGraphBase> SlowGraph;
-
-#endif
Index: src/work/deba/test_graph.h
===================================================================
--- src/work/deba/test_graph.h	(revision 340)
+++ src/work/deba/test_graph.h	(revision 377)
@@ -6,11 +6,11 @@
 #include <vector>
 
-#include <invalid.h>
-
-#include "vector_map.h"
+#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"
 
 namespace hugo {
@@ -41,13 +41,22 @@
  //   template <typename T> friend class EdgeMap;
  
-		NodeMapRegistry<ListGraph, Node> node_maps;
+  private:
+
+		NodeMapRegistry<ListGraph, Node> node_maps(*this);
+		EdgeMapRegistry<ListGraph, Edge> edge_maps(*this);
+ 
+	public:
+ 
 
     template <typename T>
-    class NodeMap : public VectorMap<ListGraph, Edge, T, EdgeMapBase> {};
+    class NodeMap : public VectorMap<ListGraph, Node, T, NodeMapBase> {
+		public:
+			NodeMap(ListGraph& g) : VectorMap<ListGraph, Node, T, NodeMapBase>(g) {}
+		};
 		
 		EdgeMapRegistry<ListGraph, Edge> edge_maps;
 
     template <typename T>
-    class EdgeMap : public VectorMap<Graph, Node, T, NodeMapBase> {};
+    class EdgeMap : public VectorMap<ListGraph, Edge, T, EdgeMapBase> {};
 
 
@@ -311,5 +320,5 @@
 
     void erase(Node i) { 
-			node_map.erase(i);
+			node_maps.erase(i);
       while (first<OutEdgeIt>(i).valid()) erase(first<OutEdgeIt>(i));
       while (first<InEdgeIt>(i).valid()) erase(first<InEdgeIt>(i));
Index: src/work/deba/vector_map.h
===================================================================
--- src/work/deba/vector_map.h	(revision 340)
+++ src/work/deba/vector_map.h	(revision 377)
@@ -35,5 +35,7 @@
 	
 	void add(const K& key) {
-		container.resize(key->id);
+		if (key->id() >= container.size()) {
+			container.resize(key->id() + 1);
+		}
 	}
 	
@@ -44,5 +46,5 @@
 	
 	Container container;
-}
+};
 
 #endif
