[Lemon-commits] Alpar Juttner: Merge bugfixes #610, #611, #612, #614
Lemon HG
hg at lemon.cs.elte.hu
Wed Oct 17 20:07:38 CEST 2018
details: http://lemon.cs.elte.hu/hg/lemon/rev/c8d0179a32a2
changeset: 1404:c8d0179a32a2
user: Alpar Juttner <alpar [at] cs.elte.hu>
date: Wed Oct 17 19:22:52 2018 +0200
description:
Merge bugfixes #610,#611,#612,#614
diffstat:
CMakeLists.txt | 41 ++++++++++++++---------------
cmake/FindCOIN.cmake | 13 ++++++++-
lemon/adaptors.h | 60 ++++++++++++++++++++++----------------------
lemon/arg_parser.cc | 4 +-
lemon/planarity.h | 11 +++++++-
lemon/random.h | 2 +-
test/max_flow_test.cc | 4 +-
test/planarity_test.cc | 67 +++++++++++++++++++++++++++++++++++++++++++------
tools/dimacs-to-lgf.cc | 2 +
9 files changed, 136 insertions(+), 68 deletions(-)
diffs (truncated from 384 to 300 lines):
diff --git a/CMakeLists.txt b/CMakeLists.txt
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -86,38 +86,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 --git a/cmake/FindCOIN.cmake b/cmake/FindCOIN.cmake
--- a/cmake/FindCOIN.cmake
+++ b/cmake/FindCOIN.cmake
@@ -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 --git a/lemon/adaptors.h b/lemon/adaptors.h
--- a/lemon/adaptors.h
+++ b/lemon/adaptors.h
@@ -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 --git a/lemon/arg_parser.cc b/lemon/arg_parser.cc
--- a/lemon/arg_parser.cc
+++ b/lemon/arg_parser.cc
@@ -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 --git a/lemon/planarity.h b/lemon/planarity.h
--- a/lemon/planarity.h
+++ b/lemon/planarity.h
@@ -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 --git a/lemon/random.h b/lemon/random.h
--- a/lemon/random.h
+++ b/lemon/random.h
@@ -339,7 +339,7 @@
do {
num = rnd() & mask;
} while (num > max);
- return num;
+ return static_cast<Result>(num);
}
};
diff --git a/test/max_flow_test.cc b/test/max_flow_test.cc
--- a/test/max_flow_test.cc
+++ b/test/max_flow_test.cc
@@ -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 --git a/test/planarity_test.cc b/test/planarity_test.cc
--- a/test/planarity_test.cc
+++ b/test/planarity_test.cc
@@ -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",
More information about the Lemon-commits
mailing list