# HG changeset patch
# User gyorokp
# Date 1269722063 -3600
# Node ID 4e27249fd00f82efa5a0d0c2380427e346fc3e4a
# Parent  941e63d323f17b503f4d85fc5ec8a9c476672e8a
Added planar_graph_test (Snapshot broken) (#363)

diff -r 941e63d323f1 -r 4e27249fd00f test/CMakeLists.txt
--- a/test/CMakeLists.txt	Sun Mar 21 18:41:52 2010 +0100
+++ b/test/CMakeLists.txt	Sat Mar 27 21:34:23 2010 +0100
@@ -35,6 +35,7 @@
   min_cost_flow_test
   min_mean_cycle_test
   path_test
+  planar_graph_test
   planarity_test
   preflow_test
   radix_sort_test
diff -r 941e63d323f1 -r 4e27249fd00f test/Makefile.am
--- a/test/Makefile.am	Sun Mar 21 18:41:52 2010 +0100
+++ b/test/Makefile.am	Sat Mar 27 21:34:23 2010 +0100
@@ -37,6 +37,7 @@
 	test/min_cost_flow_test \
 	test/min_mean_cycle_test \
 	test/path_test \
+	test/planar_graph_test \
 	test/planarity_test \
 	test/preflow_test \
 	test/radix_sort_test \
@@ -88,6 +89,7 @@
 test_min_cost_flow_test_SOURCES = test/min_cost_flow_test.cc
 test_min_mean_cycle_test_SOURCES = test/min_mean_cycle_test.cc
 test_path_test_SOURCES = test/path_test.cc
+test_planar_graph_test_SOURCES = test/digraph_test.cc
 test_planarity_test_SOURCES = test/planarity_test.cc
 test_preflow_test_SOURCES = test/preflow_test.cc
 test_radix_sort_test_SOURCES = test/radix_sort_test.cc
diff -r 941e63d323f1 -r 4e27249fd00f test/planar_graph_test.cc
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/planar_graph_test.cc	Sat Mar 27 21:34:23 2010 +0100
@@ -0,0 +1,332 @@
+/* -*- mode: C++; indent-tabs-mode: nil; -*-
+ *
+ * This file is a part of LEMON, a generic C++ optimization library.
+ *
+ * Copyright (C) 2003-2010
+ * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
+ * (Egervary Research Group on Combinatorial Optimization, EGRES).
+ *
+ * Permission to use, modify and distribute this software is granted
+ * provided that this copyright notice appears in all copies. For
+ * precise terms see the accompanying LICENSE file.
+ *
+ * This software is provided "AS IS" with no warranty of any kind,
+ * express or implied, and with no claim as to its suitability for any
+ * purpose.
+ *
+ */
+
+#include <lemon/concepts/graph.h>
+#include <lemon/planar_graph.h>
+
+#include "test_tools.h"
+#include "planar_graph_test.h"
+
+using namespace lemon;
+using namespace lemon::concepts;
+
+template <class Graph>
+void checkGraphBuild() {
+  TEMPLATE_GRAPH_TYPEDEFS(Graph);
+
+  Graph G;
+  checkGraphNodeList(G, 0);
+  checkGraphEdgeList(G, 0);
+  checkGraphArcList(G, 0);
+  checkGraphFaceList(G, 0);
+
+  G.reserveNode(3);
+  G.reserveEdge(3);
+
+  Node
+    n1 = G.addNode(),
+    n2 = G.addNode(),
+    n3 = G.addNode();
+  checkGraphNodeList(G, 3);
+  checkGraphEdgeList(G, 0);
+  checkGraphArcList(G, 0);
+  checkGraphFaceList(G, 3);
+
+  Edge e1 = G.addEdge(n1, n2, INVALID, INVALID);
+  check((G.u(e1) == n1 && G.v(e1) == n2) || (G.u(e1) == n2 && G.v(e1) == n1),
+        "Wrong edge");
+
+  checkGraphNodeList(G, 3);
+  checkGraphEdgeList(G, 1);
+  checkGraphArcList(G, 2);
+  checkGraphFaceList(G, 2);
+
+  checkGraphIncEdgeArcLists(G, n1, 1);
+  checkGraphIncEdgeArcLists(G, n2, 1);
+  checkGraphIncEdgeArcLists(G, n3, 0);
+
+  checkGraphConEdgeList(G, 1);
+  checkGraphConArcList(G, 2);
+
+  Edge e2 = G.addEdge(n2, n1, e1, e1),
+       e3 = G.addEdge(n2, n3, e1, INVALID);
+
+  checkGraphNodeList(G, 3);
+  checkGraphEdgeList(G, 3);
+  checkGraphArcList(G, 6);
+  checkGraphFaceList(G, 2);
+
+  checkGraphIncEdgeArcLists(G, n1, 2);
+  checkGraphIncEdgeArcLists(G, n2, 3);
+  checkGraphIncEdgeArcLists(G, n3, 1);
+
+  checkGraphConEdgeList(G, 3);
+  checkGraphConArcList(G, 6);
+
+  checkArcDirections(G);
+
+  checkNodeIds(G);
+  checkArcIds(G);
+  checkEdgeIds(G);
+  checkFaceIds(G);
+  checkGraphNodeMap(G);
+  checkGraphArcMap(G);
+  checkGraphFaceMap(G);
+}
+
+template <class Graph>
+void checkGraphArcSplit() {
+  TEMPLATE_GRAPH_TYPEDEFS(Graph);
+
+  Graph G;
+  Node n0 = G.addNode(),
+       n1 = G.addNode(),
+       n2 = G.addNode(),
+       n3 = G.addNode();
+  Edge a0 = G.addEdge(n0,n1,INVALID,INVALID),
+       a1 = G.addEdge(n0,n3,a0,INVALID),
+       a2 = G.addEdge(n0,n2,a0,INVALID),
+       a3 = G.addEdge(n1,n3,a0,a1),
+       a4 = G.addEdge(n3,n2,a1,a2);
+
+  checkGraphNodeList(G, 4);
+  checkGraphEdgeList(G, 5);
+  checkGraphArcList(G, 10);
+  checkGraphFaceList(G, 3);
+
+  G.split(a1);
+
+  checkGraphNodeList(G, 5);
+  checkGraphEdgeList(G, 6);
+  checkGraphArcList(G, 12);
+  checkGraphFaceList(G, 3);
+
+  checkGraphIncEdgeArcLists(G, n0, 3);
+  checkGraphIncEdgeArcLists(G, n1, 2);
+  checkGraphIncEdgeArcLists(G, n2, 2);
+  checkGraphIncEdgeArcLists(G, n3, 3);
+
+  checkGraphBoundaryArcList(G, G.leftFace(G.direct(a0,true)), 4);
+  checkGraphBoundaryArcList(G, G.leftFace(G.direct(a0,false)), 4);
+  checkGraphBoundaryArcList(G, G.leftFace(G.direct(a1,false)), 4);
+
+  checkGraphConEdgeList(G, 6);
+  checkGraphConArcList(G, 12);
+
+}
+
+template <class Graph>
+void checkGraphErase() {
+  TEMPLATE_GRAPH_TYPEDEFS(Graph);
+
+  Graph G;
+  Node n1 = G.addNode(),
+       n2 = G.addNode(),
+       n3 = G.addNode(),
+       n4 = G.addNode();
+  Edge e1 = G.addEdge(n1, n2, INVALID, INVALID),
+       e2 = G.addEdge(n2, n1, e1, e1),
+       e3 = G.addEdge(n2, n3, e1, INVALID),
+       e4 = G.addEdge(n1, n4, e2, INVALID),
+       e5 = G.addEdge(n4, n3, e4, e3);
+
+  // Check edge deletion
+  G.erase(e2);
+
+  checkGraphNodeList(G, 4);
+  checkGraphEdgeList(G, 4);
+  checkGraphArcList(G, 8);
+  checkGraphFaceList(G, 2);
+
+  checkGraphIncEdgeArcLists(G, n1, 2);
+  checkGraphIncEdgeArcLists(G, n2, 2);
+  checkGraphIncEdgeArcLists(G, n3, 2);
+  checkGraphIncEdgeArcLists(G, n4, 2);
+
+  checkGraphBoundaryArcList(G, G.leftFace(G.direct(e1,true)), 4);
+  checkGraphBoundaryArcList(G, G.leftFace(G.direct(e1,false)), 4);
+
+  checkGraphConEdgeList(G, 4);
+  checkGraphConArcList(G, 8);
+
+  // Check node deletion
+  G.erase(n3);
+
+  checkGraphNodeList(G, 3);
+  checkGraphEdgeList(G, 2);
+  checkGraphArcList(G, 4);
+  checkGraphFaceList(G, 1);
+
+  checkGraphIncEdgeArcLists(G, n1, 2);
+  checkGraphIncEdgeArcLists(G, n2, 1);
+  checkGraphIncEdgeArcLists(G, n4, 1);
+
+  checkGraphBoundaryArcList(G, G.leftFace(G.direct(e1,true)), 4);
+
+  checkGraphConEdgeList(G, 2);
+  checkGraphConArcList(G, 4);
+}
+
+
+template <class Graph>
+void checkGraphSnapshot() {
+  TEMPLATE_GRAPH_TYPEDEFS(Graph);
+
+  Graph G;
+  Node n1 = G.addNode(),
+       n2 = G.addNode(),
+       n3 = G.addNode();
+  Edge e1 = G.addEdge(n1, n2, INVALID, INVALID),
+       e2 = G.addEdge(n2, n1, e1, e1),
+       e3 = G.addEdge(n2, n3, e1, INVALID);
+
+  checkGraphNodeList(G, 3);
+  checkGraphEdgeList(G, 3);
+  checkGraphArcList(G, 6);
+  checkGraphFaceList(G, 2);
+
+  typename Graph::Snapshot snapshot(G);
+
+  Node n = G.addNode();
+  Edge ea4 = G.addEdge(n3, n, e3, INVALID),
+       ea5 = G.addEdge(n, n3, ea4, ea4),
+       ea6 = G.addEdge(n3, n2, ea5, e3);
+
+  checkGraphNodeList(G, 4);
+  checkGraphEdgeList(G, 6);
+  checkGraphArcList(G, 12);
+  checkGraphFaceList(G, 4);
+
+  snapshot.restore();
+
+  checkGraphNodeList(G, 3);
+  checkGraphEdgeList(G, 3);
+  checkGraphArcList(G, 6);
+  checkGraphFaceList(G, 2);
+
+  checkGraphIncEdgeArcLists(G, n1, 2);
+  checkGraphIncEdgeArcLists(G, n2, 3);
+  checkGraphIncEdgeArcLists(G, n3, 1);
+  checkGraphBoundaryArcList(G, G.leftFace(G.direct(e1,true)), 2);
+  checkGraphBoundaryArcList(G, G.leftFace(G.direct(e1,false)), 4);
+
+  checkGraphConEdgeList(G, 3);
+  checkGraphConArcList(G, 6);
+
+  checkNodeIds(G);
+  checkEdgeIds(G);
+  checkArcIds(G);
+  checkFaceIds(G);
+  checkGraphNodeMap(G);
+  checkGraphEdgeMap(G);
+  checkGraphArcMap(G);
+  checkGraphFaceMap(G);
+
+  G.addNode();
+  snapshot.save(G);
+
+  G.addEdge(G.addNode(), G.addNode(), INVALID, INVALID);
+
+  snapshot.restore();
+  snapshot.save(G);
+
+  checkGraphNodeList(G, 4);
+  checkGraphEdgeList(G, 3);
+  checkGraphArcList(G, 6);
+  checkGraphFaceList(G, 3);
+
+  G.addEdge(G.addNode(), G.addNode(), INVALID, INVALID);
+
+  snapshot.restore();
+
+  checkGraphNodeList(G, 4);
+  checkGraphEdgeList(G, 3);
+  checkGraphArcList(G, 6);
+  checkGraphFaceList(G, 3);
+}
+
+template <typename Graph>
+void checkGraphValidity() {
+  TEMPLATE_GRAPH_TYPEDEFS(Graph);
+  Graph g;
+
+  Node
+    n1 = g.addNode(),
+    n2 = g.addNode(),
+    n3 = g.addNode();
+
+  Edge
+    e1 = g.addEdge(n1, n2, INVALID, INVALID),
+    e2 = g.addEdge(n2, n3, e1, INVALID);
+
+  check(g.valid(n1), "Wrong validity check");
+  check(g.valid(e1), "Wrong validity check");
+  check(g.valid(g.direct(e1, true)), "Wrong validity check");
+
+  check(!g.valid(g.nodeFromId(-1)), "Wrong validity check");
+  check(!g.valid(g.edgeFromId(-1)), "Wrong validity check");
+  check(!g.valid(g.arcFromId(-1)), "Wrong validity check");
+  check(!g.valid(g.faceFromId(-1)), "Wrong validity check");
+}
+
+template <typename Graph>
+void checkGraphValidityErase() {
+  TEMPLATE_GRAPH_TYPEDEFS(Graph);
+  Graph g;
+
+  Node
+    n1 = g.addNode(),
+    n2 = g.addNode(),
+    n3 = g.addNode();
+
+  Edge
+    e1 = g.addEdge(n1, n2, INVALID, INVALID),
+    e2 = g.addEdge(n2, n3, e1, INVALID);
+
+  check(g.valid(n1), "Wrong validity check");
+  check(g.valid(e1), "Wrong validity check");
+  check(g.valid(g.direct(e1, true)), "Wrong validity check");
+
+  g.erase(n1);
+
+  check(!g.valid(n1), "Wrong validity check");
+  check(g.valid(n2), "Wrong validity check");
+  check(g.valid(n3), "Wrong validity check");
+  check(!g.valid(e1), "Wrong validity check");
+  check(g.valid(e2), "Wrong validity check");
+
+  check(!g.valid(g.nodeFromId(-1)), "Wrong validity check");
+  check(!g.valid(g.edgeFromId(-1)), "Wrong validity check");
+  check(!g.valid(g.arcFromId(-1)), "Wrong validity check");
+  check(!g.valid(g.faceFromId(-1)), "Wrong validity check");
+}
+
+void checkGraphs() {
+  { // Checking PlanarGraph
+    checkGraphBuild<PlanarGraph>();
+    checkGraphArcSplit<PlanarGraph>();
+    checkGraphErase<PlanarGraph>();
+    checkGraphSnapshot<PlanarGraph>();
+    checkGraphValidityErase<PlanarGraph>();
+  }
+}
+
+int main() {
+  checkGraphs();
+  return 0;
+}
diff -r 941e63d323f1 -r 4e27249fd00f test/planar_graph_test.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/planar_graph_test.h	Sat Mar 27 21:34:23 2010 +0100
@@ -0,0 +1,365 @@
+/* -*- mode: C++; indent-tabs-mode: nil; -*-
+ *
+ * This file is a part of LEMON, a generic C++ optimization library.
+ *
+ * Copyright (C) 2003-2009
+ * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
+ * (Egervary Research Group on Combinatorial Optimization, EGRES).
+ *
+ * Permission to use, modify and distribute this software is granted
+ * provided that this copyright notice appears in all copies. For
+ * precise terms see the accompanying LICENSE file.
+ *
+ * This software is provided "AS IS" with no warranty of any kind,
+ * express or implied, and with no claim as to its suitability for any
+ * purpose.
+ *
+ */
+
+#ifndef LEMON_TEST_GRAPH_TEST_H
+#define LEMON_TEST_GRAPH_TEST_H
+
+#include <set>
+
+#include <lemon/core.h>
+#include <lemon/maps.h>
+
+#include "test_tools.h"
+
+namespace lemon {
+
+  template<class Graph>
+  void checkGraphNodeList(const Graph &G, int cnt)
+  {
+    typename Graph::NodeIt n(G);
+    for(int i=0;i<cnt;i++) {
+      check(n!=INVALID,"Wrong Node list linking.");
+      ++n;
+    }
+    check(n==INVALID,"Wrong Node list linking.");
+    check(countNodes(G)==cnt,"Wrong Node number.");
+  }
+
+  template<class Graph>
+  void checkGraphFaceList(const Graph &G, int cnt)
+  {
+    typename Graph::FaceIt n(G);
+    for(int i=0;i<cnt;i++) {
+      check(n!=INVALID,"Wrong Face list linking.");
+      ++n;
+    }
+    check(n==INVALID,"Wrong Face list linking.");
+    check(countFaces(G)==cnt,"Wrong Face number.");
+  }
+
+  template<class Graph>
+  void checkGraphArcList(const Graph &G, int cnt)
+  {
+    typename Graph::ArcIt e(G);
+    for(int i=0;i<cnt;i++) {
+      check(e!=INVALID,"Wrong Arc list linking.");
+      check(G.oppositeNode(G.source(e), e) == G.target(e),
+            "Wrong opposite node");
+      check(G.oppositeNode(G.target(e), e) == G.source(e),
+            "Wrong opposite node");
+      ++e;
+    }
+    check(e==INVALID,"Wrong Arc list linking.");
+    check(countArcs(G)==cnt,"Wrong Arc number.");
+  }
+
+  template<class Graph>
+  void checkGraphOutArcList(const Graph &G, typename Graph::Node n, int cnt)
+  {
+    typename Graph::OutArcIt e(G,n);
+    for(int i=0;i<cnt;i++) {
+      check(e!=INVALID,"Wrong OutArc list linking.");
+      check(n==G.source(e),"Wrong OutArc list linking.");
+      check(n==G.baseNode(e),"Wrong OutArc list linking.");
+      check(G.target(e)==G.runningNode(e),"Wrong OutArc list linking.");
+      ++e;
+    }
+    check(e==INVALID,"Wrong OutArc list linking.");
+    check(countOutArcs(G,n)==cnt,"Wrong OutArc number.");
+  }
+
+  template<class Graph>
+  void checkGraphInArcList(const Graph &G, typename Graph::Node n, int cnt)
+  {
+    typename Graph::InArcIt e(G,n);
+    for(int i=0;i<cnt;i++) {
+      check(e!=INVALID,"Wrong InArc list linking.");
+      check(n==G.target(e),"Wrong InArc list linking.");
+      check(n==G.baseNode(e),"Wrong OutArc list linking.");
+      check(G.source(e)==G.runningNode(e),"Wrong OutArc list linking.");
+      ++e;
+    }
+    check(e==INVALID,"Wrong InArc list linking.");
+    check(countInArcs(G,n)==cnt,"Wrong InArc number.");
+  }
+
+  template<class Graph>
+  void checkGraphEdgeList(const Graph &G, int cnt)
+  {
+    typename Graph::EdgeIt e(G);
+    for(int i=0;i<cnt;i++) {
+      check(e!=INVALID,"Wrong Edge list linking.");
+      check(G.oppositeNode(G.u(e), e) == G.v(e), "Wrong opposite node");
+      check(G.oppositeNode(G.v(e), e) == G.u(e), "Wrong opposite node");
+      ++e;
+    }
+    check(e==INVALID,"Wrong Edge list linking.");
+    check(countEdges(G)==cnt,"Wrong Edge number.");
+  }
+
+  template<class Graph>
+  void checkGraphIncEdgeList(const Graph &G, typename Graph::Node n, int cnt)
+  {
+    typename Graph::IncEdgeIt e(G,n);
+    for(int i=0;i<cnt;i++) {
+      check(e!=INVALID,"Wrong IncEdge list linking.");
+      check(n==G.u(e) || n==G.v(e),"Wrong IncEdge list linking.");
+      check(n==G.baseNode(e),"Wrong OutArc list linking.");
+      check(G.u(e)==G.runningNode(e) || G.v(e)==G.runningNode(e),
+            "Wrong OutArc list linking.");
+      ++e;
+    }
+    check(e==INVALID,"Wrong IncEdge list linking.");
+    check(countIncEdges(G,n)==cnt,"Wrong IncEdge number.");
+  }
+
+  template <class Graph>
+  void checkGraphIncEdgeArcLists(const Graph &G, typename Graph::Node n,
+                                 int cnt)
+  {
+    checkGraphIncEdgeList(G, n, cnt);
+    checkGraphOutArcList(G, n, cnt);
+    checkGraphInArcList(G, n, cnt);
+  }
+
+  template<class Graph>
+  void checkGraphBoundaryArcList(const Graph &G, typename Graph::Face n, int
+    cnt)
+  {
+//    std::cout << G.id(n) << ' ';
+//    int alma = countBoundaryArcs(G,n);
+//    std::cout << alma << ':';
+    typename Graph::CwBoundaryArcIt e(G,n);
+    for(int i=0;i<cnt;i++) {
+//      std::cout << ',' << G.id(e);
+      check(e!=INVALID,"Wrong CwBoundaryArc list linking.");
+      check(n==G.w1(e) || n==G.w2(e),"Wrong CwBoundaryArc list linking.");
+      ++e;
+    }
+//    std::cout << std::endl;
+    check(e==INVALID,"Wrong BoundaryArc list linking.");
+    check(countBoundaryArcs(G,n)==cnt,"Wrong IncEdge number.");
+  }
+
+  template <class Graph>
+  void checkGraphConArcList(const Graph &G, int cnt) {
+    int i = 0;
+    for (typename Graph::NodeIt u(G); u != INVALID; ++u) {
+      for (typename Graph::NodeIt v(G); v != INVALID; ++v) {
+        for (ConArcIt<Graph> a(G, u, v); a != INVALID; ++a) {
+          check(G.source(a) == u, "Wrong iterator.");
+          check(G.target(a) == v, "Wrong iterator.");
+          ++i;
+        }
+      }
+    }
+    check(cnt == i, "Wrong iterator.");
+  }
+
+  template <class Graph>
+  void checkGraphConEdgeList(const Graph &G, int cnt) {
+    int i = 0;
+    for (typename Graph::NodeIt u(G); u != INVALID; ++u) {
+      for (typename Graph::NodeIt v(G); v != INVALID; ++v) {
+        for (ConEdgeIt<Graph> e(G, u, v); e != INVALID; ++e) {
+          check((G.u(e) == u && G.v(e) == v) ||
+                (G.u(e) == v && G.v(e) == u), "Wrong iterator.");
+          i += u == v ? 2 : 1;
+        }
+      }
+    }
+    check(2 * cnt == i, "Wrong iterator.");
+  }
+
+  template <typename Graph>
+  void checkArcDirections(const Graph& G) {
+    for (typename Graph::ArcIt a(G); a != INVALID; ++a) {
+      check(G.source(a) == G.target(G.oppositeArc(a)), "Wrong direction");
+      check(G.target(a) == G.source(G.oppositeArc(a)), "Wrong direction");
+      check(G.direct(a, G.direction(a)) == a, "Wrong direction");
+    }
+  }
+
+  template <typename Graph>
+  void checkNodeIds(const Graph& G) {
+    std::set<int> values;
+    for (typename Graph::NodeIt n(G); n != INVALID; ++n) {
+      check(G.nodeFromId(G.id(n)) == n, "Wrong id");
+      check(values.find(G.id(n)) == values.end(), "Wrong id");
+      check(G.id(n) <= G.maxNodeId(), "Wrong maximum id");
+      values.insert(G.id(n));
+    }
+  }
+
+  template <typename Graph>
+  void checkArcIds(const Graph& G) {
+    std::set<int> values;
+    for (typename Graph::ArcIt a(G); a != INVALID; ++a) {
+      check(G.arcFromId(G.id(a)) == a, "Wrong id");
+      check(values.find(G.id(a)) == values.end(), "Wrong id");
+      check(G.id(a) <= G.maxArcId(), "Wrong maximum id");
+      values.insert(G.id(a));
+    }
+  }
+
+  template <typename Graph>
+  void checkEdgeIds(const Graph& G) {
+    std::set<int> values;
+    for (typename Graph::EdgeIt e(G); e != INVALID; ++e) {
+      check(G.edgeFromId(G.id(e)) == e, "Wrong id");
+      check(values.find(G.id(e)) == values.end(), "Wrong id");
+      check(G.id(e) <= G.maxEdgeId(), "Wrong maximum id");
+      values.insert(G.id(e));
+    }
+  }
+
+  template <typename Graph>
+  void checkFaceIds(const Graph& G) {
+    std::set<int> values;
+    for (typename Graph::FaceIt n(G); n != INVALID; ++n) {
+      check(G.faceFromId(G.id(n)) == n, "Wrong id");
+      check(values.find(G.id(n)) == values.end(), "Wrong id");
+      check(G.id(n) <= G.maxFaceId(), "Wrong maximum id");
+      values.insert(G.id(n));
+    }
+  }
+
+  template <typename Graph>
+  void checkGraphNodeMap(const Graph& G) {
+    typedef typename Graph::Node Node;
+    typedef typename Graph::NodeIt NodeIt;
+
+    typedef typename Graph::template NodeMap<int> IntNodeMap;
+    IntNodeMap map(G, 42);
+    for (NodeIt it(G); it != INVALID; ++it) {
+      check(map[it] == 42, "Wrong map constructor.");
+    }
+    int s = 0;
+    for (NodeIt it(G); it != INVALID; ++it) {
+      map[it] = 0;
+      check(map[it] == 0, "Wrong operator[].");
+      map.set(it, s);
+      check(map[it] == s, "Wrong set.");
+      ++s;
+    }
+    s = s * (s - 1) / 2;
+    for (NodeIt it(G); it != INVALID; ++it) {
+      s -= map[it];
+    }
+    check(s == 0, "Wrong sum.");
+
+    // map = constMap<Node>(12);
+    // for (NodeIt it(G); it != INVALID; ++it) {
+    //   check(map[it] == 12, "Wrong operator[].");
+    // }
+  }
+
+  template <typename Graph>
+  void checkGraphArcMap(const Graph& G) {
+    typedef typename Graph::Arc Arc;
+    typedef typename Graph::ArcIt ArcIt;
+
+    typedef typename Graph::template ArcMap<int> IntArcMap;
+    IntArcMap map(G, 42);
+    for (ArcIt it(G); it != INVALID; ++it) {
+      check(map[it] == 42, "Wrong map constructor.");
+    }
+    int s = 0;
+    for (ArcIt it(G); it != INVALID; ++it) {
+      map[it] = 0;
+      check(map[it] == 0, "Wrong operator[].");
+      map.set(it, s);
+      check(map[it] == s, "Wrong set.");
+      ++s;
+    }
+    s = s * (s - 1) / 2;
+    for (ArcIt it(G); it != INVALID; ++it) {
+      s -= map[it];
+    }
+    check(s == 0, "Wrong sum.");
+
+    // map = constMap<Arc>(12);
+    // for (ArcIt it(G); it != INVALID; ++it) {
+    //   check(map[it] == 12, "Wrong operator[].");
+    // }
+  }
+
+  template <typename Graph>
+  void checkGraphEdgeMap(const Graph& G) {
+    typedef typename Graph::Edge Edge;
+    typedef typename Graph::EdgeIt EdgeIt;
+
+    typedef typename Graph::template EdgeMap<int> IntEdgeMap;
+    IntEdgeMap map(G, 42);
+    for (EdgeIt it(G); it != INVALID; ++it) {
+      check(map[it] == 42, "Wrong map constructor.");
+    }
+    int s = 0;
+    for (EdgeIt it(G); it != INVALID; ++it) {
+      map[it] = 0;
+      check(map[it] == 0, "Wrong operator[].");
+      map.set(it, s);
+      check(map[it] == s, "Wrong set.");
+      ++s;
+    }
+    s = s * (s - 1) / 2;
+    for (EdgeIt it(G); it != INVALID; ++it) {
+      s -= map[it];
+    }
+    check(s == 0, "Wrong sum.");
+
+    // map = constMap<Edge>(12);
+    // for (EdgeIt it(G); it != INVALID; ++it) {
+    //   check(map[it] == 12, "Wrong operator[].");
+    // }
+  }
+
+
+  template <typename Graph>
+  void checkGraphFaceMap(const Graph& G) {
+    typedef typename Graph::Face Face;
+    typedef typename Graph::FaceIt FaceIt;
+
+    typedef typename Graph::template FaceMap<int> IntFaceMap;
+    IntFaceMap map(G, 42);
+    for (FaceIt it(G); it != INVALID; ++it) {
+      check(map[it] == 42, "Wrong map constructor.");
+    }
+    int s = 0;
+    for (FaceIt it(G); it != INVALID; ++it) {
+      map[it] = 0;
+      check(map[it] == 0, "Wrong operator[].");
+      map.set(it, s);
+      check(map[it] == s, "Wrong set.");
+      ++s;
+    }
+    s = s * (s - 1) / 2;
+    for (FaceIt it(G); it != INVALID; ++it) {
+      s -= map[it];
+    }
+    check(s == 0, "Wrong sum.");
+
+    // map = constMap<Node>(12);
+    // for (NodeIt it(G); it != INVALID; ++it) {
+    //   check(map[it] == 12, "Wrong operator[].");
+    // }
+  }
+
+} //namespace lemon
+
+#endif
