[Lemon-commits] Alpar Juttner: Merge #180 and a bugfix in #51

Lemon HG hg at lemon.cs.elte.hu
Mon Dec 14 06:17:47 CET 2009


details:   http://lemon.cs.elte.hu/hg/lemon/rev/f903263902f6
changeset: 888:f903263902f6
user:      Alpar Juttner <alpar [at] cs.elte.hu>
date:      Mon Dec 14 06:07:52 2009 +0100
description:
	Merge #180 and a bugfix in #51

diffstat:

 lemon/Makefile.am         |     1 +
 lemon/bits/map_extender.h |    96 +-
 lemon/planarity.h         |  2737 ++++++++++++++++++++++++++++++++++++++++++++++++
 lemon/unionfind.h         |     2 +-
 test/CMakeLists.txt       |     1 +
 test/Makefile.am          |     2 +
 test/planarity_test.cc    |   262 ++++
 7 files changed, 3052 insertions(+), 49 deletions(-)

diffs (truncated from 3294 to 300 lines):

diff --git a/lemon/Makefile.am b/lemon/Makefile.am
--- a/lemon/Makefile.am
+++ b/lemon/Makefile.am
@@ -110,6 +110,7 @@
 	lemon/network_simplex.h \
 	lemon/pairing_heap.h \
 	lemon/path.h \
+	lemon/planarity.h \
 	lemon/preflow.h \
 	lemon/radix_heap.h \
 	lemon/radix_sort.h \
diff --git a/lemon/bits/map_extender.h b/lemon/bits/map_extender.h
--- a/lemon/bits/map_extender.h
+++ b/lemon/bits/map_extender.h
@@ -84,36 +84,36 @@
 
       typedef typename Map::Value Value;
 
-      MapIt() {}
+      MapIt() : map(NULL) {}
 
-      MapIt(Invalid i) : Parent(i) { }
+      MapIt(Invalid i) : Parent(i), map(NULL) {}
 
-      explicit MapIt(Map& _map) : map(_map) {
-        map.notifier()->first(*this);
+      explicit MapIt(Map& _map) : map(&_map) {
+        map->notifier()->first(*this);
       }
 
       MapIt(const Map& _map, const Item& item)
-        : Parent(item), map(_map) {}
+        : Parent(item), map(&_map) {}
 
       MapIt& operator++() {
-        map.notifier()->next(*this);
+        map->notifier()->next(*this);
         return *this;
       }
 
       typename MapTraits<Map>::ConstReturnValue operator*() const {
-        return map[*this];
+        return (*map)[*this];
       }
 
       typename MapTraits<Map>::ReturnValue operator*() {
-        return map[*this];
+        return (*map)[*this];
       }
 
       void set(const Value& value) {
-        map.set(*this, value);
+        map->set(*this, value);
       }
 
     protected:
-      Map& map;
+      Map* map;
 
     };
 
@@ -124,19 +124,19 @@
 
       typedef typename Map::Value Value;
 
-      ConstMapIt() {}
+      ConstMapIt() : map(NULL) {}
 
-      ConstMapIt(Invalid i) : Parent(i) { }
+      ConstMapIt(Invalid i) : Parent(i), map(NULL) {}
 
-      explicit ConstMapIt(Map& _map) : map(_map) {
-        map.notifier()->first(*this);
+      explicit ConstMapIt(Map& _map) : map(&_map) {
+        map->notifier()->first(*this);
       }
 
       ConstMapIt(const Map& _map, const Item& item)
         : Parent(item), map(_map) {}
 
       ConstMapIt& operator++() {
-        map.notifier()->next(*this);
+        map->notifier()->next(*this);
         return *this;
       }
 
@@ -145,32 +145,32 @@
       }
 
     protected:
-      const Map& map;
+      const Map* map;
     };
 
     class ItemIt : public Item {
       typedef Item Parent;
 
     public:
+      ItemIt() : map(NULL) {}
 
-      ItemIt() {}
 
-      ItemIt(Invalid i) : Parent(i) { }
+      ItemIt(Invalid i) : Parent(i), map(NULL) {}
 
-      explicit ItemIt(Map& _map) : map(_map) {
-        map.notifier()->first(*this);
+      explicit ItemIt(Map& _map) : map(&_map) {
+        map->notifier()->first(*this);
       }
 
       ItemIt(const Map& _map, const Item& item)
-        : Parent(item), map(_map) {}
+        : Parent(item), map(&_map) {}
 
       ItemIt& operator++() {
-        map.notifier()->next(*this);
+        map->notifier()->next(*this);
         return *this;
       }
 
     protected:
-      const Map& map;
+      const Map* map;
 
     };
   };
