# HG changeset patch
# User Peter Gyorok
# Date 1285418159 -7200
# Node ID 2c0edf00dc8ff8bdf85187c590b17d2a355b2d03
# Parent  10d57978f9003ad2839583e71265b72b30b884b1
PlanarGraph and PlaneGraph related fixes (#363)

diff -r 10d57978f900 -r 2c0edf00dc8f lemon/graph_to_eps.h
--- a/lemon/graph_to_eps.h	Mon Jun 07 20:57:51 2010 +0200
+++ b/lemon/graph_to_eps.h	Sat Sep 25 14:35:59 2010 +0200
@@ -662,6 +662,7 @@
 public:
   ~GraphToEps() { }
 
+private:
   template<typename GR, typename D>
   void edgeToEps(const GR &g, std::ostream &os, const typename GR::Arc e,
     const Color &col, double width, D t) {
@@ -674,7 +675,7 @@
   }
 
   template<typename D>
-  void inner_run(D t) {
+  void start(D t) {
     const double EPSILON=1e-9;
     if(dontPrint) return;
 
@@ -1076,6 +1077,7 @@
     if(_pleaseRemoveOsStream) {delete &os;}
   }
 
+public:
   ///Draws the graph.
 
   ///Like other functions using
@@ -1083,11 +1085,11 @@
   ///this function calls the algorithm itself, i.e. in this case
   ///it draws the graph.
   void run(int i = 0) {
-    this->inner_run(i); //for normal graphs
+    this->start(i); //for normal graphs
   }
 
   void run(bool b) {
-    this->inner_run(b); //for plane graphs with custom edge shape support
+    this->start(b); //for plane graphs with custom edge shape support
   }
 
   ///\name Aliases
diff -r 10d57978f900 -r 2c0edf00dc8f lemon/planar_graph.h
--- a/lemon/planar_graph.h	Mon Jun 07 20:57:51 2010 +0200
+++ b/lemon/planar_graph.h	Sat Sep 25 14:35:59 2010 +0200
@@ -21,7 +21,7 @@
 
 ///\ingroup graphs
 ///\file
-///\brief PlanarGraph classes. UNDER CONSTRUCTION.
+///\brief PlanarGraph classes.
 
 #include <lemon/core.h>
 #include <lemon/error.h>
@@ -359,14 +359,14 @@
 
     void firstCcwF(Arc &e, const Face &f) const {
       e.id = faces[f.id].first_arc;
+      setToOpposite(e);
       turnRight(e);
-      setToOpposite(e);
     }
     void nextCcwF(Arc &e) const {
       if (e.id == faces[arcs[e.id].left_face].first_arc) e = INVALID;
       else {
+        setToOpposite(e);
         turnRight(e);
-        setToOpposite(e);
       }
     }
     void firstCwF(Arc &e, const Face &f) const {
@@ -379,25 +379,25 @@
     }
 
     void firstInF(Arc &e, const Face &f) const {
-      e.id = faces[f.id].first_arc;
+      e.id = faces[f.id].first_arc ^ 1;
+      turnRight(e);
+      setToOpposite(e);
     }
     void nextInF(Arc &e) const {
-      setToOpposite(e);
-      turnRight(e);
-      if (e.id == faces[arcs[e.id].left_face].first_arc) e = INVALID;
-    }
-    void lastInF(Arc &e, const Face &f) const {
-      e.id = faces[f.id].first_arc;
-      setToOpposite(e);
-      turnRight(e);
-    }
-    void prevInF(Arc &e) const {
-      if (e.id == faces[arcs[e.id].left_face].first_arc) {
+      if (e.id == (faces[arcs[e.id ^ 1].left_face].first_arc ^ 1)) {
         e = INVALID;
         return;
       }
+      turnRight(e);
       setToOpposite(e);
-      turnRight(e);
+    }
+    void lastInF(Arc &e, const Face &f) const {
+      e.id = faces[f.id].first_arc ^ 1;
+    }
+    void prevInF(Arc &e) const {
+      setToOpposite(e);
+      turnLeft(e);
+      if (e.id == (faces[arcs[e.id ^ 1].left_face].first_arc ^ 1)) e = INVALID;
     }
 
     void firstOutF(Arc &e, const Face &f) const {
@@ -522,7 +522,7 @@
     }
 
     Node addNode() {
-      int n = link_node();
+      int n = linkNode();
 
       nodes[n].component = addComponent();
       components[nodes[n].component].num_nodes = 1;
@@ -540,7 +540,7 @@
           left_face && nodes[u.id].component == nodes[v.id].component) return
           INVALID;
 
-      int n = link_edge();
+      int n = linkEdge();
 
       arcs[n].target = u.id;
       arcs[n | 1].target = v.id;
@@ -585,15 +585,15 @@
         faces[f.id].first_arc = n | 1;
         faces[oldf].first_arc = n;
         Arc arc(n | 1);
-        wall_paint(arc,f.id,arc);
+        wallPaint(arc,f.id,arc);
         if (nodes[v.id].component != nodes[u.id].component) {
           erase(Face(oldf));
           erase(Face(oldfb));
           if (components[ca].num_nodes > components[cb].num_nodes) {
-            component_relabel(v,ca);
+            componentRelabel(v,ca);
             eraseComponent(cb);
           } else {
-            component_relabel(u,cb);
+            componentRelabel(u,cb);
             eraseComponent(ca);
           }
         }
@@ -638,7 +638,7 @@
       eraseComponent(nodes[n].component);
       erase(Face(nodes[n].outer_face));
 
-      unlink_node(n);
+      unlinkNode(n);
     }
 
     void erase(const Edge& edge) {
@@ -658,7 +658,7 @@
       bool comp_split = false;
       if (fr != fl) {
         Arc arc(faces[fr].first_arc);
-        wall_paint(arc,fl,arc);
+        wallPaint(arc,fl,arc);
         if ((faces[fl].first_arc | 1) == (n | 1))
           faces[fl].first_arc = faces[fr].first_arc;
         erase(Face(fr));
@@ -671,7 +671,7 @@
           ed.id ^= 1;
           turnRightF(arc);
           Face f = addFace();
-          wall_paint(arc,f.id,ed);
+          wallPaint(arc,f.id,ed);
           faces[f.id].first_arc = arc.id;
           turnRightF(ed);
           faces[fr].first_arc = ed.id;
@@ -681,7 +681,7 @@
       if (arcs[n].next_out != -1) {
         arcs[arcs[n].next_out].prev_out = arcs[n].prev_out;
       } else {
-        nodes[arcs[n].target].last_out = arcs[n].prev_out;
+        nodes[arcs[n | 1].target].last_out = arcs[n].prev_out;
       }
 
       if (arcs[n].prev_out != -1) {
@@ -693,7 +693,7 @@
       if (arcs[n | 1].next_out != -1) {
         arcs[arcs[n | 1].next_out].prev_out = arcs[n | 1].prev_out;
       } else {
-        nodes[arcs[n | 1].target].last_out = arcs[n | 1].prev_out;
+        nodes[arcs[n].target].last_out = arcs[n | 1].prev_out;
       }
 
       if (arcs[n | 1].prev_out != -1) {
@@ -702,9 +702,9 @@
         nodes[arcs[n].target].first_out = arcs[n | 1].next_out;
       }
 
-      unlink_edge(edge);
+      unlinkEdge(edge);
 
-      if (comp_split) component_relabel(Node(arcs[n | 1].target),
+      if (comp_split) componentRelabel(Node(arcs[n | 1].target),
         addComponent());
       if (nodes[arcs[n].target].first_out == -1 && nodes[arcs[n | 1].target].
               first_out == -1) {
@@ -736,15 +736,15 @@
     Node split(Edge e) {
       Node v;
       Edge e2;
-      inner_split1(v,e2);
-      return inner_split2(e,v,e2);
+      innerSplit1(v,e2);
+      return innerSplit2(e,v,e2);
     }
 
     Node split(Node n1, Edge e1, Edge e2, bool b) {
       Node n2;
-      inner_split1(n1,n2);
+      innerSplit1(n1,n2);
       Edge a3;
-      inner_split2(n1,n2,e1,e2,b,a3);
+      innerSplit2(n1,n2,e1,e2,b,a3);
       if (!b && a3 != INVALID) erase(a3);
       return n2;
     }
@@ -754,8 +754,8 @@
       Node n2 = v(e);
       Node nd;
       bool simple;
-      inner_contract1(n1,n2,nd,simple);
-      inner_contract2(e,n1,n2,nd,simple);
+      innerContract1(n1,n2,nd,simple);
+      innerContract2(e,n1,n2,nd,simple);
     }
 
   protected:
@@ -763,7 +763,7 @@
     //Adds a node to the linked list and sets default properties. Used by
     //addNode and other functions that take care of the planar properties by
     //themselves.
-    int link_node() {
+    int linkNode() {
       int n;
       if (first_free_node==-1) {
         n = nodes.size();
@@ -784,7 +784,7 @@
     //Removes a node from the linked list. Used by
     //erase(Node) and other functions that take care of the planar properties by
     //themselves.
-    void unlink_node(int n) {
+    void unlinkNode(int n) {
       if (nodes[n].next != -1) {
         nodes[nodes[n].next].prev = nodes[n].prev;
       }
@@ -803,7 +803,7 @@
     //Adds an edge to the linked list. Used by
     //addEdge and other functions that take care of the planar properties by
     //themselves.
-    int link_edge() {
+    int linkEdge() {
       int n;
       if (first_free_arc == -1) {
         n = arcs.size();
@@ -819,7 +819,7 @@
     //Removes an edge from the linked list. Used by
     //erase(Edge) and other functions that take care of the planar properties by
     //themselves.
-    void unlink_edge(Edge e) {
+    void unlinkEdge(Edge e) {
       int n = e.id*2;
       arcs[n].next_out = first_free_arc;
       first_free_arc = n;
@@ -828,12 +828,12 @@
     }
 
     //Primitives of split(Edge)
-    void inner_split1(Node &v, Edge &e2) {
-      v = Node(link_node());
-      e2 = Arc(link_edge());
+    void innerSplit1(Node &v, Edge &e2) {
+      v = Node(linkNode());
+      e2 = Arc(linkEdge());
     }
 
-    Node inner_split2(Edge e, Node v, Edge e2) {
+    Node innerSplit2(Edge e, Node v, Edge e2) {
       Arc a(e.id*2);
       int b = e2.id*2;
       nodes[v.id].component = nodes[arcs[a.id].target].component;
@@ -864,7 +864,7 @@
     }
 
     //Primitives of contract(Edge)
-    void inner_contract1(Node n1, Node n2, Node &to_delete, bool &simple) {
+    void innerContract1(Node n1, Node n2, Node &to_delete, bool &simple) {
       if (nodes[n1.id].first_out == nodes[n1.id].last_out) {
         simple = true;
         to_delete = n1;
@@ -877,7 +877,7 @@
       }
     }
 
-    void inner_contract2(Edge e, Node n1, Node n2, Node &to_delete, bool
+    void innerContract2(Edge e, Node n1, Node n2, Node &to_delete, bool
       &simple) {
       if (simple) {
         erase(e);
@@ -921,17 +921,17 @@
       }
       arcs[arcs[a.id].prev_out].next_out = arcs[a.id | 1].next_out;
 
-      unlink_edge(e);
+      unlinkEdge(e);
       --components[nodes[n2.id].component].num_nodes;
-      unlink_node(n2.id);
+      unlinkNode(n2.id);
     }
 
     //Primitives of split(Node)
-    void inner_split1(Node n1, Node &n2) {
-      n2 = Node(link_node());
+    void innerSplit1(Node n1, Node &n2) {
+      n2 = Node(linkNode());
     }
 
-    void inner_split2(Node n1, Node n2, Edge e1, Edge e2, bool b, Edge &e3) {
+    void innerSplit2(Node n1, Node n2, Edge e1, Edge e2, bool b, Edge &e3) {
       e3 = INVALID;
       if (nodes[n1.id].first_out == -1) {
         if (b) e3 = addEdge(n1,n2,INVALID,INVALID);
@@ -945,7 +945,7 @@
       if (arcs[a1.id].target != n1.id) a1.id |= 1;
       Arc a2(e2.id*2);
       if (arcs[a2.id].target != n1.id) a2.id |= 1;
-      Arc a3(link_edge());
+      Arc a3(linkEdge());
       e3 = a3;
       arcs[a3.id].target = n1.id;
       arcs[a3.id | 1].target = n2.id;
@@ -973,7 +973,7 @@
     }
 
     //Relabels the "wall" of a face with a new face ID.
-    void wall_paint(Arc arc, int f_id, Arc ed) {
+    void wallPaint(Arc arc, int f_id, Arc ed) {
       do {
         arcs[arc.id].left_face = f_id;
         turnRightF(arc);
@@ -981,7 +981,7 @@
     }
 
     //Relabels a component with a new component ID.
-    void component_relabel(Node node, int comp_id) {
+    void componentRelabel(Node node, int comp_id) {
       std::vector<int> ns(nodes.size());
       std::list<int> q;
       q.push_back(node.id);
@@ -1137,7 +1137,6 @@
       }
     }
 #endif
-
   };
 
   // Face counting:
@@ -1302,10 +1301,10 @@
     };
 
 
-  /// Iterator class for the faces.
+		/// Iterator class for the faces.
 
-  /// This iterator goes through the faces of a planar graph.
-  class FaceIt : public Face {
+		/// This iterator goes through the faces of a planar graph.
+		class FaceIt : public Face {
       const Graph* _graph;
     public:
 
@@ -1325,13 +1324,13 @@
         return *this;
       }
 
-    };
+		};
 
 
-  /// Iterator class for the common faces of two nodes
+		/// Iterator class for the common faces of two nodes
 
-  /// This iterator goes through the common faces of two nodes
-  class CommonFacesIt : public Face {
+		/// This iterator goes through the common faces of two nodes
+		class CommonFacesIt : public Face {
       const Graph* _graph;
       const Node _n1, _n2;
       std::set<Face> _f1, _f2;
@@ -1371,12 +1370,12 @@
         return *this;
       }
 
-    };
+		};
 
-  /// Iterator class for the common nodes of two facess
+		/// Iterator class for the common nodes of two facess
 
-  /// This iterator goes through the common nodes of two faces
-  class CommonNodesIt : public Node {
+		/// This iterator goes through the common nodes of two faces
+		class CommonNodesIt : public Node {
       const Graph* _graph;
       const Face _f1, _f2;
       std::set<Node> _ns1,_ns2;
@@ -1416,12 +1415,39 @@
         return *this;
       }
 
-    };
+		};
 
-  /// Iterator class for the arcs on the boundary of a face.
+		/// This iterator goes through the arcs on the boundary of a face counter clockwise.
+		class CcwBoundaryArcIt : public Arc {
+      const Graph* _graph;
+      Face _face;
+      Arc f_arc;
+    public:
 
-  /// This iterator goes through the arcs on the boundary of a face clockwise.
-  class CwBoundaryArcIt : public Arc {
+      CcwBoundaryArcIt() { }
+
+      CcwBoundaryArcIt(Invalid i) : Arc(i) { }
+
+      CcwBoundaryArcIt(const Graph& graph, const Face& face)
+          : _graph(&graph), _face(face) {
+        _graph->firstCcwF(static_cast<Arc&>(*this),face);
+        f_arc = *this;
+      }
+
+      CcwBoundaryArcIt(const Graph& graph, const Arc& arc)
+          : Arc(arc), _graph(&graph) {}
+
+      CcwBoundaryArcIt& operator++() {
+        _graph->nextCcwF(*this);
+        return *this;
+      }
+
+		};
+
+		/// Iterator class for the arcs on the boundary of a face.
+
+		/// This iterator goes through the arcs on the boundary of a face clockwise.
+		class CwBoundaryArcIt : public Arc {
       const Graph* _graph;
       Face _face;
       Arc f_arc;
@@ -1445,33 +1471,114 @@
         return *this;
       }
 
-    };
+		};
 
-  /// Iterator class for the arcs around a node.
+		/// Iterator class for the outgoing arcs of a node.
 
-  /// This iterator goes through the arcs around a node anticlockwise.
-  class CcwArcIt : public Arc {
+		/// This iterator goes through the outgoing arcs of a node counter clockwise.
+		class CcwOutArcIt : public Arc {
       const Graph* _graph;
       const Node _node;
     public:
 
-      CcwArcIt() { }
+      CcwOutArcIt() { }
 
-      CcwArcIt(Invalid i) : Arc(i) { }
+      CcwOutArcIt(Invalid i) : Arc(i) { }
 
-      CcwArcIt(const Graph& graph, const Node& node)
+      CcwOutArcIt(const Graph& graph, const Node& node)
           : _graph(&graph), _node(node) {
-        _graph->firstCcw(*this, node);
+        _graph->firstOut(*this, node);
       }
 
-      CcwArcIt(const Graph& graph, const Arc& arc)
+      CcwOutArcIt(const Graph& graph, const Arc& arc)
           : Arc(arc), _graph(&graph) {}
 
-      CcwArcIt& operator++() {
-        _graph->nextCcw(*this, _node);
+      CcwOutArcIt& operator++() {
+        _graph->nextOut(*this);
         return *this;
       }
 
+		};
+
+		/// Iterator class for the outgoing arcs of a node.
+
+		/// This iterator goes through the outgoing arcs of a node clockwise.
+		class CwOutArcIt : public Arc {
+      const Graph* _graph;
+      const Node _node;
+    public:
+
+      CwOutArcIt() { }
+
+      CwOutArcIt(Invalid i) : Arc(i) { }
+
+      CwOutArcIt(const Graph& graph, const Node& node)
+          : _graph(&graph), _node(node) {
+        _graph->lastOut(*this, node);
+      }
+
+      CwOutArcIt(const Graph& graph, const Arc& arc)
+          : Arc(arc), _graph(&graph) {}
+
+      CwOutArcIt& operator++() {
+        _graph->prevOut(*this);
+        return *this;
+      }
+
+		};
+		
+		/// Iterator class for the incoming arcs of a node.
+
+		/// This iterator goes through the incoming arcs of a node counter clockwise.
+		class CcwInArcIt : public Arc {
+      const Graph* _graph;
+      const Node _node;
+    public:
+
+      CcwInArcIt() { }
+
+      CcwInArcIt(Invalid i) : Arc(i) { }
+
+      CcwInArcIt(const Graph& graph, const Node& node)
+          : _graph(&graph), _node(node) {
+        _graph->firstIn(*this, node);
+      }
+
+      CcwInArcIt(const Graph& graph, const Arc& arc)
+          : Arc(arc), _graph(&graph) {}
+
+      CcwInArcIt& operator++() {
+        _graph->nextIn(*this);
+        return *this;
+      }
+
+    };
+
+		/// Iterator class for the incoming arcs of a node.
+
+		/// This iterator goes through the incoming arcs of a node clockwise.
+		class CwInArcIt : public Arc {
+      const Graph* _graph;
+      const Node _node;
+    public:
+
+      CwInArcIt() { }
+
+      CwInArcIt(Invalid i) : Arc(i) { }
+
+      CwInArcIt(const Graph& graph, const Node& node)
+          : _graph(&graph), _node(node) {
+        _graph->lastIn(*this, node);
+      }
+
+      CwInArcIt(const Graph& graph, const Arc& arc)
+          : Arc(arc), _graph(&graph) {}
+
+      CwInArcIt& operator++() {
+        _graph->prevIn(*this);
+        return *this;
+      }
+			
     };
 
     void clear() {
@@ -1519,7 +1626,7 @@
   ///This class provides only linear time counting for nodes, edges, arcs and
   ///faces.
   ///
-  ///A disconnected planar graph has have an outer face for each of its
+  ///A disconnected planar graph has an outer face for each of its
   ///components, effectively turning them into separate graphs. Each component
   ///has a corresponding component in the dual.
   ///\sa concepts::Graph
@@ -1537,10 +1644,11 @@
     /// \brief Constructor
 
     /// Constructor.
-    ///
+    /// Creates an empty planar graph.
     PlanarGraph() {}
 
-
+		typedef True PlanarGraphTag;
+		
     ///\brief Constructor that copies a planar embedding
 
     ///Constructor that copies a planar embedding.
@@ -1551,6 +1659,11 @@
       this->copyEmbedding(g,em,nm,am);
     }
 
+    ///\brief Constructor that copies a planar embedding
+
+    ///Constructor that copies a planar embedding. Places the mapping from the
+		///nodes and arcs of the old graph to the ones of the new graph into \c nm
+		///and \c am, respectively.
     template<typename Graph>
     PlanarGraph(const Graph &g, const lemon::PlanarEmbedding<Graph> &em,
         typename Graph::template NodeMap<Node> &nm,
@@ -1592,7 +1705,7 @@
       }
     }
 
-    void edge_add_notify(Edge edge) {
+    void edgeAddNotify(Edge edge) {
       notifier(Edge()).add(edge);
       std::vector<Arc> ev;
       ev.push_back(Parent::direct(edge, true));
@@ -1600,7 +1713,7 @@
       notifier(Arc()).add(ev);
     }
 
-    void edge_erase_notify(Edge edge) {
+    void edgeEraseNotify(Edge edge) {
       std::vector<Arc> av;
       av.push_back(Parent::direct(edge, true));
       av.push_back(Parent::direct(edge, false));
@@ -1626,7 +1739,7 @@
     /// This function adds a new edge to the graph between nodes
     /// \c u and \c v with inherent orientation from node \c u to
     /// node \c v. \c p_u and \c p_v are the edges that directly precede the new
-    /// edge in anticlockwise order at the nodes \c u and \c v, respectively.
+    /// edge in counter clockwise order at the nodes \c u and \c v, respectively.
     /// INVALID should be passed as \c p_u or \c p_v if and only if the
     /// respective node is isolated.
     ///
@@ -1659,7 +1772,7 @@
       if (!valid(f_v) && f_u != f_v) notifier(Face()).erase(f_v);
       if (!valid(o_u)) notifier(Face()).erase(o_u);
       if (!valid(o_v)) notifier(Face()).erase(o_v);
-      edge_add_notify(edge);
+      edgeAddNotify(edge);
       Face e_l = leftFace(direct(edge,u));
       Face e_r = rightFace(direct(edge,u));
       if (e_l != f_u && e_l != f_v && e_l != o_u && e_l != o_v)
@@ -1752,15 +1865,6 @@
       return Parent::valid(f);
     }
 
-    /// \brief Change the first node of an edge.
-    ///
-    /// Planar graphs don't support changing the endpoints of edges.
-    void changeU(Edge e, Node n) = delete;
-    /// \brief Change the second node of an edge.
-    ///
-    /// Planar graphs don't support changing the endpoints of edges.
-    void changeV(Edge e, Node n) = delete;
-
     /// \brief Contract two nodes.
     ///
     /// This function contracts the two ends of the given edge.
@@ -1786,10 +1890,10 @@
       if (n1 == n2) return;
       Node nd;
       bool simple;
-      inner_contract1(n1,n2,nd,simple);
+      innerContract1(n1,n2,nd,simple);
       notifier(Node()).erase(nd);
-      edge_erase_notify(e);
-      inner_contract2(e,n1,n2,nd,simple);
+      edgeEraseNotify(e);
+      innerContract2(e,n1,n2,nd,simple);
     }
 
     /// \brief Split an edge.
@@ -1808,16 +1912,16 @@
     Node split(Edge e) {
       Node v;
       Edge e2;
-      inner_split1(v,e2);
+      innerSplit1(v,e2);
       notifier(Node()).add(v);
-      edge_add_notify(e2);
-      return inner_split2(e,v,e2);
+      edgeAddNotify(e2);
+      return innerSplit2(e,v,e2);
     }
 
     ///Split a node.
 
     ///This function splits the given node. First, a new node is added
-    ///to the graph, then all edges in anticlockwise order from \c e1 until but
+    ///to the graph, then all edges in counter clockwise order from \c e1 until but
     ///not including \c e2
     ///are re-anchored from \c n to the new node.
     ///If the second parameter \c connect is \c true (this is the default
@@ -1835,15 +1939,15 @@
     ///Snapshot feature.
     Node split(Node n1, Edge e1, Edge e2, bool connect) {
       Node n2;
-      inner_split1(n1,n2);
+      innerSplit1(n1,n2);
       notifier(Node()).add(n2);
       Edge a3;
-      inner_split2(n1,n2,e1,e2,connect,a3);
+      innerSplit2(n1,n2,e1,e2,connect,a3);
       if (!connect) {
         if (a3 != INVALID)
           erase(a3);
       } else {
-        edge_add_notify(a3);
+        edgeAddNotify(a3);
       }
       return n2;
     }
@@ -1866,6 +1970,7 @@
     /// then it is worth reserving space for this amount before starting
     /// to build the graph.
     /// \sa reserveEdge()
+    /// \sa reserveFace()
     void reserveNode(int n) {
       nodes.reserve(n);
     };
@@ -1878,6 +1983,7 @@
     /// then it is worth reserving space for this amount before starting
     /// to build the graph.
     /// \sa reserveNode()
+    /// \sa reserveFace()
     void reserveEdge(int m) {
       arcs.reserve(2 * m);
     };
@@ -1889,11 +1995,13 @@
     /// be large (e.g. it will contain millions of nodes and/or edges),
     /// then it is worth reserving space for this amount before starting
     /// to build the graph.
-    /// \sa reserveFace()
+    /// \sa reserveNode()
+    /// \sa reserveEdge()
     void reserveFace(int n) {
       faces.reserve(n);
     };
 
+  private:
     class DualBase {
       const Graph *_graph;
     protected:
@@ -1939,12 +2047,30 @@
       void next(Node &i) const {
         _graph->next(i);
       }
+      void first(Edge &i) const {
+        _graph->first(i);
+      }
+      void next(Edge &i) const {
+        _graph->next(i);
+      }
       void first(Arc &i) const {
         _graph->first(i);
       }
       void next(Arc &i) const {
         _graph->next(i);
       }
+      void firstInc(Edge& i, bool &dir, const Node& n) const {
+			  Arc e;
+        _graph->lastInF(e, n);
+				i = e;
+				dir = _graph->direction(e);
+      }
+      void nextInc(Edge& i, bool &dir) const {
+			  Arc e = _graph->direct(i, dir);
+        _graph->prevInF(e);
+				i = e;
+				dir = _graph->direction(e);
+      }
       void firstCcw(Arc& i, const Node& n) const {
         _graph->lastInF(i, n);
       }
@@ -1957,17 +2083,35 @@
       void nextIn(Arc& i) const {
         _graph->nextInF(i);
       }
+      void lastIn(Arc& i, const Node& n) const {
+        _graph->lastInF(i, n);
+      }
+      void prevIn(Arc& i) const {
+        _graph->prevInF(i);
+      }
       void firstCwF(Arc& i, const Face& n) const {
-        _graph->lastIn(i, n);
+        _graph->lastOut(i, n);
       }
       void nextCwF(Arc& i) const {
-        _graph->prevIn(i);
+        _graph->prevOut(i);
+      }
+      void firstCcwF(Arc& i, const Face& n) const {
+        _graph->firstOut(i, n);
+      }
+      void nextCcwF(Arc& i) const {
+        _graph->nextOut(i);
       }
       void firstOut(Arc& i, const Node& n ) const {
-        _graph->firstOutF(i, n);
+        _graph->firstCcwF(i, n);
       }
       void nextOut(Arc& i) const {
-        _graph->nextOutF(i);
+        _graph->nextCcwF(i);
+      }
+      void lastOut(Arc& i, const Node& n ) const {
+        _graph->firstCwF(i, n);
+      }
+      void prevOut(Arc& i) const {
+        _graph->nextCwF(i);
       }
       void first(Face &i) const {
         _graph->first(i);
@@ -2004,16 +2148,34 @@
       bool valid(Face n) const {
         return _graph->valid(n);
       }
-
+			Node u(Edge e) const {
+				return _graph->w1(e);
+			}
+			Node v(Edge e) const {
+				return _graph->w2(e);
+			}
+			Face w1(Edge e) const {
+				return _graph->u(e);
+			}
+			Face w2(Edge e) const {
+				return _graph->v(e);
+			}
+			
     };
 
     typedef PlanarGraphExtender<GraphExtender<DualBase> > ExtendedDualBase;
 
-  /// Adaptor class for the dual of a planar graph.
+	public:		
 
-  /// This is an adaptor class for the dual of a planar graph.
-  class Dual : public ExtendedDualBase {
-    public:
+		/// Adaptor class for the dual of a planar graph.
+
+		/// This is an adaptor class for the dual of a planar graph.
+		/// Nodes in the dual graph correspond to the faces of the underlying planar
+		/// graph and vice versa. For this reason, the type Node in Dual is the same
+		/// as Face in PlanarGraph and vice versa. All the iterators, maps and
+		/// inspector functions work the same way as with PlanarGraph.
+		class Dual : public ExtendedDualBase {
+		public:
       Dual(const PlanarGraph &graph) {
         initialize(&graph);
       }
diff -r 10d57978f900 -r 2c0edf00dc8f lemon/plane_graph.h
--- a/lemon/plane_graph.h	Mon Jun 07 20:57:51 2010 +0200
+++ b/lemon/plane_graph.h	Sat Sep 25 14:35:59 2010 +0200
@@ -21,7 +21,7 @@
 
 ///\ingroup graphs
 ///\file
-///\brief PlaneGraph classes. UNDER CONSTRUCTION.
+///\brief PlaneGraph class.
 
 #include <lemon/planarity.h>
 #include <lemon/planar_graph.h>
@@ -457,6 +457,24 @@
   ///\ref PlaneGraph adds geometry features to PlanarGraph. While PlanarGraph
   ///must be built from the topology, PlaneGraph requires coordinates for nodes
   ///and determines the topology that fits the coordinates.
+	///This class takes an edge shape type as a template parameter. The following
+	///classes can be used as an edge shape type:
+	/// - PlaneGraphStraightEdge
+	/// - PlaneGraphLineStripEdge
+	/// - PlaneGraphBezier2Edge
+	/// - PlaneGraphBezier3Edge
+	///A custom edge shape must have the following:
+	/// - typedef Point; - a point type, such as dim2::Point
+	/// - typedef Shape; - type which stores the shape data
+	/// - static Shape create(); - creates an "empty" shape
+	/// - static Shape create(...); - creates a shape with arbitrary data
+	/// - static Point source(Shape); - returns the source point of an edge
+	/// - static Point target(Shape); - returns the target point of an edge
+	/// - static Shape reverse(Shape); - reverses an edge
+	/// - static bool between(Shape c, Shape a, Shape b); - returns true if and
+	///     only if c should go between a and b in counter clockwise order
+	/// - static bool intersect(Shape, Shape); - checks if two edges intersect
+	/// - static bool degenerate(Shape); - checks if a shape is invalid
   ///\sa PlanarGraph
   template <typename EdgeType = PlaneGraphStraightEdge>
   class PlaneGraph : public PlanarGraph {
@@ -522,6 +540,11 @@
         }
     }
 
+    ///\brief Constructor that copies a planar drawing
+
+    ///Constructor that copies a planar drawing. Places the mapping from the
+		///nodes and arcs of the old graph to the ones of the new graph into \c nm
+		///and \c em, respectively.
     template<typename Graph>
     PlaneGraph(const Graph &graph, const lemon::PlanarDrawing<Graph> &drawing,
         typename Graph::template NodeMap<Node> &nm,
@@ -633,10 +656,6 @@
       if (p_v != INVALID && (p_u == INVALID || leftFace(p_u) != leftFace(p_v))
         && checkIntersections(es,p_v)) return INVALID;
 
-#ifdef REMOVE_BEFORE_RELEASE
-            std::cout << "AddArc: " << id(n1) << "->" << id(n2) << ", p_u: "
-             << id(p_u) << ", p_v: " << id(p_v) << std::endl;
-#endif
       Edge e = PlanarGraph::addEdge(n1,n2,p_u,p_v);
       if (e != INVALID) {
         if (n1 != n2 || EdgeType::between(esr,edgeshapes[p_u],es)) {
@@ -667,19 +686,25 @@
     }
 
     ///Get a map of the node locations.
+		
     ///Get a map of the node locations.
+		///
     const NodeMap<EdgePoint> &nodePosMap() const {
       return nodepos;
     }
 
     ///Tell the location of a node.
+		
     ///Tell the location of a node.
+		///
     const EdgePoint &locate(const Node &n) const {
       return nodepos[n];
     }
 
     ///Tell the location of an arc.
+		
     ///Tell the location of an arc.
+		///
     const EdgeShape &locate(const Arc &a) const {
       return edgeshapes[a];
     }
@@ -693,7 +718,8 @@
 
     /// Iterator class for the edge shapes around a node.
 
-    /// This iterator goes through the arcs around a node anticlockwise.
+    /// This iterator goes through the arcs around a node counter clockwise.
+		///
     class CcwIncIt : public Arc {
       const PlaneGraph* _graph;
       const Node _node;
@@ -725,6 +751,7 @@
     /// Iterator class for the edge shapes around a node.
 
     /// This iterator goes through the arcs around a node clockwise.
+		///
     class CwIncIt : public Arc {
       const PlaneGraph* _graph;
       const Node _node;
@@ -756,6 +783,7 @@
     /// Iterator class for the edge shapes on the boundary of a face.
 
     /// This iterator goes through the arcs on the boundary of a face clockwise.
+		///
     class CwBoundaryIt {
       const PlaneGraph* _graph;
       Face _face;
@@ -786,7 +814,7 @@
     /// Iterator class for the edge shapes on the boundary of a face.
 
     /// This iterator goes through the arcs on the boundary of a face
-    /// anticlockwise.
+    /// counter clockwise.
     class CcwBoundaryIt {
       const PlaneGraph* _graph;
       Face _face;
diff -r 10d57978f900 -r 2c0edf00dc8f test/planar_graph_test.cc
--- a/test/planar_graph_test.cc	Mon Jun 07 20:57:51 2010 +0200
+++ b/test/planar_graph_test.cc	Sat Sep 25 14:35:59 2010 +0200
@@ -91,6 +91,38 @@
 }
 
 template <class Graph>
+void checkGraphDual() {
+  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(n1, n3, e1, INVALID),
+       e3 = G.addEdge(n1, n4, e2, INVALID),
+       e4 = G.addEdge(n2, n3, e1, e2),
+       e5 = G.addEdge(n4, n3, e3, e4);
+			 
+	typedef PlanarGraph::Dual PD;
+	PD D(G);
+	checkGraphNodeList(D, 3);
+	checkGraphEdgeList(D, 5);
+	checkGraphArcList(D, 10);
+	checkGraphFaceList(D, 4);
+
+  checkGraphIncEdgeArcLists(D, G.leftFace(G.direct(e3, false)), 3);
+  checkGraphIncEdgeArcLists(D, G.leftFace(G.direct(e3, true)), 4);
+  checkGraphIncEdgeArcLists(D, G.leftFace(G.direct(e2, false)), 3);
+  checkGraphBoundaryArcList(D, n1, 3);
+  checkGraphBoundaryArcList(D, n2, 2);
+  checkGraphBoundaryArcList(D, n3, 3);
+  checkGraphBoundaryArcList(D, n4, 2);
+	
+}
+
+template <class Graph>
 void checkPlaneGraphBuild() {
   TEMPLATE_GRAPH_TYPEDEFS(Graph);
 
@@ -154,6 +186,126 @@
   checkGraphFaceMap(G);
 }
 
+PlaneGraphLineStripEdge::Shape p2e(dim2::Point<double> p1,
+	dim2::Point<double> p2) {
+	std::vector<dim2::Point<double> > v(2);
+	v[0] = p1;
+	v[1] = p2;
+	return PlaneGraphLineStripEdge::create(v);
+}
+
+template<class Graph>
+void checkPlaneGraph2Build() {
+  TEMPLATE_GRAPH_TYPEDEFS(Graph);
+	
+	Graph G;
+	typedef dim2::Point<double> Pt;
+  Node
+    n1 = G.addNode(Pt(0.0,1.0)),
+    n2 = G.addNode(Pt(0.0,0.0)),
+    n3 = G.addNode(Pt(1.0,0.0)),
+    n4 = G.addNode(Pt(1.0,1.0)),
+    n5 = G.addNode(Pt(2.0,0.5));
+	Edge
+	  e1 = G.addEdge(p2e(Pt(0.0,1.0), Pt(0.0,0.0))),
+	  e2 = G.addEdge(p2e(Pt(0.0,1.0), Pt(1.0,0.0))),
+	  e3 = G.addEdge(p2e(Pt(0.0,1.0), Pt(1.0,1.0))),
+	  e4 = G.addEdge(p2e(Pt(0.0,0.0), Pt(1.0,0.0))),
+	  e5 = G.addEdge(p2e(Pt(1.0,1.0), Pt(1.0,0.0))),
+	  e6 = G.addEdge(p2e(Pt(0.0,1.0), Pt(1.0,1.0))),	//invalid
+	  e7 = G.addEdge(p2e(Pt(0.0,1.0), Pt(2.0,0.5)));	//invalid
+
+		checkGraphNodeList(G, 5);
+		checkGraphEdgeList(G, 5);
+		checkGraphArcList(G, 10);
+		checkGraphFaceList(G, 4);
+
+		checkGraphIncEdgeArcLists(G, n1, 3);
+		checkGraphIncEdgeArcLists(G, n2, 2);
+		checkGraphIncEdgeArcLists(G, n3, 3);
+		checkGraphIncEdgeArcLists(G, n4, 2);
+		checkGraphIncEdgeArcLists(G, n5, 0);
+		
+	}
+
+PlaneGraphBezier2Edge::Shape p3e(dim2::Point<double> p1,
+	dim2::Point<double> p2, dim2::Point<double> p3) {
+	return PlaneGraphBezier2Edge::create(p1, p2, p3);
+}
+
+template<class Graph>
+void checkPlaneGraph3Build() {
+  TEMPLATE_GRAPH_TYPEDEFS(Graph);
+	
+	Graph G;
+	typedef dim2::Point<double> Pt;
+  Node
+    n1 = G.addNode(Pt(0.0,1.0)),
+    n2 = G.addNode(Pt(0.0,0.0)),
+    n3 = G.addNode(Pt(1.0,0.0)),
+    n4 = G.addNode(Pt(1.0,1.0)),
+    n5 = G.addNode(Pt(2.0,0.5));
+	Edge
+	  e1 = G.addEdge(p3e(Pt(0.0,1.0), Pt(-1.0,0.5), Pt(0.0,0.0))),
+	  e2 = G.addEdge(p3e(Pt(0.0,1.0), Pt(0.6,0.6), Pt(1.0,0.0))),
+	  e3 = G.addEdge(p3e(Pt(0.0,1.0), Pt(0.5,1.1), Pt(1.0,1.0))),
+	  e4 = G.addEdge(p3e(Pt(0.0,0.0), Pt(0.5,-0.1), Pt(1.0,0.0))),
+	  e5 = G.addEdge(p3e(Pt(1.0,1.0), Pt(1.1,0.5),  Pt(1.0,0.0))),
+	  e6 = G.addEdge(p3e(Pt(0.0,1.0), Pt(0.6,0.6), Pt(1.0,1.0))),	//invalid
+	  e7 = G.addEdge(p3e(Pt(0.0,1.0), Pt(1.6,0.75), Pt(2.0,0.5)));	//invalid
+
+		checkGraphNodeList(G, 5);
+		checkGraphEdgeList(G, 5);
+		checkGraphArcList(G, 10);
+		checkGraphFaceList(G, 4);
+
+		checkGraphIncEdgeArcLists(G, n1, 3);
+		checkGraphIncEdgeArcLists(G, n2, 2);
+		checkGraphIncEdgeArcLists(G, n3, 3);
+		checkGraphIncEdgeArcLists(G, n4, 2);
+		checkGraphIncEdgeArcLists(G, n5, 0);
+		
+	}
+
+PlaneGraphBezier3Edge::Shape p4e(dim2::Point<double> p1,
+	dim2::Point<double> p2, dim2::Point<double> p3, dim2::Point<double> p4) {
+	return PlaneGraphBezier3Edge::create(p1, p2, p3, p4);
+}
+
+template<class Graph>
+void checkPlaneGraph4Build() {
+  TEMPLATE_GRAPH_TYPEDEFS(Graph);
+	
+	Graph G;
+	typedef dim2::Point<double> Pt;
+  Node
+    n1 = G.addNode(Pt(0.0,1.0)),
+    n2 = G.addNode(Pt(0.0,0.0)),
+    n3 = G.addNode(Pt(1.0,0.0)),
+    n4 = G.addNode(Pt(1.0,1.0)),
+    n5 = G.addNode(Pt(2.0,0.5));
+	Edge
+	  e1 = G.addEdge(p4e(Pt(0.0,1.0), Pt(-0.1,0.66), Pt(-0.1,0.33), Pt(0.0,0.0))),
+	  e2 = G.addEdge(p4e(Pt(0.0,1.0), Pt(0.33,0.33), Pt(0.66,0.66), Pt(1.0,0.0))),
+	  e3 = G.addEdge(p4e(Pt(0.0,1.0), Pt(0.33,1.1), Pt(0.66,1.1), Pt(1.0,1.0))),
+	  e4 = G.addEdge(p4e(Pt(0.0,0.0), Pt(0.33,-0.1), Pt(0.66,-0.1), Pt(1.0,0.0))),
+	  e5 = G.addEdge(p4e(Pt(1.0,1.0), Pt(1.1,0.66), Pt(1.1,0.33), Pt(1.0,0.0))),
+	  e6 = G.addEdge(p4e(Pt(0.0,1.0), Pt(0.33,0.33), Pt(0.66,0.66), Pt(1.0,1.0))),
+	  e7 = G.addEdge(p4e(Pt(0.0,1.0), Pt(1.0,0.75), Pt(1.5,0.66), Pt(2.0,0.5)));
+
+		checkGraphNodeList(G, 5);
+		checkGraphEdgeList(G, 5);
+		checkGraphArcList(G, 10);
+		checkGraphFaceList(G, 4);
+
+		checkGraphIncEdgeArcLists(G, n1, 3);
+		checkGraphIncEdgeArcLists(G, n2, 2);
+		checkGraphIncEdgeArcLists(G, n3, 3);
+		checkGraphIncEdgeArcLists(G, n4, 2);
+		checkGraphIncEdgeArcLists(G, n5, 0);
+		
+	}
+
 template <class Graph>
 void checkGraphArcSplit() {
   TEMPLATE_GRAPH_TYPEDEFS(Graph);
@@ -493,7 +645,11 @@
 void checkGraphs() {
   { // Checking PlanarGraph
     checkGraphBuild<PlanarGraph>();
+    checkGraphDual<PlanarGraph>();
     checkPlaneGraphBuild<PlaneGraph<> >();
+    checkPlaneGraph2Build<PlaneGraph<PlaneGraphLineStripEdge> >();
+    checkPlaneGraph3Build<PlaneGraph<PlaneGraphBezier2Edge> >();
+    checkPlaneGraph4Build<PlaneGraph<PlaneGraphBezier3Edge> >();
     checkGraphArcSplit<PlanarGraph>();
     checkGraphNodeSplit<PlanarGraph>();
     checkGraphContract<PlanarGraph>();
diff -r 10d57978f900 -r 2c0edf00dc8f test/planar_graph_test.h
--- a/test/planar_graph_test.h	Mon Jun 07 20:57:51 2010 +0200
+++ b/test/planar_graph_test.h	Sat Sep 25 14:35:59 2010 +0200
@@ -16,8 +16,8 @@
  *
  */
 
-#ifndef LEMON_TEST_GRAPH_TEST_H
-#define LEMON_TEST_GRAPH_TEST_H
+#ifndef LEMON_TEST_PLANAR_GRAPH_TEST_H
+#define LEMON_TEST_PLANAR_GRAPH_TEST_H
 
 #include <set>
 
@@ -25,22 +25,11 @@
 #include <lemon/maps.h>
 
 #include "test_tools.h"
+#include "graph_test.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);
@@ -53,132 +42,27 @@
   }
 
   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)
   {
-    typename Graph::CwBoundaryArcIt e(G,n);
+    typename Graph::CwBoundaryArcIt e1(G,n);
+    typename Graph::CcwBoundaryArcIt e2(G,n);
+		std::vector<int> v(cnt);
     for(int i=0;i<cnt;i++) {
-      check(e!=INVALID,"Wrong CwBoundaryArc list linking.");
-      check(n==G.w1(e) || n==G.w2(e),"Wrong CwBoundaryArc list linking.");
-      ++e;
+      check(e1!=INVALID,"Wrong CwBoundaryArc list linking.");
+      check(n==G.w1(e1) || n==G.w2(e1),"Wrong CwBoundaryArc list linking.");
+			v[i] = G.id(e1);
+      ++e1;
     }
-    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(e1==INVALID,"Wrong BoundaryArc list linking.");
+    for(int i=0;i<cnt;i++) {
+      check(e2!=INVALID,"Wrong CcwBoundaryArc list linking.");
+      check(n==G.w1(e2) || n==G.w2(e2),"Wrong CcwBoundaryArc list linking.");
+			check(v[cnt-1-i] == G.id(e2),"Conflicting Cw and Ccw iterators.");
+      ++e2;
     }
-    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.");
+    check(e2==INVALID,"Wrong BoundaryArc list linking.");
+    check(countBoundaryArcs(G,n)==cnt,"Wrong Boundary Arc number.");
   }
 
   template<class Graph>
@@ -206,48 +90,6 @@
   }
 
   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) {
@@ -259,97 +101,6 @@
   }
 
   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;
