# HG changeset patch
# User Alpar Juttner <alpar@cs.elte.hu>
# Date 1539796684 -7200
# Node ID e5af35e6c93ff93f73cbe6ab3eef8e6750518457
# Parent  411819b8702c7fdb328049de5607e916155fa8ef# Parent  3c00344f49c951d5076dd2c4b7a2389603aba66c
Merge bugfixes #610,#611,#612,#614 to branch 1.3

diff -r 411819b8702c -r e5af35e6c93f CMakeLists.txt
--- a/CMakeLists.txt	Fri Mar 23 16:09:27 2018 +0100
+++ b/CMakeLists.txt	Wed Oct 17 19:18:04 2018 +0200
@@ -82,38 +82,37 @@
 
 IF(LEMON_ENABLE_GLPK) 
   FIND_PACKAGE(GLPK 4.33)
+  IF(GLPK_FOUND)
+    SET(LEMON_HAVE_LP TRUE)
+    SET(LEMON_HAVE_MIP TRUE)
+    SET(LEMON_HAVE_GLPK TRUE)
+  ENDIF(GLPK_FOUND)
 ENDIF(LEMON_ENABLE_GLPK)
 IF(LEMON_ENABLE_ILOG)
   FIND_PACKAGE(ILOG)
+  IF(ILOG_FOUND)
+    SET(LEMON_HAVE_LP TRUE)
+    SET(LEMON_HAVE_MIP TRUE)
+    SET(LEMON_HAVE_CPLEX TRUE)
+  ENDIF(ILOG_FOUND)
 ENDIF(LEMON_ENABLE_ILOG)
 IF(LEMON_ENABLE_COIN)
   FIND_PACKAGE(COIN)
+  IF(COIN_FOUND)
+    SET(LEMON_HAVE_LP TRUE)
+    SET(LEMON_HAVE_MIP TRUE)
+    SET(LEMON_HAVE_CLP TRUE)
+    SET(LEMON_HAVE_CBC TRUE)
+  ENDIF(COIN_FOUND)
 ENDIF(LEMON_ENABLE_COIN)
 IF(LEMON_ENABLE_SOPLEX)
   FIND_PACKAGE(SOPLEX)
+  IF(SOPLEX_FOUND)
+    SET(LEMON_HAVE_LP TRUE)
+    SET(LEMON_HAVE_SOPLEX TRUE)
+  ENDIF(SOPLEX_FOUND)
 ENDIF(LEMON_ENABLE_SOPLEX)
 
-IF(GLPK_FOUND)
-  SET(LEMON_HAVE_LP TRUE)
-  SET(LEMON_HAVE_MIP TRUE)
-  SET(LEMON_HAVE_GLPK TRUE)
-ENDIF(GLPK_FOUND)
-IF(ILOG_FOUND)
-  SET(LEMON_HAVE_LP TRUE)
-  SET(LEMON_HAVE_MIP TRUE)
-  SET(LEMON_HAVE_CPLEX TRUE)
-ENDIF(ILOG_FOUND)
-IF(COIN_FOUND)
-  SET(LEMON_HAVE_LP TRUE)
-  SET(LEMON_HAVE_MIP TRUE)
-  SET(LEMON_HAVE_CLP TRUE)
-  SET(LEMON_HAVE_CBC TRUE)
-ENDIF(COIN_FOUND)
-IF(SOPLEX_FOUND)
-  SET(LEMON_HAVE_LP TRUE)
-  SET(LEMON_HAVE_SOPLEX TRUE)
-ENDIF(SOPLEX_FOUND)
-
 IF(ILOG_FOUND)
   SET(DEFAULT_LP "CPLEX")
   SET(DEFAULT_MIP "CPLEX")
diff -r 411819b8702c -r e5af35e6c93f cmake/FindCOIN.cmake
--- a/cmake/FindCOIN.cmake	Fri Mar 23 16:09:27 2018 +0100
+++ b/cmake/FindCOIN.cmake	Wed Oct 17 19:18:04 2018 +0200
@@ -65,6 +65,12 @@
   HINTS ${COIN_ROOT_DIR}/lib
 )
 
