[Lemon-commits] Alpar Juttner: Merge
Lemon HG
hg at lemon.cs.elte.hu
Tue Nov 16 08:19:56 CET 2010
details: http://lemon.cs.elte.hu/hg/lemon/rev/4980b05606bd
changeset: 1021:4980b05606bd
user: Alpar Juttner <alpar [at] cs.elte.hu>
date: Tue Nov 16 07:46:01 2010 +0100
description:
Merge
diffstat:
CMakeLists.txt | 1 +
doc/CMakeLists.txt | 14 +
doc/Doxyfile.in | 6 +-
lemon/CMakeLists.txt | 12 +
lemon/Makefile.am | 1 +
lemon/hao_orlin.h | 32 +-
lemon/lemon.pc.cmake | 10 +
lemon/nagamochi_ibaraki.h | 697 +++++++++++++++++++++++++++++++++++++++++++
test/CMakeLists.txt | 15 +-
test/Makefile.am | 2 +
test/nagamochi_ibaraki_test.cc | 141 ++++++++
11 files changed, 915 insertions(+), 16 deletions(-)
diffs (truncated from 1111 to 300 lines):
diff --git a/CMakeLists.txt b/CMakeLists.txt
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -4,6 +4,7 @@
PROJECT(${PROJECT_NAME})
INCLUDE(FindPythonInterp)
+INCLUDE(FindWget)
IF(EXISTS ${PROJECT_SOURCE_DIR}/cmake/version.cmake)
INCLUDE(${PROJECT_SOURCE_DIR}/cmake/version.cmake)
diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt
--- a/doc/CMakeLists.txt
+++ b/doc/CMakeLists.txt
@@ -3,6 +3,8 @@
SET(abs_top_srcdir ${PROJECT_SOURCE_DIR})
SET(abs_top_builddir ${PROJECT_BINARY_DIR})
+SET(LEMON_DOC_SOURCE_BROWSER "NO" CACHE STRING "Include source into the doc (YES/NO).")
+
CONFIGURE_FILE(
${PROJECT_SOURCE_DIR}/doc/Doxyfile.in
${PROJECT_BINARY_DIR}/doc/Doxyfile
@@ -52,3 +54,15 @@
ENDIF()
ENDIF()
+
+IF(WGET_FOUND)
+ADD_CUSTOM_TARGET(update-external-tags
+ COMMAND ${CMAKE_COMMAND} -E make_directory dl
+ # COMMAND ${CMAKE_COMMAND} -E copy libstdc++.tag dl
+ COMMAND ${WGET_EXECUTABLE} wget -P dl -N libstdc++.tag.tmp http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/libstdc++.tag
+ COMMAND ${CMAKE_COMMAND} -E rename dl/libstdc++.tag libstdc++.tag
+ COMMAND ${CMAKE_COMMAND} -E remove dl/libstdc++.tag
+ COMMAND ${CMAKE_COMMAND} -E remove_directory dl
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+ )
+ENDIF()
diff --git a/doc/Doxyfile.in b/doc/Doxyfile.in
--- a/doc/Doxyfile.in
+++ b/doc/Doxyfile.in
@@ -70,7 +70,7 @@
SHOW_FILES = YES
SHOW_NAMESPACES = YES
FILE_VERSION_FILTER =
-LAYOUT_FILE = DoxygenLayout.xml
+LAYOUT_FILE = "@abs_top_srcdir@/doc/DoxygenLayout.xml"
#---------------------------------------------------------------------------
# configuration options related to warning and progress messages
#---------------------------------------------------------------------------
@@ -114,7 +114,7 @@
#---------------------------------------------------------------------------
# configuration options related to source browsing
#---------------------------------------------------------------------------
-SOURCE_BROWSER = NO
+SOURCE_BROWSER = @LEMON_DOC_SOURCE_BROWSER@
INLINE_SOURCES = NO
STRIP_CODE_COMMENTS = YES
REFERENCED_BY_RELATION = NO
@@ -225,7 +225,7 @@
#---------------------------------------------------------------------------
# Options related to the search engine
#---------------------------------------------------------------------------
-TAGFILES = "@abs_top_srcdir@/doc/libstdc++.tag = http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/ "
+TAGFILES = "@abs_top_builddir@/doc/libstdc++.tag = http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/ "
GENERATE_TAGFILE = html/lemon.tag
ALLEXTERNALS = NO
EXTERNAL_GROUPS = NO
diff --git a/lemon/CMakeLists.txt b/lemon/CMakeLists.txt
--- a/lemon/CMakeLists.txt
+++ b/lemon/CMakeLists.txt
@@ -8,6 +8,12 @@
${CMAKE_CURRENT_BINARY_DIR}/config.h
)
+CONFIGURE_FILE(
+ ${CMAKE_CURRENT_SOURCE_DIR}/lemon.pc.cmake
+ ${CMAKE_CURRENT_BINARY_DIR}/lemon.pc
+ @ONLY
+)
+
SET(LEMON_SOURCES
arg_parser.cc
base.cc
@@ -66,3 +72,9 @@
DESTINATION include/lemon
COMPONENT headers
)
+
+INSTALL(
+ FILES ${CMAKE_CURRENT_BINARY_DIR}/lemon.pc
+ DESTINATION lib/pkgconfig
+)
+
diff --git a/lemon/Makefile.am b/lemon/Makefile.am
--- a/lemon/Makefile.am
+++ b/lemon/Makefile.am
@@ -108,6 +108,7 @@
lemon/math.h \
lemon/min_cost_arborescence.h \
lemon/max_cardinality_search.h \
+ lemon/nagamochi_ibaraki.h \
lemon/nauty_reader.h \
lemon/network_simplex.h \
lemon/pairing_heap.h \
diff --git a/lemon/hao_orlin.h b/lemon/hao_orlin.h
--- a/lemon/hao_orlin.h
+++ b/lemon/hao_orlin.h
@@ -53,8 +53,8 @@
/// minimum cut of \f$ D \f$. The algorithm is a modified
/// preflow push-relabel algorithm. Our implementation calculates
/// the minimum cut in \f$ O(n^2\sqrt{m}) \f$ time (we use the
- /// highest-label rule), or in \f$O(nm)\f$ for unit capacities. The
- /// purpose of such algorithm is e.g. testing network reliability.
+ /// highest-label rule), or in \f$O(nm)\f$ for unit capacities. A notable
+ /// use of this algorithm is testing network reliability.
///
/// For an undirected graph you can run just the first phase of the
/// algorithm or you can use the algorithm of Nagamochi and Ibaraki,
@@ -912,6 +912,8 @@
/// This function calculates a minimum cut with \f$ source \f$ on the
/// source-side (i.e. a set \f$ X\subsetneq V \f$ with
/// \f$ source \in X \f$ and minimal outgoing capacity).
+ /// It updates the stored cut if (and only if) the newly found one
+ /// is better.
///
/// \pre \ref init() must be called before using this function.
void calculateOut() {
@@ -924,6 +926,8 @@
/// This function calculates a minimum cut with \f$ source \f$ on the
/// sink-side (i.e. a set \f$ X\subsetneq V \f$ with
/// \f$ source \notin X \f$ and minimal outgoing capacity).
+ /// It updates the stored cut if (and only if) the newly found one
+ /// is better.
///
/// \pre \ref init() must be called before using this function.
void calculateIn() {
@@ -933,8 +937,8 @@
/// \brief Run the algorithm.
///
- /// This function runs the algorithm. It finds nodes \c source and
- /// \c target arbitrarily and then calls \ref init(), \ref calculateOut()
+ /// This function runs the algorithm. It chooses source node,
+ /// then calls \ref init(), \ref calculateOut()
/// and \ref calculateIn().
void run() {
init();
@@ -944,9 +948,9 @@
/// \brief Run the algorithm.
///
- /// This function runs the algorithm. It uses the given \c source node,
- /// finds a proper \c target node and then calls the \ref init(),
- /// \ref calculateOut() and \ref calculateIn().
+ /// This function runs the algorithm. It calls \ref init(),
+ /// \ref calculateOut() and \ref calculateIn() with the given
+ /// source node.
void run(const Node& s) {
init(s);
calculateOut();
@@ -965,7 +969,9 @@
/// \brief Return the value of the minimum cut.
///
- /// This function returns the value of the minimum cut.
+ /// This function returns the value of the best cut found by the
+ /// previously called \ref run(), \ref calculateOut() or \ref
+ /// calculateIn().
///
/// \pre \ref run(), \ref calculateOut() or \ref calculateIn()
/// must be called before using this function.
@@ -976,9 +982,13 @@
/// \brief Return a minimum cut.
///
- /// This function sets \c cutMap to the characteristic vector of a
- /// minimum value cut: it will give a non-empty set \f$ X\subsetneq V \f$
- /// with minimal outgoing capacity (i.e. \c cutMap will be \c true exactly
+ /// This function gives the best cut found by the
+ /// previously called \ref run(), \ref calculateOut() or \ref
+ /// calculateIn().
+ ///
+ /// It sets \c cutMap to the characteristic vector of the found
+ /// minimum value cut - a non-empty set \f$ X\subsetneq V \f$
+ /// of minimum outgoing capacity (i.e. \c cutMap will be \c true exactly
/// for the nodes of \f$ X \f$).
///
/// \param cutMap A \ref concepts::WriteMap "writable" node map with
diff --git a/lemon/lemon.pc.cmake b/lemon/lemon.pc.cmake
new file mode 100644
--- /dev/null
+++ b/lemon/lemon.pc.cmake
@@ -0,0 +1,10 @@
+prefix=@CMAKE_INSTALL_PREFIX@
+exec_prefix=@CMAKE_INSTALL_PREFIX@/bin
+libdir=@CMAKE_INSTALL_PREFIX@/lib
+includedir=@CMAKE_INSTALL_PREFIX@/include
+
+Name: @PROJECT_NAME@
+Description: Library for Efficient Modeling and Optimization in Networks
+Version: @PROJECT_VERSION@
+Libs: -L${libdir} -lemon @GLPK_LIBS@ @CPLEX_LIBS@ @SOPLEX_LIBS@ @CLP_LIBS@ @CBC_LIBS@
+Cflags: -I${includedir}
diff --git a/lemon/nagamochi_ibaraki.h b/lemon/nagamochi_ibaraki.h
new file mode 100644
--- /dev/null
+++ b/lemon/nagamochi_ibaraki.h
@@ -0,0 +1,697 @@
+/* -*- 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.
+ *
+ */
+
+#ifndef LEMON_NAGAMOCHI_IBARAKI_H
+#define LEMON_NAGAMOCHI_IBARAKI_H
+
+
+/// \ingroup min_cut
+/// \file
+/// \brief Implementation of the Nagamochi-Ibaraki algorithm.
+
+#include <lemon/core.h>
+#include <lemon/bin_heap.h>
+#include <lemon/bucket_heap.h>
+#include <lemon/maps.h>
+#include <lemon/radix_sort.h>
+#include <lemon/unionfind.h>
+
+#include <cassert>
+
+namespace lemon {
+
+ /// \brief Default traits class for NagamochiIbaraki class.
+ ///
+ /// Default traits class for NagamochiIbaraki class.
+ /// \param GR The undirected graph type.
+ /// \param CM Type of capacity map.
+ template <typename GR, typename CM>
+ struct NagamochiIbarakiDefaultTraits {
+ /// The type of the capacity map.
+ typedef typename CM::Value Value;
+
+ /// The undirected graph type the algorithm runs on.
+ typedef GR Graph;
+
+ /// \brief The type of the map that stores the edge capacities.
+ ///
+ /// The type of the map that stores the edge capacities.
+ /// It must meet the \ref concepts::ReadMap "ReadMap" concept.
+ typedef CM CapacityMap;
+
+ /// \brief Instantiates a CapacityMap.
+ ///
+ /// This function instantiates a \ref CapacityMap.
+#ifdef DOXYGEN
+ static CapacityMap *createCapacityMap(const Graph& graph)
+#else
+ static CapacityMap *createCapacityMap(const Graph&)
+#endif
+ {
+ LEMON_ASSERT(false, "CapacityMap is not initialized");
+ return 0; // ignore warnings
+ }
+
+ /// \brief The cross reference type used by heap.
+ ///
+ /// The cross reference type used by heap.
+ /// Usually \c Graph::NodeMap<int>.
+ typedef typename Graph::template NodeMap<int> HeapCrossRef;
+
+ /// \brief Instantiates a HeapCrossRef.
+ ///
+ /// This function instantiates a \ref HeapCrossRef.
+ /// \param g is the graph, to which we would like to define the
+ /// \ref HeapCrossRef.
+ static HeapCrossRef *createHeapCrossRef(const Graph& g) {
+ return new HeapCrossRef(g);
+ }
+
+ /// \brief The heap type used by NagamochiIbaraki algorithm.
+ ///
+ /// The heap type used by NagamochiIbaraki algorithm. It has to
+ /// maximize the priorities.
+ ///
+ /// \sa BinHeap
More information about the Lemon-commits
mailing list