@@ -231,36 +231,36 @@
     public:
       typedef typename Map::Value Value;
 
-      MapIt() {}
+      MapIt() : map(NULL) {}
 
-      MapIt(Invalid i) : Parent(i) { }
+      MapIt(Invalid i) : Parent(i), map(NULL) { }
 
-      explicit MapIt(Map& _map) : map(_map) {
-        map.graph.first(*this);
+      explicit MapIt(Map& _map) : map(&_map) {
+        map->graph.first(*this);
       }
 
       MapIt(const Map& _map, const Item& item)
-        : Parent(item), map(_map) {}
+        : Parent(item), map(&_map) {}
 
       MapIt& operator++() {
-        map.graph.next(*this);
+        map->graph.next(*this);
         return *this;
       }
 
       typename MapTraits<Map>::ConstReturnValue operator*() const {
-        return map[*this];
+        return (*map)[*this];
       }
 
       typename MapTraits<Map>::ReturnValue operator*() {
-        return map[*this];
+        return (*map)[*this];
       }
 
       void set(const Value& value) {
-        map.set(*this, value);
+        map->set(*this, value);
       }
 
     protected:
-      Map& map;
+      Map* map;
 
     };
 
@@ -271,53 +271,53 @@
 
       typedef typename Map::Value Value;
 
-      ConstMapIt() {}
+      ConstMapIt() : map(NULL) {}
 
-      ConstMapIt(Invalid i) : Parent(i) { }
+      ConstMapIt(Invalid i) : Parent(i), map(NULL) { }
 
-      explicit ConstMapIt(Map& _map) : map(_map) {
-        map.graph.first(*this);
+      explicit ConstMapIt(Map& _map) : map(&_map) {
+        map->graph.first(*this);
       }
 
       ConstMapIt(const Map& _map, const Item& item)
-        : Parent(item), map(_map) {}
+        : Parent(item), map(&_map) {}
 
       ConstMapIt& operator++() {
-        map.graph.next(*this);
+        map->graph.next(*this);
         return *this;
       }
 
       typename MapTraits<Map>::ConstReturnValue operator*() const {
-        return map[*this];
+        return (*map)[*this];
       }
 
     protected:
-      const Map& map;
+      const Map* map;
     };
 
     class ItemIt : public Item {
       typedef Item Parent;
 
     public:
+      ItemIt() : map(NULL) {}
 
-      ItemIt() {}
 
-      ItemIt(Invalid i) : Parent(i) { }
+      ItemIt(Invalid i) : Parent(i), map(NULL) { }
 
-      explicit ItemIt(Map& _map) : map(_map) {
-        map.graph.first(*this);
+      explicit ItemIt(Map& _map) : map(&_map) {
+        map->graph.first(*this);
       }
 
       ItemIt(const Map& _map, const Item& item)
-        : Parent(item), map(_map) {}
+        : Parent(item), map(&_map) {}
 
       ItemIt& operator++() {
-        map.graph.next(*this);
+        map->graph.next(*this);
         return *this;
       }
 
     protected:
-      const Map& map;
+      const Map* map;
 
     };
 
diff --git a/lemon/planarity.h b/lemon/planarity.h
new file mode 100644
--- /dev/null
+++ b/lemon/planarity.h
@@ -0,0 +1,2737 @@
+/* -*- 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_PLANARITY_H
+#define LEMON_PLANARITY_H
+
+/// \ingroup planar
+/// \file
+/// \brief Planarity checking, embedding, drawing and coloring
+
+#include <vector>
+#include <list>
+
+#include <lemon/dfs.h>
+#include <lemon/bfs.h>
+#include <lemon/radix_sort.h>
+#include <lemon/maps.h>
+#include <lemon/path.h>
+#include <lemon/bucket_heap.h>
+#include <lemon/adaptors.h>
+#include <lemon/edge_set.h>
+#include <lemon/color.h>
+#include <lemon/dim2.h>
+
+namespace lemon {
+
+  namespace _planarity_bits {
+
+    template <typename Graph>
+    struct PlanarityVisitor : DfsVisitor<Graph> {
+
+      TEMPLATE_GRAPH_TYPEDEFS(Graph);
+
+      typedef typename Graph::template NodeMap<Arc> PredMap;
+
+      typedef typename Graph::template EdgeMap<bool> TreeMap;
+



More information about the Lemon-commits mailing list