+FIND_LIBRARY(COIN_PTHREADS_LIBRARY
+  NAMES pthreads libpthreads
+  HINTS ${COIN_ROOT_DIR}/lib/coin
+  HINTS ${COIN_ROOT_DIR}/lib
+)
+
 INCLUDE(FindPackageHandleStandardArgs)
 FIND_PACKAGE_HANDLE_STANDARD_ARGS(COIN DEFAULT_MSG
   COIN_INCLUDE_DIR
@@ -82,14 +88,17 @@
 
 IF(COIN_FOUND)
   SET(COIN_INCLUDE_DIRS ${COIN_INCLUDE_DIR})
-  SET(COIN_CLP_LIBRARIES "${COIN_CLP_LIBRARY};${COIN_COIN_UTILS_LIBRARY};${COIN_ZLIB_LIBRARY};${COIN_BZ2_LIBRARY}")
+  SET(COIN_CLP_LIBRARIES "${COIN_CLP_LIBRARY};${COIN_COIN_UTILS_LIBRARY}")
   IF(COIN_ZLIB_LIBRARY)
     SET(COIN_CLP_LIBRARIES "${COIN_CLP_LIBRARIES};${COIN_ZLIB_LIBRARY}")
   ENDIF(COIN_ZLIB_LIBRARY)
    IF(COIN_BZ2_LIBRARY)
     SET(COIN_CLP_LIBRARIES "${COIN_CLP_LIBRARIES};${COIN_BZ2_LIBRARY}")
   ENDIF(COIN_BZ2_LIBRARY)
-  SET(COIN_CBC_LIBRARIES "${COIN_CBC_LIBRARY};${COIN_CBC_SOLVER_LIBRARY};${COIN_CGL_LIBRARY};${COIN_OSI_LIBRARY};${COIN_OSI_CBC_LIBRARY};${COIN_OSI_CLP_LIBRARY};${COIN_ZLIB_LIBRARY};${COIN_BZ2_LIBRARY};${COIN_CLP_LIBRARIES}")
+   IF(COIN_PTHREADS_LIBRARY)
+    SET(COIN_CLP_LIBRARIES "${COIN_CLP_LIBRARIES};${COIN_PTHREADS_LIBRARY}")
+  ENDIF(COIN_PTHREADS_LIBRARY)
+  SET(COIN_CBC_LIBRARIES "${COIN_CBC_LIBRARY};${COIN_CBC_SOLVER_LIBRARY};${COIN_CGL_LIBRARY};${COIN_OSI_LIBRARY};${COIN_OSI_CBC_LIBRARY};${COIN_OSI_CLP_LIBRARY};${COIN_CLP_LIBRARIES}")
   SET(COIN_LIBRARIES ${COIN_CBC_LIBRARIES})
 ENDIF(COIN_FOUND)
 
diff -r 411819b8702c -r e5af35e6c93f lemon/adaptors.h
--- a/lemon/adaptors.h	Fri Mar 23 16:09:27 2018 +0100
+++ b/lemon/adaptors.h	Wed Oct 17 19:18:04 2018 +0200
@@ -3446,26 +3446,26 @@
     ///
     /// This map adaptor class adapts two node maps of the original digraph
     /// to get a node map of the split digraph.
-    /// Its value type is inherited from the first node map type (\c IN).
-    /// \tparam IN The type of the node map for the in-nodes.
-    /// \tparam OUT The type of the node map for the out-nodes.
-    template <typename IN, typename OUT>
+    /// Its value type is inherited from the first node map type (\c In).
+    /// \tparam In The type of the node map for the in-nodes.
+    /// \tparam Out The type of the node map for the out-nodes.
+    template <typename In, typename Out>
     class CombinedNodeMap {
     public:
 
       /// The key type of the map
       typedef Node Key;
       /// The value type of the map
-      typedef typename IN::Value Value;
-
-      typedef typename MapTraits<IN>::ReferenceMapTag ReferenceMapTag;
-      typedef typename MapTraits<IN>::ReturnValue ReturnValue;
-      typedef typename MapTraits<IN>::ConstReturnValue ConstReturnValue;
-      typedef typename MapTraits<IN>::ReturnValue Reference;
-      typedef typename MapTraits<IN>::ConstReturnValue ConstReference;
+      typedef typename In::Value Value;
+
+      typedef typename MapTraits<In>::ReferenceMapTag ReferenceMapTag;
+      typedef typename MapTraits<In>::ReturnValue ReturnValue;
+      typedef typename MapTraits<In>::ConstReturnValue ConstReturnValue;
+      typedef typename MapTraits<In>::ReturnValue Reference;
+      typedef typename MapTraits<In>::ConstReturnValue ConstReference;
 
       /// Constructor
-      CombinedNodeMap(IN& in_map, OUT& out_map)
+      CombinedNodeMap(In& in_map, Out& out_map)
         : _in_map(in_map), _out_map(out_map) {}
 
       /// Returns the value associated with the given key.
@@ -3497,8 +3497,8 @@
 
     private:
 
-      IN& _in_map;
-      OUT& _out_map;
+      In& _in_map;
+      Out& _out_map;
 
     };
 
@@ -3506,28 +3506,28 @@
     /// \brief Returns a combined node map
     ///
     /// This function just returns a combined node map.
-    template <typename IN, typename OUT>
-    static CombinedNodeMap<IN, OUT>
-    combinedNodeMap(IN& in_map, OUT& out_map) {
-      return CombinedNodeMap<IN, OUT>(in_map, out_map);
+    template <typename In, typename Out>
+    static CombinedNodeMap<In, Out>
+    combinedNodeMap(In& in_map, Out& out_map) {
+      return CombinedNodeMap<In, Out>(in_map, out_map);
     }
 
-    template <typename IN, typename OUT>
-    static CombinedNodeMap<const IN, OUT>
-    combinedNodeMap(const IN& in_map, OUT& out_map) {
-      return CombinedNodeMap<const IN, OUT>(in_map, out_map);
+    template <typename In, typename Out>
+    static CombinedNodeMap<const In, Out>
+    combinedNodeMap(const In& in_map, Out& out_map) {
+      return CombinedNodeMap<const In, Out>(in_map, out_map);
     }
 
-    template <typename IN, typename OUT>
-    static CombinedNodeMap<IN, const OUT>
-    combinedNodeMap(IN& in_map, const OUT& out_map) {
-      return CombinedNodeMap<IN, const OUT>(in_map, out_map);
+    template <typename In, typename Out>
+    static CombinedNodeMap<In, const Out>
+    combinedNodeMap(In& in_map, const Out& out_map) {
+      return CombinedNodeMap<In, const Out>(in_map, out_map);
     }
 
-    template <typename IN, typename OUT>
-    static CombinedNodeMap<const IN, const OUT>
-    combinedNodeMap(const IN& in_map, const OUT& out_map) {
-      return CombinedNodeMap<const IN, const OUT>(in_map, out_map);
+    template <typename In, typename Out>
+    static CombinedNodeMap<const In, const Out>
+    combinedNodeMap(const In& in_map, const Out& out_map) {
+      return CombinedNodeMap<const In, const Out>(in_map, out_map);
     }
 
     /// \brief Arc map combined from an arc map and a node map of the
diff -r 411819b8702c -r e5af35e6c93f lemon/arg_parser.cc
--- a/lemon/arg_parser.cc	Fri Mar 23 16:09:27 2018 +0100
+++ b/lemon/arg_parser.cc	Wed Oct 17 19:18:04 2018 +0200
@@ -221,9 +221,9 @@
                                 const std::string &opt)
   {
     Opts::iterator o = _opts.find(opt);
-    Opts::iterator s = _opts.find(syn);
     LEMON_ASSERT(o!=_opts.end(), "Unknown option: '"+opt+"'");
-    LEMON_ASSERT(s==_opts.end(), "Option already used: '"+syn+"'");
+    LEMON_ASSERT(_opts.find(syn)==_opts.end(),
+                 "Option already used: '"+syn+"'");
     ParData p;
     p.help=opt;
     p.mandatory=false;
diff -r 411819b8702c -r e5af35e6c93f lemon/planarity.h
--- a/lemon/planarity.h	Fri Mar 23 16:09:27 2018 +0100
+++ b/lemon/planarity.h	Wed Oct 17 19:18:04 2018 +0200
@@ -2383,7 +2383,7 @@
       PlanarEmbedding<Graph> pe(_graph);
       if (!pe.run()) return false;
 
-      run(pe);
+      run(pe.embeddingMap());
       return true;
     }
 
@@ -2398,6 +2398,15 @@
     void run(const EmbeddingMap& embedding) {
       typedef SmartEdgeSet<Graph> AuxGraph;
 
+      if (countNodes(_graph) < 3) {
+        int y = 0;
+        for (typename Graph::NodeIt n(_graph); n != INVALID; ++n) {
+          _point_map[n].x = 0;
+          _point_map[n].y = y++;
+        }
+        return;
+      }
+
       if (3 * countNodes(_graph) - 6 == countEdges(_graph)) {
         drawing(_graph, embedding, _point_map);
         return;
diff -r 411819b8702c -r e5af35e6c93f lemon/random.h
--- a/lemon/random.h	Fri Mar 23 16:09:27 2018 +0100
+++ b/lemon/random.h	Wed Oct 17 19:18:04 2018 +0200
@@ -342,7 +342,7 @@
         do {
           num = rnd() & mask;
         } while (num > max);
-        return num;
+        return static_cast<Result>(num);
       }
     };
 
diff -r 411819b8702c -r e5af35e6c93f test/max_flow_test.cc
--- a/test/max_flow_test.cc	Fri Mar 23 16:09:27 2018 +0100
+++ b/test/max_flow_test.cc	Wed Oct 17 19:18:04 2018 +0200
@@ -419,7 +419,7 @@
   checkMaxFlowAlg<PType2, PreflowStartFunctions<PType2> >(test_lgf, 13);
   checkMaxFlowAlg<PType3, PreflowStartFunctions<PType3> >(test_lgf, 13);
 
-  checkMaxFlowAlg<PType2, PreflowStartFunctions<PType2> >(test_lgf_float, 0.3);
+  checkMaxFlowAlg<PType2, PreflowStartFunctions<PType2> >(test_lgf_float, 0.3f);
   checkMaxFlowAlg<PType3, PreflowStartFunctions<PType3> >(test_lgf_float, 0.3);
 
   checkInitPreflow();
@@ -433,7 +433,7 @@
   checkMaxFlowAlg<EKType2, GeneralStartFunctions<EKType2> >(test_lgf, 13);
   checkMaxFlowAlg<EKType3, GeneralStartFunctions<EKType3> >(test_lgf, 13);
 
-  checkMaxFlowAlg<EKType2, GeneralStartFunctions<EKType2> >(test_lgf_float, 0.3);
+  checkMaxFlowAlg<EKType2, GeneralStartFunctions<EKType2> >(test_lgf_float, 0.3f);
   checkMaxFlowAlg<EKType3, GeneralStartFunctions<EKType3> >(test_lgf_float, 0.3);
 
   return 0;
diff -r 411819b8702c -r e5af35e6c93f test/planarity_test.cc
--- a/test/planarity_test.cc	Fri Mar 23 16:09:27 2018 +0100
+++ b/test/planarity_test.cc	Wed Oct 17 19:18:04 2018 +0200
@@ -30,10 +30,40 @@
 using namespace lemon;
 using namespace lemon::dim2;
 
-const int lgfn = 4;
+const int lgfn = 8;
 const std::string lgf[lgfn] = {
   "@nodes\n"
   "label\n"
+  "@edges\n"
+  "     label\n",
+
+  "@nodes\n"
+  "label\n"
+  "0\n"
+  "@edges\n"
+  "     label\n",
+
+  "@nodes\n"
+  "label\n"
+  "0\n"
+  "1\n"
+  "@edges\n"
+  "     label\n"
+  "0 1  0\n",
+
+  "@nodes\n"
+  "label\n"
+  "0\n"
+  "1\n"
+  "2\n"
+  "@edges\n"
+  "     label\n"
+  "0 1  0\n"
+  "1 2  1\n"
+  "2 0  2\n",
+
+  "@nodes\n"
+  "label\n"
   "0\n"
   "1\n"
   "2\n"
@@ -136,8 +166,11 @@
       ++face_num;
     }
   }
-  check(face_num + countNodes(graph) - countConnectedComponents(graph) ==
-        countEdges(graph) + 1, "Euler test does not passed");
+
+  if (face_num != 0) {
+    check(face_num + countNodes(graph) - countConnectedComponents(graph) ==
+          countEdges(graph) + 1, "Euler test does not passed");
+  }
 }
 
 void checkKuratowski(const Graph& graph, PE& pe) {
@@ -245,13 +278,29 @@
     if (planar) {
       checkEmbedding(graph, pe);
 
-      PlanarDrawing<Graph> pd(graph);
-      pd.run(pe.embeddingMap());
-      checkDrawing(graph, pd);
+      {
+        PlanarDrawing<Graph> pd(graph);
+        pd.run(pe.embeddingMap());
+        checkDrawing(graph, pd);
+      }
 
-      PlanarColoring<Graph> pc(graph);
-      pc.runFiveColoring(pe.embeddingMap());
-      checkColoring(graph, pc, 5);
+      {
+        PlanarDrawing<Graph> pd(graph);
+        pd.run();
+        checkDrawing(graph, pd);
+      }
+
+      {
+        PlanarColoring<Graph> pc(graph);
+        pc.runFiveColoring(pe.embeddingMap());
+        checkColoring(graph, pc, 5);
+      }
+
+      {
+        PlanarColoring<Graph> pc(graph);
+        pc.runFiveColoring();
+        checkColoring(graph, pc, 5);
+      }
 
     } else {
       checkKuratowski(graph, pe);
diff -r 411819b8702c -r e5af35e6c93f tools/dimacs-to-lgf.cc
--- a/tools/dimacs-to-lgf.cc	Fri Mar 23 16:09:27 2018 +0100
+++ b/tools/dimacs-to-lgf.cc	Wed Oct 17 19:18:04 2018 +0200
@@ -73,11 +73,13 @@
       if (!output) {
         throw IoError("Cannot open the file for writing", ap.files()[1]);
       }
+      // fall through
     case 1:
       input.open(ap.files()[0].c_str());
       if (!input) {
         throw IoError("File cannot be found", ap.files()[0]);
       }
+      // fall through
     case 0:
       break;
     default: