Changes in / [538:a76f55d7d397:675:586b65073025] in lemon
- Files:
-
- 67 added
- 106 edited
Legend:
- Unmodified
- Added
- Removed
-
.hgignore
r514 r610 23 23 lemon/stamp-h2 24 24 doc/Doxyfile 25 cmake/ cmake.version25 cmake/version.cmake 26 26 .dirstamp 27 27 .libs/* 28 28 .deps/* 29 29 demo/*.eps 30 m4/libtool.m4 31 m4/ltoptions.m4 32 m4/ltsugar.m4 33 m4/ltversion.m4 34 m4/lt~obsolete.m4 30 35 31 36 syntax: regexp … … 36 41 ^autom4te.cache/.* 37 42 ^build-aux/.* 38 ^ objs.*/.*43 ^.*objs.*/.* 39 44 ^test/[a-z_]*$ 45 ^tools/[a-z-_]*$ 40 46 ^demo/.*_demo$ 41 ^ build/.*47 ^.*build.*/.* 42 48 ^doc/gen-images/.* 43 49 CMakeFiles -
CMakeLists.txt
r520 r674 10 10 PROJECT(${PROJECT_NAME}) 11 11 12 SET(CMAKE_MODULE_PATH ${ CMAKE_SOURCE_DIR}/cmake)12 SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) 13 13 14 14 INCLUDE(FindDoxygen) 15 15 INCLUDE(FindGhostscript) 16 FIND_PACKAGE(GLPK 4.33) 17 FIND_PACKAGE(CPLEX) 18 FIND_PACKAGE(COIN) 19 20 ADD_DEFINITIONS(-DHAVE_CONFIG_H) 21 22 IF(MSVC) 23 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4250 /wd4355 /wd4800 /wd4996") 24 # Suppressed warnings: 25 # C4250: 'class1' : inherits 'class2::member' via dominance 26 # C4355: 'this' : used in base member initializer list 27 # C4800: 'type' : forcing value to bool 'true' or 'false' (performance warning) 28 # C4996: 'function': was declared deprecated 29 ENDIF(MSVC) 30 31 ADD_DEFINITIONS(-DHAVE_CONFIG_H) 16 32 17 33 INCLUDE(CheckTypeSize) 18 CHECK_TYPE_SIZE("long long" L ONG_LONG)34 CHECK_TYPE_SIZE("long long" LEMON_LONG_LONG) 19 35 20 36 ENABLE_TESTING() 21 37 22 38 ADD_SUBDIRECTORY(lemon) 23 ADD_SUBDIRECTORY(demo) 24 ADD_SUBDIRECTORY(doc) 25 ADD_SUBDIRECTORY(test) 39 IF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR}) 40 ADD_SUBDIRECTORY(demo) 41 ADD_SUBDIRECTORY(tools) 42 ADD_SUBDIRECTORY(doc) 43 ADD_SUBDIRECTORY(test) 44 ENDIF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR}) 26 45 27 IF(WIN32) 28 SET(CPACK_PACKAGE_NAME ${PROJECT_NAME}) 29 SET(CPACK_PACKAGE_VENDOR "EGRES") 30 SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY 31 "LEMON - Library of Efficient Models and Optimization in Networks") 32 SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE") 46 IF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR}) 47 IF(WIN32) 48 SET(CPACK_PACKAGE_NAME ${PROJECT_NAME}) 49 SET(CPACK_PACKAGE_VENDOR "EGRES") 50 SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY 51 "LEMON - Library of Efficient Models and Optimization in Networks") 52 SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE") 33 53 34 SET(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})54 SET(CPACK_PACKAGE_VERSION ${PROJECT_VERSION}) 35 55 36 SET(CPACK_PACKAGE_INSTALL_DIRECTORY37 "${PROJECT_NAME} ${PROJECT_VERSION}")38 SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY39 "${PROJECT_NAME} ${PROJECT_VERSION}")56 SET(CPACK_PACKAGE_INSTALL_DIRECTORY 57 "${PROJECT_NAME} ${PROJECT_VERSION}") 58 SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY 59 "${PROJECT_NAME} ${PROJECT_VERSION}") 40 60 41 SET(CPACK_COMPONENTS_ALL headers library html_documentation)61 SET(CPACK_COMPONENTS_ALL headers library html_documentation bin) 42 62 43 SET(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C++ headers") 44 SET(CPACK_COMPONENT_LIBRARY_DISPLAY_NAME "Dynamic-link library") 45 SET(CPACK_COMPONENT_HTML_DOCUMENTATION_DISPLAY_NAME "HTML documentation") 63 SET(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C++ headers") 64 SET(CPACK_COMPONENT_LIBRARY_DISPLAY_NAME "Dynamic-link library") 65 SET(CPACK_COMPONENT_BIN_DISPLAY_NAME "Command line utilities") 66 SET(CPACK_COMPONENT_HTML_DOCUMENTATION_DISPLAY_NAME "HTML documentation") 46 67 47 SET(CPACK_COMPONENT_HEADERS_DESCRIPTION 48 "C++ header files") 49 SET(CPACK_COMPONENT_LIBRARY_DESCRIPTION 50 "DLL and import library") 51 SET(CPACK_COMPONENT_HTML_DOCUMENTATION_DESCRIPTION 52 "Doxygen generated documentation") 68 SET(CPACK_COMPONENT_HEADERS_DESCRIPTION 69 "C++ header files") 70 SET(CPACK_COMPONENT_LIBRARY_DESCRIPTION 71 "DLL and import library") 72 SET(CPACK_COMPONENT_BIN_DESCRIPTION 73 "Command line utilities") 74 SET(CPACK_COMPONENT_HTML_DOCUMENTATION_DESCRIPTION 75 "Doxygen generated documentation") 53 76 54 SET(CPACK_COMPONENT_HEADERS_DEPENDS library)77 SET(CPACK_COMPONENT_HEADERS_DEPENDS library) 55 78 56 SET(CPACK_COMPONENT_HEADERS_GROUP "Development")57 SET(CPACK_COMPONENT_LIBRARY_GROUP "Development")58 SET(CPACK_COMPONENT_HTML_DOCUMENTATION_GROUP "Documentation")79 SET(CPACK_COMPONENT_HEADERS_GROUP "Development") 80 SET(CPACK_COMPONENT_LIBRARY_GROUP "Development") 81 SET(CPACK_COMPONENT_HTML_DOCUMENTATION_GROUP "Documentation") 59 82 60 SET(CPACK_COMPONENT_GROUP_DEVELOPMENT_DESCRIPTION61 "Components needed to develop software using LEMON")62 SET(CPACK_COMPONENT_GROUP_DOCUMENTATION_DESCRIPTION63 "Documentation of LEMON")83 SET(CPACK_COMPONENT_GROUP_DEVELOPMENT_DESCRIPTION 84 "Components needed to develop software using LEMON") 85 SET(CPACK_COMPONENT_GROUP_DOCUMENTATION_DESCRIPTION 86 "Documentation of LEMON") 64 87 65 SET(CPACK_ALL_INSTALL_TYPES Full Developer)88 SET(CPACK_ALL_INSTALL_TYPES Full Developer) 66 89 67 SET(CPACK_COMPONENT_HEADERS_INSTALL_TYPES Developer Full)68 SET(CPACK_COMPONENT_LIBRARY_INSTALL_TYPES Developer Full)69 SET(CPACK_COMPONENT_HTML_DOCUMENTATION_INSTALL_TYPES Full)90 SET(CPACK_COMPONENT_HEADERS_INSTALL_TYPES Developer Full) 91 SET(CPACK_COMPONENT_LIBRARY_INSTALL_TYPES Developer Full) 92 SET(CPACK_COMPONENT_HTML_DOCUMENTATION_INSTALL_TYPES Full) 70 93 71 SET(CPACK_GENERATOR "NSIS")72 SET(CPACK_NSIS_MUI_ICON "${CMAKE_SOURCE_DIR}/cmake/nsis/lemon.ico")73 SET(CPACK_NSIS_MUI_UNIICON "${CMAKE_SOURCE_DIR}/cmake/nsis/uninstall.ico")74 #SET(CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/cmake/nsis\\\\installer.bmp")75 SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\lemon.ico")76 SET(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} ${PROJECT_NAME}")77 SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\lemon.cs.elte.hu")78 SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\lemon.cs.elte.hu")79 SET(CPACK_NSIS_CONTACT "lemon-user@lemon.cs.elte.hu")80 SET(CPACK_NSIS_CREATE_ICONS_EXTRA "81 CreateShortCut \\\"$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\Documentation.lnk\\\" \\\"$INSTDIR\\\\share\\\\doc\\\\index.html\\\"82 ")83 SET(CPACK_NSIS_DELETE_ICONS_EXTRA "84 !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP85 Delete \\\"$SMPROGRAMS\\\\$MUI_TEMP\\\\Documentation.lnk\\\"86 ")94 SET(CPACK_GENERATOR "NSIS") 95 SET(CPACK_NSIS_MUI_ICON "${PROJECT_SOURCE_DIR}/cmake/nsis/lemon.ico") 96 SET(CPACK_NSIS_MUI_UNIICON "${PROJECT_SOURCE_DIR}/cmake/nsis/uninstall.ico") 97 #SET(CPACK_PACKAGE_ICON "${PROJECT_SOURCE_DIR}/cmake/nsis\\\\installer.bmp") 98 SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\lemon.ico") 99 SET(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} ${PROJECT_NAME}") 100 SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\lemon.cs.elte.hu") 101 SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\lemon.cs.elte.hu") 102 SET(CPACK_NSIS_CONTACT "lemon-user@lemon.cs.elte.hu") 103 SET(CPACK_NSIS_CREATE_ICONS_EXTRA " 104 CreateShortCut \\\"$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\Documentation.lnk\\\" \\\"$INSTDIR\\\\share\\\\doc\\\\index.html\\\" 105 ") 106 SET(CPACK_NSIS_DELETE_ICONS_EXTRA " 107 !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP 108 Delete \\\"$SMPROGRAMS\\\\$MUI_TEMP\\\\Documentation.lnk\\\" 109 ") 87 110 88 INCLUDE(CPack) 89 ENDIF(WIN32) 111 INCLUDE(CPack) 112 ENDIF(WIN32) 113 ENDIF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR}) -
INSTALL
r526 r615 28 28 29 29 This command compiles the non-template part of LEMON into libemon.a 30 file. It also compiles the programs in the tools and demo subdirectories31 when enabled.30 file. It also compiles the programs in the tools subdirectory by 31 default. 32 32 33 33 4. `make check' … … 75 75 76 76 Set the installation prefix to PREFIX. By default it is /usr/local. 77 78 --enable-demo79 80 Build the examples in the demo subdirectory.81 82 --disable-demo83 84 Do not build the examples in the demo subdirectory (default).85 77 86 78 --enable-tools … … 159 151 160 152 Disable SoPlex support. 153 154 --with-coin[=PREFIX] 155 156 Enable support for COIN-OR solvers (CLP and CBC). You should 157 specify the prefix too. (by default, COIN-OR tools install 158 themselves to the source code directory). This command enables the 159 solvers that are actually found. 160 161 --with-coin-includedir=DIR 162 163 The directory where the COIN-OR header files are located. This is 164 only useful when the COIN-OR headers and libraries are not under 165 the same prefix (which is unlikely). 166 167 --with-coin-libdir=DIR 168 169 The directory where the COIN-OR libraries are located. This is only 170 useful when the COIN-OR headers and libraries are not under the 171 same prefix (which is unlikely). 172 173 --without-coin 174 175 Disable COIN-OR support. -
LICENSE
r530 r600 2 2 copyright/license. 3 3 4 Copyright (C) 2003-200 8Egervary Jeno Kombinatorikus Optimalizalasi4 Copyright (C) 2003-2009 Egervary Jeno Kombinatorikus Optimalizalasi 5 5 Kutatocsoport (Egervary Combinatorial Optimization Research Group, 6 6 EGRES). -
Makefile.am
r503 r614 1 1 ACLOCAL_AMFLAGS = -I m4 2 3 AM_CXXFLAGS = $(WARNINGCXXFLAGS) 2 4 3 5 AM_CPPFLAGS = -I$(top_srcdir) -I$(top_builddir) … … 10 12 m4/lx_check_glpk.m4 \ 11 13 m4/lx_check_soplex.m4 \ 14 m4/lx_check_clp.m4 \ 15 m4/lx_check_cbc.m4 \ 12 16 CMakeLists.txt \ 13 17 cmake/FindGhostscript.cmake \ 18 cmake/FindGLPK.cmake \ 14 19 cmake/version.cmake.in \ 15 20 cmake/version.cmake \ … … 37 42 include test/Makefile.am 38 43 include doc/Makefile.am 39 include demo/Makefile.am40 44 include tools/Makefile.am 45 46 DIST_SUBDIRS = demo 47 48 demo: 49 $(MAKE) $(AM_MAKEFLAGS) -C demo 41 50 42 51 MRPROPERFILES = \ … … 66 75 bzip2 --best -c > $(PACKAGE)-$(VERSION).tar.bz2 67 76 68 .PHONY: mrproper dist-bz2 distcheck-bz277 .PHONY: demo mrproper dist-bz2 distcheck-bz2 -
configure.ac
r515 r674 20 20 AC_CONFIG_HEADERS([config.h lemon/config.h]) 21 21 22 lx_cmdline_cxxflags_set=${CXXFLAGS+set}23 24 22 dnl Do compilation tests using the C++ compiler. 25 23 AC_LANG([C++]) … … 28 26 AC_CHECK_TYPE(long long, [long_long_found=yes], [long_long_found=no]) 29 27 if test x"$long_long_found" = x"yes"; then 30 AC_DEFINE([ HAVE_LONG_LONG], [1], [Define to 1 if you have long long.])28 AC_DEFINE([LEMON_HAVE_LONG_LONG], [1], [Define to 1 if you have long long.]) 31 29 fi 32 30 … … 53 51 54 52 dnl Set custom compiler flags when using g++. 55 if test x"$lx_cmdline_cxxflags_set" != x"set" -a"$GXX" = yes -a "$ICC" = no; then56 CXXFLAGS="$CXXFLAGS -Wall -W -Wall -W -Wunused -Wformat=2 -Wctor-dtor-privacy -Wnon-virtual-dtor -Wno-char-subscripts -Wwrite-strings -Wno-char-subscripts -Wreturn-type -Wcast-qual -Wcast-align -Wsign-promo -Woverloaded-virtual-Woverloaded-virtual -ansi -fno-strict-aliasing -Wold-style-cast -Wno-unknown-pragmas"53 if test "$GXX" = yes -a "$ICC" = no; then 54 WARNINGCXXFLAGS="-Wall -W -Wall -W -Wunused -Wformat=2 -Wctor-dtor-privacy -Wnon-virtual-dtor -Wno-char-subscripts -Wwrite-strings -Wno-char-subscripts -Wreturn-type -Wcast-qual -Wcast-align -Wsign-promo -Woverloaded-virtual -ansi -fno-strict-aliasing -Wold-style-cast -Wno-unknown-pragmas" 57 55 fi 56 AC_SUBST([WARNINGCXXFLAGS]) 58 57 59 58 dnl Checks for libraries. 60 #LX_CHECK_GLPK 61 #LX_CHECK_CPLEX 62 #LX_CHECK_SOPLEX 59 LX_CHECK_GLPK 60 LX_CHECK_CPLEX 61 LX_CHECK_SOPLEX 62 LX_CHECK_COIN 63 63 64 dnl Disable/enable building the demo programs. 65 AC_ARG_ENABLE([demo], 66 AS_HELP_STRING([--enable-demo], [build the demo programs]) 67 AS_HELP_STRING([--disable-demo], [do not build the demo programs @<:@default@:>@]), 68 [], [enable_demo=no]) 69 AC_MSG_CHECKING([whether to build the demo programs]) 70 if test x"$enable_demo" != x"no"; then 71 AC_MSG_RESULT([yes]) 72 else 73 AC_MSG_RESULT([no]) 74 fi 75 AM_CONDITIONAL([WANT_DEMO], [test x"$enable_demo" != x"no"]) 64 AM_CONDITIONAL([HAVE_LP], [test x"$lx_lp_found" = x"yes"]) 65 AM_CONDITIONAL([HAVE_MIP], [test x"$lx_mip_found" = x"yes"]) 76 66 77 67 dnl Disable/enable building the binary tools. … … 108 98 AC_CONFIG_FILES([ 109 99 Makefile 100 demo/Makefile 110 101 cmake/version.cmake 111 102 doc/Doxyfile … … 121 112 echo 122 113 echo C++ compiler.................. : $CXX 123 echo C++ compiles flags............ : $ CXXFLAGS114 echo C++ compiles flags............ : $WARNINGCXXFLAGS $CXXFLAGS 124 115 echo 125 116 echo Compiler supports long long... : $long_long_found 126 117 echo 127 #echo GLPK support.................. : $lx_glpk_found 128 #echo CPLEX support................. : $lx_cplex_found 129 #echo SOPLEX support................ : $lx_soplex_found 130 #echo 131 echo Build demo programs........... : $enable_demo 118 echo GLPK support.................. : $lx_glpk_found 119 echo CPLEX support................. : $lx_cplex_found 120 echo SOPLEX support................ : $lx_soplex_found 121 echo CLP support................... : $lx_clp_found 122 echo CBC support................... : $lx_cbc_found 123 echo 132 124 echo Build additional tools........ : $enable_tools 133 125 echo -
demo/CMakeLists.txt
r225 r674 1 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}) 1 INCLUDE_DIRECTORIES( 2 ${PROJECT_SOURCE_DIR} 3 ${PROJECT_BINARY_DIR} 4 ) 2 5 3 LINK_DIRECTORIES(${ CMAKE_BINARY_DIR}/lemon)6 LINK_DIRECTORIES(${PROJECT_BINARY_DIR}/lemon) 4 7 5 8 SET(DEMOS -
demo/Makefile.am
r164 r611 1 EXTRA_DIST += \ 2 demo/CMakeLists.txt \ 3 demo/digraph.lgf 1 AM_CXXFLAGS = $(WARNINGCXXFLAGS) 4 2 5 if WANT_DEMO 3 AM_CPPFLAGS = -I$(top_srcdir) -I$(top_builddir) 4 LDADD = $(top_builddir)/lemon/libemon.la 6 5 7 noinst_PROGRAMS += \ 8 demo/arg_parser_demo \ 9 demo/graph_to_eps_demo \ 10 demo/lgf_demo 6 EXTRA_DIST = \ 7 CMakeLists.txt \ 8 digraph.lgf 11 9 12 endif WANT_DEMO 10 noinst_PROGRAMS = \ 11 arg_parser_demo \ 12 graph_to_eps_demo \ 13 lgf_demo 13 14 14 demo_arg_parser_demo_SOURCES = demo/arg_parser_demo.cc15 demo_graph_to_eps_demo_SOURCES = demo/graph_to_eps_demo.cc16 demo_lgf_demo_SOURCES = demo/lgf_demo.cc15 arg_parser_demo_SOURCES = arg_parser_demo.cc 16 graph_to_eps_demo_SOURCES = graph_to_eps_demo.cc 17 lgf_demo_SOURCES = lgf_demo.cc -
demo/arg_parser_demo.cc
r311 r463 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). -
demo/graph_to_eps_demo.cc
r313 r659 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 86 86 coords(coords). 87 87 title("Sample .eps figure"). 88 copyright("(C) 2003-200 8LEMON Project").88 copyright("(C) 2003-2009 LEMON Project"). 89 89 run(); 90 90 … … 93 93 coords(coords). 94 94 title("Sample .eps figure"). 95 copyright("(C) 2003-200 8LEMON Project").95 copyright("(C) 2003-2009 LEMON Project"). 96 96 absoluteNodeSizes().absoluteArcWidths(). 97 97 nodeScale(2).nodeSizes(sizes). … … 106 106 graphToEps(g,"graph_to_eps_demo_out_3_arr.eps"). 107 107 title("Sample .eps figure (with arrowheads)"). 108 copyright("(C) 2003-200 8LEMON Project").108 copyright("(C) 2003-2009 LEMON Project"). 109 109 absoluteNodeSizes().absoluteArcWidths(). 110 110 nodeColors(composeMap(palette,colors)). … … 133 133 graphToEps(g,"graph_to_eps_demo_out_4_par.eps"). 134 134 title("Sample .eps figure (parallel arcs)"). 135 copyright("(C) 2003-200 8LEMON Project").135 copyright("(C) 2003-2009 LEMON Project"). 136 136 absoluteNodeSizes().absoluteArcWidths(). 137 137 nodeShapes(shapes). … … 148 148 graphToEps(g,"graph_to_eps_demo_out_5_par_arr.eps"). 149 149 title("Sample .eps figure (parallel arcs and arrowheads)"). 150 copyright("(C) 2003-200 8LEMON Project").150 copyright("(C) 2003-2009 LEMON Project"). 151 151 absoluteNodeSizes().absoluteArcWidths(). 152 152 nodeScale(2).nodeSizes(sizes). … … 164 164 graphToEps(g,"graph_to_eps_demo_out_6_par_arr_a4.eps"). 165 165 title("Sample .eps figure (fits to A4)"). 166 copyright("(C) 2003-200 8LEMON Project").166 copyright("(C) 2003-2009 LEMON Project"). 167 167 scaleToA4(). 168 168 absoluteNodeSizes().absoluteArcWidths(). … … 183 183 ListDigraph::NodeMap<Point> hcoords(h); 184 184 185 int cols=int(s qrt(double(palette.size())));185 int cols=int(std::sqrt(double(palette.size()))); 186 186 for(int i=0;i<int(paletteW.size());i++) { 187 187 Node n=h.addNode(); … … 194 194 scale(60). 195 195 title("Sample .eps figure (Palette demo)"). 196 copyright("(C) 2003-200 8LEMON Project").196 copyright("(C) 2003-2009 LEMON Project"). 197 197 coords(hcoords). 198 198 absoluteNodeSizes().absoluteArcWidths(). -
demo/lgf_demo.cc
r294 r463 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). -
doc/CMakeLists.txt
r520 r633 1 1 SET(PACKAGE_NAME ${PROJECT_NAME}) 2 2 SET(PACKAGE_VERSION ${PROJECT_VERSION}) 3 SET(abs_top_srcdir ${ CMAKE_SOURCE_DIR})4 SET(abs_top_builddir ${ CMAKE_BINARY_DIR})3 SET(abs_top_srcdir ${PROJECT_SOURCE_DIR}) 4 SET(abs_top_builddir ${PROJECT_BINARY_DIR}) 5 5 6 6 CONFIGURE_FILE( 7 ${ CMAKE_SOURCE_DIR}/doc/Doxyfile.in8 ${ CMAKE_BINARY_DIR}/doc/Doxyfile7 ${PROJECT_SOURCE_DIR}/doc/Doxyfile.in 8 ${PROJECT_BINARY_DIR}/doc/Doxyfile 9 9 @ONLY) 10 10 … … 15 15 COMMAND rm -rf gen-images 16 16 COMMAND mkdir gen-images 17 COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/bipartite_matching.png ${CMAKE_CURRENT_SOURCE_DIR}/images/bipartite_matching.eps 18 COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/bipartite_partitions.png ${CMAKE_CURRENT_SOURCE_DIR}/images/bipartite_partitions.eps 19 COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/connected_components.png ${CMAKE_CURRENT_SOURCE_DIR}/images/connected_components.eps 20 COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/edge_biconnected_components.png ${CMAKE_CURRENT_SOURCE_DIR}/images/edge_biconnected_components.eps 21 COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/grid_graph.png ${CMAKE_CURRENT_SOURCE_DIR}/images/grid_graph.eps 22 COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/node_biconnected_components.png ${CMAKE_CURRENT_SOURCE_DIR}/images/node_biconnected_components.eps 17 23 COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/nodeshape_0.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_0.eps 18 24 COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/nodeshape_1.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_1.eps … … 20 26 COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/nodeshape_3.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_3.eps 21 27 COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/nodeshape_4.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_4.eps 28 COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/strongly_connected_components.png ${CMAKE_CURRENT_SOURCE_DIR}/images/strongly_connected_components.eps 22 29 COMMAND rm -rf html 23 30 COMMAND ${DOXYGEN_EXECUTABLE} Doxyfile … … 27 34 COMMAND if exist gen-images rmdir /s /q gen-images 28 35 COMMAND mkdir gen-images 36 COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/bipartite_matching.png ${CMAKE_CURRENT_SOURCE_DIR}/images/bipartite_matching.eps 37 COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/bipartite_partitions.png ${CMAKE_CURRENT_SOURCE_DIR}/images/bipartite_partitions.eps 38 COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/connected_components.png ${CMAKE_CURRENT_SOURCE_DIR}/images/connected_components.eps 39 COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/edge_biconnected_components.png ${CMAKE_CURRENT_SOURCE_DIR}/images/edge_biconnected_components.eps 40 COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/grid_graph.png ${CMAKE_CURRENT_SOURCE_DIR}/images/grid_graph.eps 41 COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/node_biconnected_components.png ${CMAKE_CURRENT_SOURCE_DIR}/images/node_biconnected_components.eps 29 42 COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/nodeshape_0.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_0.eps 30 43 COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/nodeshape_1.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_1.eps … … 32 45 COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/nodeshape_3.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_3.eps 33 46 COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/nodeshape_4.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_4.eps 47 COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/strongly_connected_components.png ${CMAKE_CURRENT_SOURCE_DIR}/images/strongly_connected_components.eps 34 48 COMMAND if exist html rmdir /s /q html 35 49 COMMAND ${DOXYGEN_EXECUTABLE} Doxyfile -
doc/Doxyfile.in
r316 r379 67 67 ENABLED_SECTIONS = 68 68 MAX_INITIALIZER_LINES = 5 69 SHOW_USED_FILES = YES69 SHOW_USED_FILES = NO 70 70 SHOW_DIRECTORIES = YES 71 71 SHOW_FILES = YES -
doc/Makefile.am
r317 r634 15 15 16 16 DOC_EPS_IMAGES18 = \ 17 grid_graph.eps \ 17 18 nodeshape_0.eps \ 18 19 nodeshape_1.eps \ … … 21 22 nodeshape_4.eps 22 23 24 DOC_EPS_IMAGES27 = \ 25 bipartite_matching.eps \ 26 bipartite_partitions.eps \ 27 connected_components.eps \ 28 edge_biconnected_components.eps \ 29 node_biconnected_components.eps \ 30 strongly_connected_components.eps 31 23 32 DOC_EPS_IMAGES = \ 24 $(DOC_EPS_IMAGES18) 33 $(DOC_EPS_IMAGES18) \ 34 $(DOC_EPS_IMAGES27) 25 35 26 36 DOC_PNG_IMAGES = \ … … 38 48 if test ${gs_found} = yes; then \ 39 49 $(GS_COMMAND) -sDEVICE=pngalpha -r18 -sOutputFile=$@ $<; \ 50 else \ 51 echo; \ 52 echo "Ghostscript not found."; \ 53 echo; \ 54 exit 1; \ 55 fi 56 57 $(DOC_EPS_IMAGES27:%.eps=doc/gen-images/%.png): doc/gen-images/%.png: doc/images/%.eps 58 -mkdir doc/gen-images 59 if test ${gs_found} = yes; then \ 60 $(GS_COMMAND) -sDEVICE=pngalpha -r27 -sOutputFile=$@ $<; \ 40 61 else \ 41 62 echo; \ -
doc/coding_style.dox
r210 r463 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). -
doc/dirs.dox
r318 r463 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 72 72 \brief Auxiliary tools for implementation. 73 73 74 This directory contains some auxiliary classes for implementing graphs, 74 This directory contains some auxiliary classes for implementing graphs, 75 75 maps and some other classes. 76 76 As a user you typically don't have to deal with these files. -
doc/groups.dox
r318 r658 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 17 17 */ 18 18 19 namespace lemon { 20 19 21 /** 20 22 @defgroup datas Data Structures 21 This group describes the several data structures implemented in LEMON.23 This group contains the several data structures implemented in LEMON. 22 24 */ 23 25 … … 61 63 62 64 /** 65 @defgroup graph_adaptors Adaptor Classes for Graphs 66 @ingroup graphs 67 \brief Adaptor classes for digraphs and graphs 68 69 This group contains several useful adaptor classes for digraphs and graphs. 70 71 The main parts of LEMON are the different graph structures, generic 72 graph algorithms, graph concepts, which couple them, and graph 73 adaptors. While the previous notions are more or less clear, the 74 latter one needs further explanation. Graph adaptors are graph classes 75 which serve for considering graph structures in different ways. 76 77 A short example makes this much clearer. Suppose that we have an 78 instance \c g of a directed graph type, say ListDigraph and an algorithm 79 \code 80 template <typename Digraph> 81 int algorithm(const Digraph&); 82 \endcode 83 is needed to run on the reverse oriented graph. It may be expensive 84 (in time or in memory usage) to copy \c g with the reversed 85 arcs. In this case, an adaptor class is used, which (according 86 to LEMON \ref concepts::Digraph "digraph concepts") works as a digraph. 87 The adaptor uses the original digraph structure and digraph operations when 88 methods of the reversed oriented graph are called. This means that the adaptor 89 have minor memory usage, and do not perform sophisticated algorithmic 90 actions. The purpose of it is to give a tool for the cases when a 91 graph have to be used in a specific alteration. If this alteration is 92 obtained by a usual construction like filtering the node or the arc set or 93 considering a new orientation, then an adaptor is worthwhile to use. 94 To come back to the reverse oriented graph, in this situation 95 \code 96 template<typename Digraph> class ReverseDigraph; 97 \endcode 98 template class can be used. The code looks as follows 99 \code 100 ListDigraph g; 101 ReverseDigraph<ListDigraph> rg(g); 102 int result = algorithm(rg); 103 \endcode 104 During running the algorithm, the original digraph \c g is untouched. 105 This techniques give rise to an elegant code, and based on stable 106 graph adaptors, complex algorithms can be implemented easily. 107 108 In flow, circulation and matching problems, the residual 109 graph is of particular importance. Combining an adaptor implementing 110 this with shortest path algorithms or minimum mean cycle algorithms, 111 a range of weighted and cardinality optimization algorithms can be 112 obtained. For other examples, the interested user is referred to the 113 detailed documentation of particular adaptors. 114 115 The behavior of graph adaptors can be very different. Some of them keep 116 capabilities of the original graph while in other cases this would be 117 meaningless. This means that the concepts that they meet depend 118 on the graph adaptor, and the wrapped graph. 119 For example, if an arc of a reversed digraph is deleted, this is carried 120 out by deleting the corresponding arc of the original digraph, thus the 121 adaptor modifies the original digraph. 122 However in case of a residual digraph, this operation has no sense. 123 124 Let us stand one more example here to simplify your work. 125 ReverseDigraph has constructor 126 \code 127 ReverseDigraph(Digraph& digraph); 128 \endcode 129 This means that in a situation, when a <tt>const %ListDigraph&</tt> 130 reference to a graph is given, then it have to be instantiated with 131 <tt>Digraph=const %ListDigraph</tt>. 132 \code 133 int algorithm1(const ListDigraph& g) { 134 ReverseDigraph<const ListDigraph> rg(g); 135 return algorithm2(rg); 136 } 137 \endcode 138 */ 139 140 /** 63 141 @defgroup semi_adaptors Semi-Adaptor Classes for Graphs 64 142 @ingroup graphs 65 143 \brief Graph types between real graphs and graph adaptors. 66 144 67 This group describes some graph types between real graphs and graph adaptors.145 This group contains some graph types between real graphs and graph adaptors. 68 146 These classes wrap graphs to give new functionality as the adaptors do it. 69 147 On the other hand they are not light-weight structures as the adaptors. … … 75 153 \brief Map structures implemented in LEMON. 76 154 77 This group describes the map structures implemented in LEMON.155 This group contains the map structures implemented in LEMON. 78 156 79 157 LEMON provides several special purpose maps and map adaptors that e.g. combine … … 88 166 \brief Special graph-related maps. 89 167 90 This group describes maps that are specifically designed to assign 91 values to the nodes and arcs of graphs. 168 This group contains maps that are specifically designed to assign 169 values to the nodes and arcs/edges of graphs. 170 171 If you are looking for the standard graph maps (\c NodeMap, \c ArcMap, 172 \c EdgeMap), see the \ref graph_concepts "Graph Structure Concepts". 92 173 */ 93 174 … … 97 178 \brief Tools to create new maps from existing ones 98 179 99 This group describes map adaptors that are used to create "implicit"180 This group contains map adaptors that are used to create "implicit" 100 181 maps from other maps. 101 182 102 Most of them are \ref lemon::concepts::ReadMap "read-only maps".183 Most of them are \ref concepts::ReadMap "read-only maps". 103 184 They can make arithmetic and logical operations between one or two maps 104 185 (negation, shifting, addition, multiplication, logical 'and', 'or', … … 160 241 \brief Two dimensional data storages implemented in LEMON. 161 242 162 This group describes two dimensional data storages implemented in LEMON.243 This group contains two dimensional data storages implemented in LEMON. 163 244 */ 164 245 … … 168 249 \brief %Path structures implemented in LEMON. 169 250 170 This group describes the path structures implemented in LEMON.251 This group contains the path structures implemented in LEMON. 171 252 172 253 LEMON provides flexible data structures to work with paths. … … 184 265 \brief Auxiliary data structures implemented in LEMON. 185 266 186 This group describes some data structures implemented in LEMON in267 This group contains some data structures implemented in LEMON in 187 268 order to make it easier to implement combinatorial algorithms. 188 269 */ … … 190 271 /** 191 272 @defgroup algs Algorithms 192 \brief This group describes the several algorithms273 \brief This group contains the several algorithms 193 274 implemented in LEMON. 194 275 195 This group describes the several algorithms276 This group contains the several algorithms 196 277 implemented in LEMON. 197 278 */ … … 202 283 \brief Common graph search algorithms. 203 284 204 This group describes the common graph search algorithms like205 Breadth-First Search (BFS) and Depth-First Search (DFS).285 This group contains the common graph search algorithms, namely 286 \e breadth-first \e search (BFS) and \e depth-first \e search (DFS). 206 287 */ 207 288 … … 211 292 \brief Algorithms for finding shortest paths. 212 293 213 This group describes the algorithms for finding shortest paths in graphs. 294 This group contains the algorithms for finding shortest paths in digraphs. 295 296 - \ref Dijkstra algorithm for finding shortest paths from a source node 297 when all arc lengths are non-negative. 298 - \ref BellmanFord "Bellman-Ford" algorithm for finding shortest paths 299 from a source node when arc lenghts can be either positive or negative, 300 but the digraph should not contain directed cycles with negative total 301 length. 302 - \ref FloydWarshall "Floyd-Warshall" and \ref Johnson "Johnson" algorithms 303 for solving the \e all-pairs \e shortest \e paths \e problem when arc 304 lenghts can be either positive or negative, but the digraph should 305 not contain directed cycles with negative total length. 306 - \ref Suurballe A successive shortest path algorithm for finding 307 arc-disjoint paths between two nodes having minimum total length. 214 308 */ 215 309 … … 219 313 \brief Algorithms for finding maximum flows. 220 314 221 This group describes the algorithms for finding maximum flows and315 This group contains the algorithms for finding maximum flows and 222 316 feasible circulations. 223 317 224 The maximum flow problem is to find a flow between a single source and 225 a single target that is maximum. Formally, there is a \f$G=(V,A)\f$ 226 directed graph, an \f$c_a:A\rightarrow\mathbf{R}^+_0\f$ capacity 227 function and given \f$s, t \in V\f$ source and target node. The 228 maximum flow is the \f$f_a\f$ solution of the next optimization problem: 229 230 \f[ 0 \le f_a \le c_a \f] 231 \f[ \sum_{v\in\delta^{-}(u)}f_{vu}=\sum_{v\in\delta^{+}(u)}f_{uv} 232 \qquad \forall u \in V \setminus \{s,t\}\f] 233 \f[ \max \sum_{v\in\delta^{+}(s)}f_{uv} - \sum_{v\in\delta^{-}(s)}f_{vu}\f] 318 The \e maximum \e flow \e problem is to find a flow of maximum value between 319 a single source and a single target. Formally, there is a \f$G=(V,A)\f$ 320 digraph, a \f$cap: A\rightarrow\mathbf{R}^+_0\f$ capacity function and 321 \f$s, t \in V\f$ source and target nodes. 322 A maximum flow is an \f$f: A\rightarrow\mathbf{R}^+_0\f$ solution of the 323 following optimization problem. 324 325 \f[ \max\sum_{sv\in A} f(sv) - \sum_{vs\in A} f(vs) \f] 326 \f[ \sum_{uv\in A} f(uv) = \sum_{vu\in A} f(vu) 327 \quad \forall u\in V\setminus\{s,t\} \f] 328 \f[ 0 \leq f(uv) \leq cap(uv) \quad \forall uv\in A \f] 234 329 235 330 LEMON contains several algorithms for solving maximum flow problems: 236 - \ref lemon::EdmondsKarp "Edmonds-Karp"237 - \ref lemon::Preflow "Goldberg's Preflow algorithm"238 - \ref lemon::DinitzSleatorTarjan "Dinitz's blocking flow algorithm with dynamic trees"239 - \ref lemon::GoldbergTarjan "Preflow algorithm with dynamic trees"240 241 In most cases the \ref lemon::Preflow "Preflow" algorithm provides the242 fastest method to compute the maximum flow. All impelementations243 provides functions to query the minimum cut, which is the dual linear244 pro gramming problem of the maximum flow.331 - \ref EdmondsKarp Edmonds-Karp algorithm. 332 - \ref Preflow Goldberg-Tarjan's preflow push-relabel algorithm. 333 - \ref DinitzSleatorTarjan Dinitz's blocking flow algorithm with dynamic trees. 334 - \ref GoldbergTarjan Preflow push-relabel algorithm with dynamic trees. 335 336 In most cases the \ref Preflow "Preflow" algorithm provides the 337 fastest method for computing a maximum flow. All implementations 338 provides functions to also query the minimum cut, which is the dual 339 problem of the maximum flow. 245 340 */ 246 341 … … 251 346 \brief Algorithms for finding minimum cost flows and circulations. 252 347 253 This group describes the algorithms for finding minimum cost flows and348 This group contains the algorithms for finding minimum cost flows and 254 349 circulations. 350 351 The \e minimum \e cost \e flow \e problem is to find a feasible flow of 352 minimum total cost from a set of supply nodes to a set of demand nodes 353 in a network with capacity constraints (lower and upper bounds) 354 and arc costs. 355 Formally, let \f$G=(V,A)\f$ be a digraph, 356 \f$lower, upper: A\rightarrow\mathbf{Z}^+_0\f$ denote the lower and 357 upper bounds for the flow values on the arcs, for which 358 \f$0 \leq lower(uv) \leq upper(uv)\f$ holds for all \f$uv\in A\f$. 359 \f$cost: A\rightarrow\mathbf{Z}^+_0\f$ denotes the cost per unit flow 360 on the arcs, and \f$sup: V\rightarrow\mathbf{Z}\f$ denotes the 361 signed supply values of the nodes. 362 If \f$sup(u)>0\f$, then \f$u\f$ is a supply node with \f$sup(u)\f$ 363 supply, if \f$sup(u)<0\f$, then \f$u\f$ is a demand node with 364 \f$-sup(u)\f$ demand. 365 A minimum cost flow is an \f$f: A\rightarrow\mathbf{Z}^+_0\f$ solution 366 of the following optimization problem. 367 368 \f[ \min\sum_{uv\in A} f(uv) \cdot cost(uv) \f] 369 \f[ \sum_{uv\in A} f(uv) - \sum_{vu\in A} f(vu) \geq 370 sup(u) \quad \forall u\in V \f] 371 \f[ lower(uv) \leq f(uv) \leq upper(uv) \quad \forall uv\in A \f] 372 373 The sum of the supply values, i.e. \f$\sum_{u\in V} sup(u)\f$ must be 374 zero or negative in order to have a feasible solution (since the sum 375 of the expressions on the left-hand side of the inequalities is zero). 376 It means that the total demand must be greater or equal to the total 377 supply and all the supplies have to be carried out from the supply nodes, 378 but there could be demands that are not satisfied. 379 If \f$\sum_{u\in V} sup(u)\f$ is zero, then all the supply/demand 380 constraints have to be satisfied with equality, i.e. all demands 381 have to be satisfied and all supplies have to be used. 382 383 If you need the opposite inequalities in the supply/demand constraints 384 (i.e. the total demand is less than the total supply and all the demands 385 have to be satisfied while there could be supplies that are not used), 386 then you could easily transform the problem to the above form by reversing 387 the direction of the arcs and taking the negative of the supply values 388 (e.g. using \ref ReverseDigraph and \ref NegMap adaptors). 389 However \ref NetworkSimplex algorithm also supports this form directly 390 for the sake of convenience. 391 392 A feasible solution for this problem can be found using \ref Circulation. 393 394 Note that the above formulation is actually more general than the usual 395 definition of the minimum cost flow problem, in which strict equalities 396 are required in the supply/demand contraints, i.e. 397 398 \f[ \sum_{uv\in A} f(uv) - \sum_{vu\in A} f(vu) = 399 sup(u) \quad \forall u\in V. \f] 400 401 However if the sum of the supply values is zero, then these two problems 402 are equivalent. So if you need the equality form, you have to ensure this 403 additional contraint for the algorithms. 404 405 The dual solution of the minimum cost flow problem is represented by node 406 potentials \f$\pi: V\rightarrow\mathbf{Z}\f$. 407 An \f$f: A\rightarrow\mathbf{Z}^+_0\f$ feasible solution of the problem 408 is optimal if and only if for some \f$\pi: V\rightarrow\mathbf{Z}\f$ 409 node potentials the following \e complementary \e slackness optimality 410 conditions hold. 411 412 - For all \f$uv\in A\f$ arcs: 413 - if \f$cost^\pi(uv)>0\f$, then \f$f(uv)=lower(uv)\f$; 414 - if \f$lower(uv)<f(uv)<upper(uv)\f$, then \f$cost^\pi(uv)=0\f$; 415 - if \f$cost^\pi(uv)<0\f$, then \f$f(uv)=upper(uv)\f$. 416 - For all \f$u\in V\f$: 417 - if \f$\sum_{uv\in A} f(uv) - \sum_{vu\in A} f(vu) \neq sup(u)\f$, 418 then \f$\pi(u)=0\f$. 419 420 Here \f$cost^\pi(uv)\f$ denotes the \e reduced \e cost of the arc 421 \f$uv\in A\f$ with respect to the node potentials \f$\pi\f$, i.e. 422 \f[ cost^\pi(uv) = cost(uv) + \pi(u) - \pi(v).\f] 423 424 All algorithms provide dual solution (node potentials) as well 425 if an optimal flow is found. 426 427 LEMON contains several algorithms for solving minimum cost flow problems. 428 - \ref NetworkSimplex Primal Network Simplex algorithm with various 429 pivot strategies. 430 - \ref CostScaling Push-Relabel and Augment-Relabel algorithms based on 431 cost scaling. 432 - \ref CapacityScaling Successive Shortest %Path algorithm with optional 433 capacity scaling. 434 - \ref CancelAndTighten The Cancel and Tighten algorithm. 435 - \ref CycleCanceling Cycle-Canceling algorithms. 436 437 Most of these implementations support the general inequality form of the 438 minimum cost flow problem, but CancelAndTighten and CycleCanceling 439 only support the equality form due to the primal method they use. 440 441 In general NetworkSimplex is the most efficient implementation, 442 but in special cases other algorithms could be faster. 443 For example, if the total supply and/or capacities are rather small, 444 CapacityScaling is usually the fastest algorithm (without effective scaling). 255 445 */ 256 446 … … 261 451 \brief Algorithms for finding minimum cut in graphs. 262 452 263 This group describes the algorithms for finding minimum cut in graphs.264 265 The minimum cutproblem is to find a non-empty and non-complete266 \f$X\f$ subset of the vertices with minimum overall capacity on267 outgoing arcs. Formally, there is \f$G=(V,A)\f$ directed graph, an268 \f$c _a:A\rightarrow\mathbf{R}^+_0\f$ capacity function. The minimum453 This group contains the algorithms for finding minimum cut in graphs. 454 455 The \e minimum \e cut \e problem is to find a non-empty and non-complete 456 \f$X\f$ subset of the nodes with minimum overall capacity on 457 outgoing arcs. Formally, there is a \f$G=(V,A)\f$ digraph, a 458 \f$cap: A\rightarrow\mathbf{R}^+_0\f$ capacity function. The minimum 269 459 cut is the \f$X\f$ solution of the next optimization problem: 270 460 271 461 \f[ \min_{X \subset V, X\not\in \{\emptyset, V\}} 272 \sum_{uv\in A, u\in X, v\not\in X}c_{uv}\f]462 \sum_{uv\in A, u\in X, v\not\in X}cap(uv) \f] 273 463 274 464 LEMON contains several algorithms related to minimum cut problems: 275 465 276 - \ref lemon::HaoOrlin "Hao-Orlin algorithm" to calculateminimum cut277 in directed graphs 278 - \ref lemon::NagamochiIbaraki "Nagamochi-Ibaraki algorithm" to279 calculat e minimum cut in undirected graphs280 - \ref lemon::GomoryHuTree "Gomory-Hu tree computation" to calculate all281 pairs minimum cut in undirected graphs466 - \ref HaoOrlin "Hao-Orlin algorithm" for calculating minimum cut 467 in directed graphs. 468 - \ref NagamochiIbaraki "Nagamochi-Ibaraki algorithm" for 469 calculating minimum cut in undirected graphs. 470 - \ref GomoryHu "Gomory-Hu tree computation" for calculating 471 all-pairs minimum cut in undirected graphs. 282 472 283 473 If you want to find minimum cut just between two distinict nodes, 284 please see the \ref max_flow "Maximum Flow page".285 */ 286 287 /** 288 @defgroup graph_prop Connectivity and Other Graph Properties474 see the \ref max_flow "maximum flow problem". 475 */ 476 477 /** 478 @defgroup graph_properties Connectivity and Other Graph Properties 289 479 @ingroup algs 290 480 \brief Algorithms for discovering the graph properties 291 481 292 This group describes the algorithms for discovering the graph properties482 This group contains the algorithms for discovering the graph properties 293 483 like connectivity, bipartiteness, euler property, simplicity etc. 294 484 … … 302 492 \brief Algorithms for planarity checking, embedding and drawing 303 493 304 This group describes the algorithms for planarity checking,494 This group contains the algorithms for planarity checking, 305 495 embedding and drawing. 306 496 … … 314 504 \brief Algorithms for finding matchings in graphs and bipartite graphs. 315 505 316 This group contains algorithm objects and functions to calculate506 This group contains the algorithms for calculating 317 507 matchings in graphs and bipartite graphs. The general matching problem is 318 finding a subset of the arcs which does not shares common endpoints. 508 finding a subset of the edges for which each node has at most one incident 509 edge. 319 510 320 511 There are several different algorithms for calculate matchings in 321 512 graphs. The matching problems in bipartite graphs are generally 322 513 easier than in general graphs. The goal of the matching optimization 323 can be thefinding maximum cardinality, maximum weight or minimum cost514 can be finding maximum cardinality, maximum weight or minimum cost 324 515 matching. The search can be constrained to find perfect or 325 516 maximum cardinality matching. 326 517 327 LEMON contains the next algorithms: 328 - \ref lemon::MaxBipartiteMatching "MaxBipartiteMatching" Hopcroft-Karp 329 augmenting path algorithm for calculate maximum cardinality matching in 330 bipartite graphs 331 - \ref lemon::PrBipartiteMatching "PrBipartiteMatching" Push-Relabel 332 algorithm for calculate maximum cardinality matching in bipartite graphs 333 - \ref lemon::MaxWeightedBipartiteMatching "MaxWeightedBipartiteMatching" 334 Successive shortest path algorithm for calculate maximum weighted matching 335 and maximum weighted bipartite matching in bipartite graph 336 - \ref lemon::MinCostMaxBipartiteMatching "MinCostMaxBipartiteMatching" 337 Successive shortest path algorithm for calculate minimum cost maximum 338 matching in bipartite graph 339 - \ref lemon::MaxMatching "MaxMatching" Edmond's blossom shrinking algorithm 340 for calculate maximum cardinality matching in general graph 341 - \ref lemon::MaxWeightedMatching "MaxWeightedMatching" Edmond's blossom 342 shrinking algorithm for calculate maximum weighted matching in general 343 graph 344 - \ref lemon::MaxWeightedPerfectMatching "MaxWeightedPerfectMatching" 345 Edmond's blossom shrinking algorithm for calculate maximum weighted 346 perfect matching in general graph 518 The matching algorithms implemented in LEMON: 519 - \ref MaxBipartiteMatching Hopcroft-Karp augmenting path algorithm 520 for calculating maximum cardinality matching in bipartite graphs. 521 - \ref PrBipartiteMatching Push-relabel algorithm 522 for calculating maximum cardinality matching in bipartite graphs. 523 - \ref MaxWeightedBipartiteMatching 524 Successive shortest path algorithm for calculating maximum weighted 525 matching and maximum weighted bipartite matching in bipartite graphs. 526 - \ref MinCostMaxBipartiteMatching 527 Successive shortest path algorithm for calculating minimum cost maximum 528 matching in bipartite graphs. 529 - \ref MaxMatching Edmond's blossom shrinking algorithm for calculating 530 maximum cardinality matching in general graphs. 531 - \ref MaxWeightedMatching Edmond's blossom shrinking algorithm for calculating 532 maximum weighted matching in general graphs. 533 - \ref MaxWeightedPerfectMatching 534 Edmond's blossom shrinking algorithm for calculating maximum weighted 535 perfect matching in general graphs. 347 536 348 537 \image html bipartite_matching.png … … 355 544 \brief Algorithms for finding a minimum cost spanning tree in a graph. 356 545 357 This group describes the algorithms for finding a minimum cost spanning358 tree in a graph 546 This group contains the algorithms for finding a minimum cost spanning 547 tree in a graph. 359 548 */ 360 549 … … 364 553 \brief Auxiliary algorithms implemented in LEMON. 365 554 366 This group describes some algorithms implemented in LEMON555 This group contains some algorithms implemented in LEMON 367 556 in order to make it easier to implement complex algorithms. 368 557 */ … … 373 562 \brief Approximation algorithms. 374 563 375 This group describes the approximation and heuristic algorithms564 This group contains the approximation and heuristic algorithms 376 565 implemented in LEMON. 377 566 */ … … 379 568 /** 380 569 @defgroup gen_opt_group General Optimization Tools 381 \brief This group describes some general optimization frameworks570 \brief This group contains some general optimization frameworks 382 571 implemented in LEMON. 383 572 384 This group describes some general optimization frameworks573 This group contains some general optimization frameworks 385 574 implemented in LEMON. 386 575 */ … … 391 580 \brief Lp and Mip solver interfaces for LEMON. 392 581 393 This group describes Lp and Mip solver interfaces for LEMON. The582 This group contains Lp and Mip solver interfaces for LEMON. The 394 583 various LP solvers could be used in the same manner with this 395 584 interface. … … 410 599 \brief Metaheuristics for LEMON library. 411 600 412 This group describes some metaheuristic optimization tools.601 This group contains some metaheuristic optimization tools. 413 602 */ 414 603 … … 425 614 \brief Simple basic graph utilities. 426 615 427 This group describes some simple basic graph utilities.616 This group contains some simple basic graph utilities. 428 617 */ 429 618 … … 433 622 \brief Tools for development, debugging and testing. 434 623 435 This group describes several useful tools for development,624 This group contains several useful tools for development, 436 625 debugging and testing. 437 626 */ … … 442 631 \brief Simple tools for measuring the performance of algorithms. 443 632 444 This group describes simple tools for measuring the performance633 This group contains simple tools for measuring the performance 445 634 of algorithms. 446 635 */ … … 451 640 \brief Exceptions defined in LEMON. 452 641 453 This group describes the exceptions defined in LEMON.642 This group contains the exceptions defined in LEMON. 454 643 */ 455 644 … … 458 647 \brief Graph Input-Output methods 459 648 460 This group describes the tools for importing and exporting graphs649 This group contains the tools for importing and exporting graphs 461 650 and graph related data. Now it supports the \ref lgf-format 462 651 "LEMON Graph Format", the \c DIMACS format and the encapsulated … … 465 654 466 655 /** 467 @defgroup lemon_io LEMON Input-Output656 @defgroup lemon_io LEMON Graph Format 468 657 @ingroup io_group 469 658 \brief Reading and writing LEMON Graph Format. 470 659 471 This group describes methods for reading and writing660 This group contains methods for reading and writing 472 661 \ref lgf-format "LEMON Graph Format". 473 662 */ … … 478 667 \brief General \c EPS drawer and graph exporter 479 668 480 This group describes general \c EPS drawing methods and special669 This group contains general \c EPS drawing methods and special 481 670 graph exporting tools. 671 */ 672 673 /** 674 @defgroup dimacs_group DIMACS format 675 @ingroup io_group 676 \brief Read and write files in DIMACS format 677 678 Tools to read a digraph from or write it to a file in DIMACS format data. 679 */ 680 681 /** 682 @defgroup nauty_group NAUTY Format 683 @ingroup io_group 684 \brief Read \e Nauty format 685 686 Tool to read graphs from \e Nauty format data. 482 687 */ 483 688 … … 486 691 \brief Skeleton classes and concept checking classes 487 692 488 This group describes the data/algorithm skeletons and concept checking693 This group contains the data/algorithm skeletons and concept checking 489 694 classes implemented in LEMON. 490 695 … … 516 721 \brief Skeleton and concept checking classes for graph structures 517 722 518 This group describes the skeletons and concept checking classes of LEMON's723 This group contains the skeletons and concept checking classes of LEMON's 519 724 graph structures and helper classes used to implement these. 520 725 */ … … 525 730 \brief Skeleton and concept checking classes for maps 526 731 527 This group describes the skeletons and concept checking classes of maps.732 This group contains the skeletons and concept checking classes of maps. 528 733 */ 529 734 … … 531 736 \anchor demoprograms 532 737 533 @defgroup demos Demo programs738 @defgroup demos Demo Programs 534 739 535 740 Some demo programs are listed here. Their full source codes can be found in 536 741 the \c demo subdirectory of the source tree. 537 742 538 I t order to compile them, use <tt>--enable-demo</tt> configure option when539 build the library.540 */ 541 542 /** 543 @defgroup tools Standalone utility applications743 In order to compile them, use the <tt>make demo</tt> or the 744 <tt>make check</tt> commands. 745 */ 746 747 /** 748 @defgroup tools Standalone Utility Applications 544 749 545 750 Some utility applications are listed here. … … 549 754 */ 550 755 756 } -
doc/lgf.dox
r313 r463 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). -
doc/license.dox
r209 r463 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). -
doc/mainpage.dox
r314 r606 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 46 46 "Quick Tour to LEMON" which will guide you along. 47 47 48 If you already feel like using our library, see the page that tells you 49 \ref getstart "How to start using LEMON". 50 51 If you 52 want to see how LEMON works, see 53 some \ref demoprograms "demo programs". 48 If you already feel like using our library, see the 49 <a class="el" href="http://lemon.cs.elte.hu/pub/tutorial/">LEMON Tutorial</a>. 54 50 55 51 If you know what you are looking for then try to find it under the 56 <a class="el" href="modules.html">Modules</a> 57 section. 52 <a class="el" href="modules.html">Modules</a> section. 58 53 59 54 If you are a user of the old (0.x) series of LEMON, please check out the -
doc/migration.dox
r314 r463 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 26 26 27 27 Many of these changes adjusted automatically by the 28 <tt> script/lemon-0.x-to-1.x.sh</tt> tool. Those requiring manual28 <tt>lemon-0.x-to-1.x.sh</tt> tool. Those requiring manual 29 29 update are typeset <b>boldface</b>. 30 30 … … 54 54 55 55 \warning 56 <b>The <tt>script/lemon-0.x-to-1.x.sh</tt> tool replaces all instances of 57 the words \c graph, \c digraph, \c edge and \c arc, so it replaces them 58 in strings, comments etc. as well as in all identifiers.</b> 56 <b>The <tt>lemon-0.x-to-1.x.sh</tt> script replaces the words \c graph, 57 \c ugraph, \c edge and \c uedge in your own identifiers and in 58 strings, comments etc. as well as in all LEMON specific identifiers. 59 So use the script carefully and make a backup copy of your source files 60 before applying the script to them.</b> 59 61 60 62 \section migration-lgf LGF tools -
doc/named-param.dox
r269 r463 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). -
doc/namespaces.dox
r209 r463 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). -
doc/template.h
r209 r463 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). -
lemon/CMakeLists.txt
r511 r674 1 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}) 1 INCLUDE_DIRECTORIES( 2 ${PROJECT_SOURCE_DIR} 3 ${PROJECT_BINARY_DIR} 4 ) 2 5 3 ADD_LIBRARY(lemon 6 CONFIGURE_FILE( 7 ${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake 8 ${CMAKE_CURRENT_BINARY_DIR}/config.h 9 ) 10 11 SET(LEMON_SOURCES 4 12 arg_parser.cc 5 13 base.cc 6 14 color.cc 15 lp_base.cc 16 lp_skeleton.cc 7 17 random.cc 8 18 bits/windows.cc 9 19 ) 20 21 IF(LEMON_HAVE_GLPK) 22 SET(LEMON_SOURCES ${LEMON_SOURCES} glpk.cc) 23 INCLUDE_DIRECTORIES(${GLPK_INCLUDE_DIRS}) 24 IF(WIN32) 25 INSTALL(FILES ${GLPK_BIN_DIR}/glpk.dll DESTINATION bin) 26 INSTALL(FILES ${GLPK_BIN_DIR}/libltdl3.dll DESTINATION bin) 27 INSTALL(FILES ${GLPK_BIN_DIR}/zlib1.dll DESTINATION bin) 28 ENDIF(WIN32) 29 ENDIF(LEMON_HAVE_GLPK) 30 31 IF(LEMON_HAVE_CPLEX) 32 SET(LEMON_SOURCES ${LEMON_SOURCES} cplex.cc) 33 INCLUDE_DIRECTORIES(${CPLEX_INCLUDE_DIRS}) 34 ENDIF(LEMON_HAVE_CPLEX) 35 36 IF(LEMON_HAVE_CLP) 37 SET(LEMON_SOURCES ${LEMON_SOURCES} clp.cc) 38 INCLUDE_DIRECTORIES(${COIN_INCLUDE_DIRS}) 39 ENDIF(LEMON_HAVE_CLP) 40 41 IF(LEMON_HAVE_CBC) 42 SET(LEMON_SOURCES ${LEMON_SOURCES} cbc.cc) 43 INCLUDE_DIRECTORIES(${COIN_INCLUDE_DIRS}) 44 ENDIF(LEMON_HAVE_CBC) 45 46 ADD_LIBRARY(lemon ${LEMON_SOURCES}) 10 47 11 48 INSTALL( … … 19 56 COMPONENT headers 20 57 FILES_MATCHING PATTERN "*.h") 58 59 INSTALL( 60 FILES ${CMAKE_CURRENT_BINARY_DIR}/config.h 61 DESTINATION include/lemon 62 COMPONENT headers) -
lemon/Makefile.am
r511 r674 8 8 9 9 lemon_libemon_la_SOURCES = \ 10 lemon/arg_parser.cc \ 11 lemon/base.cc \ 12 lemon/color.cc \ 13 lemon/random.cc \ 10 lemon/arg_parser.cc \ 11 lemon/base.cc \ 12 lemon/color.cc \ 13 lemon/lp_base.cc \ 14 lemon/lp_skeleton.cc \ 15 lemon/random.cc \ 14 16 lemon/bits/windows.cc 15 17 16 #lemon_libemon_la_CXXFLAGS = $(GLPK_CFLAGS) $(CPLEX_CFLAGS) $(SOPLEX_CXXFLAGS) 17 #lemon_libemon_la_LDFLAGS = $(GLPK_LIBS) $(CPLEX_LIBS) $(SOPLEX_LIBS) 18 19 lemon_libemon_la_CXXFLAGS = \ 20 $(AM_CXXFLAGS) \ 21 $(GLPK_CFLAGS) \ 22 $(CPLEX_CFLAGS) \ 23 $(SOPLEX_CXXFLAGS) \ 24 $(CLP_CXXFLAGS) \ 25 $(CBC_CXXFLAGS) 26 27 lemon_libemon_la_LDFLAGS = \ 28 $(GLPK_LIBS) \ 29 $(CPLEX_LIBS) \ 30 $(SOPLEX_LIBS) \ 31 $(CLP_LIBS) \ 32 $(CBC_LIBS) 33 34 if HAVE_GLPK 35 lemon_libemon_la_SOURCES += lemon/glpk.cc 36 endif 37 38 if HAVE_CPLEX 39 lemon_libemon_la_SOURCES += lemon/cplex.cc 40 endif 41 42 if HAVE_SOPLEX 43 lemon_libemon_la_SOURCES += lemon/soplex.cc 44 endif 45 46 if HAVE_CLP 47 lemon_libemon_la_SOURCES += lemon/clp.cc 48 endif 49 50 if HAVE_CBC 51 lemon_libemon_la_SOURCES += lemon/cbc.cc 52 endif 18 53 19 54 lemon_HEADERS += \ 20 lemon/arg_parser.h \ 55 lemon/adaptors.h \ 56 lemon/arg_parser.h \ 21 57 lemon/assert.h \ 22 lemon/bfs.h \ 23 lemon/bin_heap.h \ 24 lemon/color.h \ 58 lemon/bfs.h \ 59 lemon/bin_heap.h \ 60 lemon/circulation.h \ 61 lemon/clp.h \ 62 lemon/color.h \ 25 63 lemon/concept_check.h \ 26 lemon/counter.h \ 64 lemon/config.h \ 65 lemon/connectivity.h \ 66 lemon/counter.h \ 27 67 lemon/core.h \ 28 lemon/dfs.h \ 29 lemon/dijkstra.h \ 30 lemon/dim2.h \ 68 lemon/cplex.h \ 69 lemon/dfs.h \ 70 lemon/dijkstra.h \ 71 lemon/dim2.h \ 72 lemon/dimacs.h \ 73 lemon/edge_set.h \ 74 lemon/elevator.h \ 31 75 lemon/error.h \ 32 lemon/graph_to_eps.h \ 76 lemon/euler.h \ 77 lemon/full_graph.h \ 78 lemon/glpk.h \ 79 lemon/gomory_hu.h \ 80 lemon/graph_to_eps.h \ 81 lemon/grid_graph.h \ 82 lemon/hypercube_graph.h \ 33 83 lemon/kruskal.h \ 84 lemon/hao_orlin.h \ 34 85 lemon/lgf_reader.h \ 35 86 lemon/lgf_writer.h \ 36 87 lemon/list_graph.h \ 88 lemon/lp.h \ 89 lemon/lp_base.h \ 90 lemon/lp_skeleton.h \ 91 lemon/list_graph.h \ 37 92 lemon/maps.h \ 93 lemon/matching.h \ 38 94 lemon/math.h \ 95 lemon/min_cost_arborescence.h \ 96 lemon/nauty_reader.h \ 97 lemon/network_simplex.h \ 39 98 lemon/path.h \ 40 lemon/random.h \ 99 lemon/preflow.h \ 100 lemon/radix_sort.h \ 101 lemon/random.h \ 41 102 lemon/smart_graph.h \ 42 lemon/time_measure.h \ 43 lemon/tolerance.h \ 103 lemon/soplex.h \ 104 lemon/suurballe.h \ 105 lemon/time_measure.h \ 106 lemon/tolerance.h \ 44 107 lemon/unionfind.h \ 45 108 lemon/bits/windows.h … … 49 112 lemon/bits/array_map.h \ 50 113 lemon/bits/base_extender.h \ 51 114 lemon/bits/bezier.h \ 52 115 lemon/bits/default_map.h \ 53 lemon/bits/enable_if.h \ 116 lemon/bits/edge_set_extender.h \ 117 lemon/bits/enable_if.h \ 118 lemon/bits/graph_adaptor_extender.h \ 54 119 lemon/bits/graph_extender.h \ 55 120 lemon/bits/map_extender.h \ 56 121 lemon/bits/path_dump.h \ 122 lemon/bits/solver_bits.h \ 57 123 lemon/bits/traits.h \ 124 lemon/bits/variant.h \ 58 125 lemon/bits/vector_map.h 59 126 -
lemon/arg_parser.cc
r311 r463 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). -
lemon/arg_parser.h
r311 r463 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). -
lemon/assert.h
r290 r463 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). -
lemon/base.cc
r220 r554 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 24 24 namespace lemon { 25 25 26 float Tolerance<float>::def_epsilon = 1e-4;26 float Tolerance<float>::def_epsilon = static_cast<float>(1e-4); 27 27 double Tolerance<double>::def_epsilon = 1e-10; 28 28 long double Tolerance<long double>::def_epsilon = 1e-14; -
lemon/bfs.h
r301 r525 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 50 50 ///It must meet the \ref concepts::WriteMap "WriteMap" concept. 51 51 typedef typename Digraph::template NodeMap<typename Digraph::Arc> PredMap; 52 ///Instantiates a PredMap.53 54 ///This function instantiates a PredMap.52 ///Instantiates a \c PredMap. 53 54 ///This function instantiates a \ref PredMap. 55 55 ///\param g is the digraph, to which we would like to define the 56 /// PredMap.56 ///\ref PredMap. 57 57 static PredMap *createPredMap(const Digraph &g) 58 58 { … … 65 65 ///It must meet the \ref concepts::WriteMap "WriteMap" concept. 66 66 typedef NullMap<typename Digraph::Node,bool> ProcessedMap; 67 ///Instantiates a ProcessedMap.68 69 ///This function instantiates a ProcessedMap.67 ///Instantiates a \c ProcessedMap. 68 69 ///This function instantiates a \ref ProcessedMap. 70 70 ///\param g is the digraph, to which 71 ///we would like to define the ProcessedMap71 ///we would like to define the \ref ProcessedMap 72 72 #ifdef DOXYGEN 73 73 static ProcessedMap *createProcessedMap(const Digraph &g) … … 84 84 ///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept. 85 85 typedef typename Digraph::template NodeMap<bool> ReachedMap; 86 ///Instantiates a ReachedMap.87 88 ///This function instantiates a ReachedMap.86 ///Instantiates a \c ReachedMap. 87 88 ///This function instantiates a \ref ReachedMap. 89 89 ///\param g is the digraph, to which 90 ///we would like to define the ReachedMap.90 ///we would like to define the \ref ReachedMap. 91 91 static ReachedMap *createReachedMap(const Digraph &g) 92 92 { … … 99 99 ///It must meet the \ref concepts::WriteMap "WriteMap" concept. 100 100 typedef typename Digraph::template NodeMap<int> DistMap; 101 ///Instantiates a DistMap.102 103 ///This function instantiates a DistMap.101 ///Instantiates a \c DistMap. 102 103 ///This function instantiates a \ref DistMap. 104 104 ///\param g is the digraph, to which we would like to define the 105 /// DistMap.105 ///\ref DistMap. 106 106 static DistMap *createDistMap(const Digraph &g) 107 107 { … … 120 120 /// 121 121 ///\tparam GR The type of the digraph the algorithm runs on. 122 ///The default value is \ref ListDigraph. The value of GR is not used 123 ///directly by \ref Bfs, it is only passed to \ref BfsDefaultTraits. 124 ///\tparam TR Traits class to set various data types used by the algorithm. 125 ///The default traits class is 126 ///\ref BfsDefaultTraits "BfsDefaultTraits<GR>". 127 ///See \ref BfsDefaultTraits for the documentation of 128 ///a Bfs traits class. 122 ///The default type is \ref ListDigraph. 129 123 #ifdef DOXYGEN 130 124 template <typename GR, … … 152 146 typedef PredMapPath<Digraph, PredMap> Path; 153 147 154 ///The traits class.148 ///The \ref BfsDefaultTraits "traits class" of the algorithm. 155 149 typedef TR Traits; 156 150 … … 214 208 typedef Bfs Create; 215 209 216 ///\name Named template parameters210 ///\name Named Template Parameters 217 211 218 212 ///@{ … … 228 222 }; 229 223 ///\brief \ref named-templ-param "Named parameter" for setting 230 /// PredMap type.224 ///\c PredMap type. 231 225 /// 232 226 ///\ref named-templ-param "Named parameter" for setting 233 ///PredMap type. 227 ///\c PredMap type. 228 ///It must meet the \ref concepts::WriteMap "WriteMap" concept. 234 229 template <class T> 235 230 struct SetPredMap : public Bfs< Digraph, SetPredMapTraits<T> > { … … 247 242 }; 248 243 ///\brief \ref named-templ-param "Named parameter" for setting 249 /// DistMap type.244 ///\c DistMap type. 250 245 /// 251 246 ///\ref named-templ-param "Named parameter" for setting 252 ///DistMap type. 247 ///\c DistMap type. 248 ///It must meet the \ref concepts::WriteMap "WriteMap" concept. 253 249 template <class T> 254 250 struct SetDistMap : public Bfs< Digraph, SetDistMapTraits<T> > { … … 266 262 }; 267 263 ///\brief \ref named-templ-param "Named parameter" for setting 268 /// ReachedMap type.264 ///\c ReachedMap type. 269 265 /// 270 266 ///\ref named-templ-param "Named parameter" for setting 271 ///ReachedMap type. 267 ///\c ReachedMap type. 268 ///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept. 272 269 template <class T> 273 270 struct SetReachedMap : public Bfs< Digraph, SetReachedMapTraits<T> > { … … 285 282 }; 286 283 ///\brief \ref named-templ-param "Named parameter" for setting 287 /// ProcessedMap type.284 ///\c ProcessedMap type. 288 285 /// 289 286 ///\ref named-templ-param "Named parameter" for setting 290 ///ProcessedMap type. 287 ///\c ProcessedMap type. 288 ///It must meet the \ref concepts::WriteMap "WriteMap" concept. 291 289 template <class T> 292 290 struct SetProcessedMap : public Bfs< Digraph, SetProcessedMapTraits<T> > { … … 303 301 }; 304 302 ///\brief \ref named-templ-param "Named parameter" for setting 305 /// ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>.303 ///\c ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>. 306 304 /// 307 305 ///\ref named-templ-param "Named parameter" for setting 308 /// ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>.306 ///\c ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>. 309 307 ///If you don't set it explicitly, it will be automatically allocated. 310 308 struct SetStandardProcessedMap : … … 341 339 342 340 ///Sets the map that stores the predecessor arcs. 343 ///If you don't use this function before calling \ref run(), 344 ///it will allocate one. The destructor deallocates this 345 ///automatically allocated map, of course. 341 ///If you don't use this function before calling \ref run(Node) "run()" 342 ///or \ref init(), an instance will be allocated automatically. 343 ///The destructor deallocates this automatically allocated map, 344 ///of course. 346 345 ///\return <tt> (*this) </tt> 347 346 Bfs &predMap(PredMap &m) … … 358 357 359 358 ///Sets the map that indicates which nodes are reached. 360 ///If you don't use this function before calling \ref run(), 361 ///it will allocate one. The destructor deallocates this 362 ///automatically allocated map, of course. 359 ///If you don't use this function before calling \ref run(Node) "run()" 360 ///or \ref init(), an instance will be allocated automatically. 361 ///The destructor deallocates this automatically allocated map, 362 ///of course. 363 363 ///\return <tt> (*this) </tt> 364 364 Bfs &reachedMap(ReachedMap &m) … … 375 375 376 376 ///Sets the map that indicates which nodes are processed. 377 ///If you don't use this function before calling \ref run(), 378 ///it will allocate one. The destructor deallocates this 379 ///automatically allocated map, of course. 377 ///If you don't use this function before calling \ref run(Node) "run()" 378 ///or \ref init(), an instance will be allocated automatically. 379 ///The destructor deallocates this automatically allocated map, 380 ///of course. 380 381 ///\return <tt> (*this) </tt> 381 382 Bfs &processedMap(ProcessedMap &m) … … 393 394 ///Sets the map that stores the distances of the nodes calculated by 394 395 ///the algorithm. 395 ///If you don't use this function before calling \ref run(), 396 ///it will allocate one. The destructor deallocates this 397 ///automatically allocated map, of course. 396 ///If you don't use this function before calling \ref run(Node) "run()" 397 ///or \ref init(), an instance will be allocated automatically. 398 ///The destructor deallocates this automatically allocated map, 399 ///of course. 398 400 ///\return <tt> (*this) </tt> 399 401 Bfs &distMap(DistMap &m) … … 409 411 public: 410 412 411 ///\name Execution control 412 ///The simplest way to execute the algorithm is to use 413 ///one of the member functions called \ref lemon::Bfs::run() "run()". 414 ///\n 415 ///If you need more control on the execution, first you must call 416 ///\ref lemon::Bfs::init() "init()", then you can add several source 417 ///nodes with \ref lemon::Bfs::addSource() "addSource()". 418 ///Finally \ref lemon::Bfs::start() "start()" will perform the 419 ///actual path computation. 413 ///\name Execution Control 414 ///The simplest way to execute the BFS algorithm is to use one of the 415 ///member functions called \ref run(Node) "run()".\n 416 ///If you need more control on the execution, first you have to call 417 ///\ref init(), then you can add several source nodes with 418 ///\ref addSource(). Finally the actual path computation can be 419 ///performed with one of the \ref start() functions. 420 420 421 421 ///@{ 422 422 423 ///\brief Initializes the internal data structures. 424 /// 423 425 ///Initializes the internal data structures. 424 425 ///Initializes the internal data structures.426 ///427 426 void init() 428 427 { … … 558 557 } 559 558 560 ///\brief Returns \c false if there are nodes 561 ///to be processed. 562 /// 563 ///Returns \c false if there are nodes 564 ///to be processed in the queue. 559 ///Returns \c false if there are nodes to be processed. 560 561 ///Returns \c false if there are nodes to be processed 562 ///in the queue. 565 563 bool emptyQueue() const { return _queue_tail==_queue_head; } 566 564 567 565 ///Returns the number of the nodes to be processed. 568 566 569 ///Returns the number of the nodes to be processed in the queue. 567 ///Returns the number of the nodes to be processed 568 ///in the queue. 570 569 int queueSize() const { return _queue_head-_queue_tail; } 571 570 … … 732 731 733 732 ///\name Query Functions 734 ///The result of the %BFS algorithm can be obtained using these733 ///The results of the BFS algorithm can be obtained using these 735 734 ///functions.\n 736 ///Either \ref lemon::Bfs::run() "run()" or \ref lemon::Bfs::start()737 /// "start()" must be calledbefore using them.735 ///Either \ref run(Node) "run()" or \ref start() should be called 736 ///before using them. 738 737 739 738 ///@{ … … 743 742 ///Returns the shortest path to a node. 744 743 /// 745 ///\warning \c t should be reach ablefrom the root(s).746 /// 747 ///\pre Either \ref run( ) or \ref start() must be called before748 /// using this function.744 ///\warning \c t should be reached from the root(s). 745 /// 746 ///\pre Either \ref run(Node) "run()" or \ref init() 747 ///must be called before using this function. 749 748 Path path(Node t) const { return Path(*G, *_pred, t); } 750 749 … … 753 752 ///Returns the distance of a node from the root(s). 754 753 /// 755 ///\warning If node \c v is not reach ablefrom the root(s), then754 ///\warning If node \c v is not reached from the root(s), then 756 755 ///the return value of this function is undefined. 757 756 /// 758 ///\pre Either \ref run( ) or \ref start() must be called before759 /// using this function.757 ///\pre Either \ref run(Node) "run()" or \ref init() 758 ///must be called before using this function. 760 759 int dist(Node v) const { return (*_dist)[v]; } 761 760 … … 764 763 ///This function returns the 'previous arc' of the shortest path 765 764 ///tree for the node \c v, i.e. it returns the last arc of a 766 ///shortest path from the root(s)to \c v. It is \c INVALID if \c v767 ///is not reach ablefrom the root(s) or if \c v is a root.765 ///shortest path from a root to \c v. It is \c INVALID if \c v 766 ///is not reached from the root(s) or if \c v is a root. 768 767 /// 769 768 ///The shortest path tree used here is equal to the shortest path 770 769 ///tree used in \ref predNode(). 771 770 /// 772 ///\pre Either \ref run( ) or \ref start() must be called before773 /// using this function.771 ///\pre Either \ref run(Node) "run()" or \ref init() 772 ///must be called before using this function. 774 773 Arc predArc(Node v) const { return (*_pred)[v];} 775 774 … … 778 777 ///This function returns the 'previous node' of the shortest path 779 778 ///tree for the node \c v, i.e. it returns the last but one node 780 ///from a shortest path from the root(s)to \c v. It is \c INVALID781 ///if \c v is not reach ablefrom the root(s) or if \c v is a root.779 ///from a shortest path from a root to \c v. It is \c INVALID 780 ///if \c v is not reached from the root(s) or if \c v is a root. 782 781 /// 783 782 ///The shortest path tree used here is equal to the shortest path 784 783 ///tree used in \ref predArc(). 785 784 /// 786 ///\pre Either \ref run( ) or \ref start() must be called before787 /// using this function.785 ///\pre Either \ref run(Node) "run()" or \ref init() 786 ///must be called before using this function. 788 787 Node predNode(Node v) const { return (*_pred)[v]==INVALID ? INVALID: 789 788 G->source((*_pred)[v]); } … … 795 794 ///of the nodes calculated by the algorithm. 796 795 /// 797 ///\pre Either \ref run( )or \ref init()796 ///\pre Either \ref run(Node) "run()" or \ref init() 798 797 ///must be called before using this function. 799 798 const DistMap &distMap() const { return *_dist;} … … 805 804 ///arcs, which form the shortest path tree. 806 805 /// 807 ///\pre Either \ref run( )or \ref init()806 ///\pre Either \ref run(Node) "run()" or \ref init() 808 807 ///must be called before using this function. 809 808 const PredMap &predMap() const { return *_pred;} 810 809 811 ///Checks if a node is reachable from the root(s). 812 813 ///Returns \c true if \c v is reachable from the root(s). 814 ///\pre Either \ref run() or \ref start() 810 ///Checks if a node is reached from the root(s). 811 812 ///Returns \c true if \c v is reached from the root(s). 813 /// 814 ///\pre Either \ref run(Node) "run()" or \ref init() 815 815 ///must be called before using this function. 816 816 bool reached(Node v) const { return (*_reached)[v]; } … … 958 958 /// This auxiliary class is created to implement the 959 959 /// \ref bfs() "function-type interface" of \ref Bfs algorithm. 960 /// It does not have own \ref run( ) method, it uses the functions961 /// and features of the plain \ref Bfs.960 /// It does not have own \ref run(Node) "run()" method, it uses the 961 /// functions and features of the plain \ref Bfs. 962 962 /// 963 963 /// This class should only be used through the \ref bfs() function, … … 1179 1179 /// bool reached = bfs(g).path(p).dist(d).run(s,t); 1180 1180 ///\endcode 1181 ///\warning Don't forget to put the \ref BfsWizard::run( ) "run()"1181 ///\warning Don't forget to put the \ref BfsWizard::run(Node) "run()" 1182 1182 ///to the end of the parameter list. 1183 1183 ///\sa BfsWizard … … 1195 1195 /// This class defines the interface of the BfsVisit events, and 1196 1196 /// it could be the base of a real visitor class. 1197 template <typename _Digraph>1197 template <typename GR> 1198 1198 struct BfsVisitor { 1199 typedef _DigraphDigraph;1199 typedef GR Digraph; 1200 1200 typedef typename Digraph::Arc Arc; 1201 1201 typedef typename Digraph::Node Node; … … 1225 1225 }; 1226 1226 #else 1227 template <typename _Digraph>1227 template <typename GR> 1228 1228 struct BfsVisitor { 1229 typedef _DigraphDigraph;1229 typedef GR Digraph; 1230 1230 typedef typename Digraph::Arc Arc; 1231 1231 typedef typename Digraph::Node Node; … … 1255 1255 /// 1256 1256 /// Default traits class of BfsVisit class. 1257 /// \tparam _DigraphThe type of the digraph the algorithm runs on.1258 template<class _Digraph>1257 /// \tparam GR The type of the digraph the algorithm runs on. 1258 template<class GR> 1259 1259 struct BfsVisitDefaultTraits { 1260 1260 1261 1261 /// \brief The type of the digraph the algorithm runs on. 1262 typedef _DigraphDigraph;1262 typedef GR Digraph; 1263 1263 1264 1264 /// \brief The type of the map that indicates which nodes are reached. … … 1281 1281 /// \ingroup search 1282 1282 /// 1283 /// \brief %BFS algorithm class with visitor interface.1283 /// \brief BFS algorithm class with visitor interface. 1284 1284 /// 1285 /// This class provides an efficient implementation of the %BFS algorithm1285 /// This class provides an efficient implementation of the BFS algorithm 1286 1286 /// with visitor interface. 1287 1287 /// 1288 /// The %BfsVisit class provides an alternative interface to the Bfs1288 /// The BfsVisit class provides an alternative interface to the Bfs 1289 1289 /// class. It works with callback mechanism, the BfsVisit object calls 1290 1290 /// the member functions of the \c Visitor class on every BFS event. … … 1295 1295 /// instead. 1296 1296 /// 1297 /// \tparam _DigraphThe type of the digraph the algorithm runs on.1298 /// The default value is1299 /// \ref ListDigraph. The value of _Digraph is not used directly by1300 /// \ref BfsVisit,it is only passed to \ref BfsVisitDefaultTraits.1301 /// \tparam _VisitorThe Visitor type that is used by the algorithm.1302 /// \ref BfsVisitor "BfsVisitor< _Digraph>" is an empty visitor, which1297 /// \tparam GR The type of the digraph the algorithm runs on. 1298 /// The default type is \ref ListDigraph. 1299 /// The value of GR is not used directly by \ref BfsVisit, 1300 /// it is only passed to \ref BfsVisitDefaultTraits. 1301 /// \tparam VS The Visitor type that is used by the algorithm. 1302 /// \ref BfsVisitor "BfsVisitor<GR>" is an empty visitor, which 1303 1303 /// does not observe the BFS events. If you want to observe the BFS 1304 1304 /// events, you should implement your own visitor class. 1305 /// \tparam _TraitsTraits class to set various data types used by the1305 /// \tparam TR Traits class to set various data types used by the 1306 1306 /// algorithm. The default traits class is 1307 /// \ref BfsVisitDefaultTraits "BfsVisitDefaultTraits< _Digraph>".1307 /// \ref BfsVisitDefaultTraits "BfsVisitDefaultTraits<GR>". 1308 1308 /// See \ref BfsVisitDefaultTraits for the documentation of 1309 1309 /// a BFS visit traits class. 1310 1310 #ifdef DOXYGEN 1311 template <typename _Digraph, typename _Visitor, typename _Traits>1311 template <typename GR, typename VS, typename TR> 1312 1312 #else 1313 template <typename _Digraph= ListDigraph,1314 typename _Visitor = BfsVisitor<_Digraph>,1315 typename _Traits = BfsVisitDefaultTraits<_Digraph> >1313 template <typename GR = ListDigraph, 1314 typename VS = BfsVisitor<GR>, 1315 typename TR = BfsVisitDefaultTraits<GR> > 1316 1316 #endif 1317 1317 class BfsVisit { … … 1319 1319 1320 1320 ///The traits class. 1321 typedef _TraitsTraits;1321 typedef TR Traits; 1322 1322 1323 1323 ///The type of the digraph the algorithm runs on. … … 1325 1325 1326 1326 ///The visitor type used by the algorithm. 1327 typedef _VisitorVisitor;1327 typedef VS Visitor; 1328 1328 1329 1329 ///The type of the map that indicates which nodes are reached. … … 1365 1365 typedef BfsVisit Create; 1366 1366 1367 /// \name Named template parameters1367 /// \name Named Template Parameters 1368 1368 1369 1369 ///@{ … … 1407 1407 /// 1408 1408 /// Sets the map that indicates which nodes are reached. 1409 /// If you don't use this function before calling \ref run(), 1410 /// it will allocate one. The destructor deallocates this 1411 /// automatically allocated map, of course. 1409 /// If you don't use this function before calling \ref run(Node) "run()" 1410 /// or \ref init(), an instance will be allocated automatically. 1411 /// The destructor deallocates this automatically allocated map, 1412 /// of course. 1412 1413 /// \return <tt> (*this) </tt> 1413 1414 BfsVisit &reachedMap(ReachedMap &m) { … … 1422 1423 public: 1423 1424 1424 /// \name Execution control 1425 /// The simplest way to execute the algorithm is to use 1426 /// one of the member functions called \ref lemon::BfsVisit::run() 1427 /// "run()". 1428 /// \n 1429 /// If you need more control on the execution, first you must call 1430 /// \ref lemon::BfsVisit::init() "init()", then you can add several 1431 /// source nodes with \ref lemon::BfsVisit::addSource() "addSource()". 1432 /// Finally \ref lemon::BfsVisit::start() "start()" will perform the 1433 /// actual path computation. 1425 /// \name Execution Control 1426 /// The simplest way to execute the BFS algorithm is to use one of the 1427 /// member functions called \ref run(Node) "run()".\n 1428 /// If you need more control on the execution, first you have to call 1429 /// \ref init(), then you can add several source nodes with 1430 /// \ref addSource(). Finally the actual path computation can be 1431 /// performed with one of the \ref start() functions. 1434 1432 1435 1433 /// @{ … … 1731 1729 1732 1730 /// \name Query Functions 1733 /// The result of the %BFS algorithm can be obtained using these1731 /// The results of the BFS algorithm can be obtained using these 1734 1732 /// functions.\n 1735 /// Either \ref lemon::BfsVisit::run() "run()" or1736 /// \ref lemon::BfsVisit::start() "start()" must be called before1737 /// using them. 1733 /// Either \ref run(Node) "run()" or \ref start() should be called 1734 /// before using them. 1735 1738 1736 ///@{ 1739 1737 1740 /// \brief Checks if a node is reachable from the root(s). 1741 /// 1742 /// Returns \c true if \c v is reachable from the root(s). 1743 /// \pre Either \ref run() or \ref start() 1738 /// \brief Checks if a node is reached from the root(s). 1739 /// 1740 /// Returns \c true if \c v is reached from the root(s). 1741 /// 1742 /// \pre Either \ref run(Node) "run()" or \ref init() 1744 1743 /// must be called before using this function. 1745 bool reached(Node v) { return (*_reached)[v]; }1744 bool reached(Node v) const { return (*_reached)[v]; } 1746 1745 1747 1746 ///@} -
lemon/bin_heap.h
r209 r631 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 34 34 ///\brief A Binary Heap implementation. 35 35 /// 36 ///This class implements the \e binary \e heap data structure. A \e heap 37 ///is a data structure for storing items with specified values called \e 38 ///priorities in such a way that finding the item with minimum priority is 39 ///efficient. \c Compare specifies the ordering of the priorities. In a heap 40 ///one can change the priority of an item, add or erase an item, etc. 36 ///This class implements the \e binary \e heap data structure. 37 /// 38 ///A \e heap is a data structure for storing items with specified values 39 ///called \e priorities in such a way that finding the item with minimum 40 ///priority is efficient. \c Comp specifies the ordering of the priorities. 41 ///In a heap one can change the priority of an item, add or erase an 42 ///item, etc. 41 43 /// 42 ///\tparam _PrioType of the priority of the items.43 ///\tparam _ItemIntMap A read and writable Item int map, used internally44 ///\tparam PR Type of the priority of the items. 45 ///\tparam IM A read and writable item map with int values, used internally 44 46 ///to handle the cross references. 45 ///\tparam _Compare A class for the ordering of the priorities. The46 /// default is \c std::less<_Prio>.47 ///\tparam Comp A functor class for the ordering of the priorities. 48 ///The default is \c std::less<PR>. 47 49 /// 48 50 ///\sa FibHeap 49 51 ///\sa Dijkstra 50 template <typename _Prio, typename _ItemIntMap, 51 typename _Compare = std::less<_Prio> > 52 template <typename PR, typename IM, typename Comp = std::less<PR> > 52 53 class BinHeap { 53 54 54 55 public: 55 56 ///\e 56 typedef _ItemIntMapItemIntMap;57 ///\e 58 typedef _PrioPrio;57 typedef IM ItemIntMap; 58 ///\e 59 typedef PR Prio; 59 60 ///\e 60 61 typedef typename ItemIntMap::Key Item; … … 62 63 typedef std::pair<Item,Prio> Pair; 63 64 ///\e 64 typedef _CompareCompare;65 typedef Comp Compare; 65 66 66 67 /// \brief Type to represent the items states. … … 70 71 /// heap's point of view, but may be useful to the user. 71 72 /// 72 /// The ItemIntMap \e should be initialized in such way that it maps73 /// PRE_HEAP (-1) to any element to be put in the heap...73 /// The item-int map must be initialized in such way that it assigns 74 /// \c PRE_HEAP (<tt>-1</tt>) to any element to be put in the heap. 74 75 enum State { 75 IN_HEAP = 0, 76 PRE_HEAP = -1, 77 POST_HEAP = -2 76 IN_HEAP = 0, ///< = 0. 77 PRE_HEAP = -1, ///< = -1. 78 POST_HEAP = -2 ///< = -2. 78 79 }; 79 80 80 81 private: 81 std::vector<Pair> data;82 Compare comp;83 ItemIntMap & iim;82 std::vector<Pair> _data; 83 Compare _comp; 84 ItemIntMap &_iim; 84 85 85 86 public: … … 87 88 /// 88 89 /// The constructor. 89 /// \param _iim should be given to the constructor, since it is used 90 /// \param map should be given to the constructor, since it is used 91 /// internally to handle the cross references. The value of the map 92 /// must be \c PRE_HEAP (<tt>-1</tt>) for every item. 93 explicit BinHeap(ItemIntMap &map) : _iim(map) {} 94 95 /// \brief The constructor. 96 /// 97 /// The constructor. 98 /// \param map should be given to the constructor, since it is used 90 99 /// internally to handle the cross references. The value of the map 91 100 /// should be PRE_HEAP (-1) for each element. 92 explicit BinHeap(ItemIntMap &_iim) : iim(_iim) {} 93 94 /// \brief The constructor. 95 /// 96 /// The constructor. 97 /// \param _iim should be given to the constructor, since it is used 98 /// internally to handle the cross references. The value of the map 99 /// should be PRE_HEAP (-1) for each element. 100 /// 101 /// \param _comp The comparator function object. 102 BinHeap(ItemIntMap &_iim, const Compare &_comp) 103 : iim(_iim), comp(_comp) {} 101 /// 102 /// \param comp The comparator function object. 103 BinHeap(ItemIntMap &map, const Compare &comp) 104 : _iim(map), _comp(comp) {} 104 105 105 106 … … 107 108 /// 108 109 /// \brief Returns the number of items stored in the heap. 109 int size() const { return data.size(); }110 int size() const { return _data.size(); } 110 111 111 112 /// \brief Checks if the heap stores no items. 112 113 /// 113 114 /// Returns \c true if and only if the heap stores no items. 114 bool empty() const { return data.empty(); }115 bool empty() const { return _data.empty(); } 115 116 116 117 /// \brief Make empty this heap. … … 121 122 /// each item to \c PRE_HEAP. 122 123 void clear() { 123 data.clear();124 _data.clear(); 124 125 } 125 126 … … 129 130 static int second_child(int i) { return 2*i+2; } 130 131 bool less(const Pair &p1, const Pair &p2) const { 131 return comp(p1.second, p2.second);132 return _comp(p1.second, p2.second); 132 133 } 133 134 134 135 int bubble_up(int hole, Pair p) { 135 136 int par = parent(hole); 136 while( hole>0 && less(p, data[par]) ) {137 move( data[par],hole);137 while( hole>0 && less(p,_data[par]) ) { 138 move(_data[par],hole); 138 139 hole = par; 139 140 par = parent(hole); … … 146 147 int child = second_child(hole); 147 148 while(child < length) { 148 if( less( data[child-1],data[child]) ) {149 if( less(_data[child-1], _data[child]) ) { 149 150 --child; 150 151 } 151 if( !less( data[child], p) )152 if( !less(_data[child], p) ) 152 153 goto ok; 153 move( data[child], hole);154 move(_data[child], hole); 154 155 hole = child; 155 156 child = second_child(hole); 156 157 } 157 158 child--; 158 if( child<length && less( data[child], p) ) {159 move( data[child], hole);159 if( child<length && less(_data[child], p) ) { 160 move(_data[child], hole); 160 161 hole=child; 161 162 } … … 166 167 167 168 void move(const Pair &p, int i) { 168 data[i] = p;169 iim.set(p.first, i);169 _data[i] = p; 170 _iim.set(p.first, i); 170 171 } 171 172 … … 176 177 /// \param p The pair to insert. 177 178 void push(const Pair &p) { 178 int n = data.size();179 data.resize(n+1);179 int n = _data.size(); 180 _data.resize(n+1); 180 181 bubble_up(n, p); 181 182 } … … 194 195 /// \pre The heap must be nonempty. 195 196 Item top() const { 196 return data[0].first;197 return _data[0].first; 197 198 } 198 199 … … 202 203 /// \pre The heap must be nonempty. 203 204 Prio prio() const { 204 return data[0].second;205 return _data[0].second; 205 206 } 206 207 … … 211 212 /// \pre The heap must be non-empty. 212 213 void pop() { 213 int n = data.size()-1;214 iim.set(data[0].first, POST_HEAP);214 int n = _data.size()-1; 215 _iim.set(_data[0].first, POST_HEAP); 215 216 if (n > 0) { 216 bubble_down(0, data[n], n);217 } 218 data.pop_back();217 bubble_down(0, _data[n], n); 218 } 219 _data.pop_back(); 219 220 } 220 221 … … 225 226 /// \pre The item should be in the heap. 226 227 void erase(const Item &i) { 227 int h = iim[i];228 int n = data.size()-1;229 iim.set(data[h].first, POST_HEAP);228 int h = _iim[i]; 229 int n = _data.size()-1; 230 _iim.set(_data[h].first, POST_HEAP); 230 231 if( h < n ) { 231 if ( bubble_up(h, data[n]) == h) {232 bubble_down(h, data[n], n);232 if ( bubble_up(h, _data[n]) == h) { 233 bubble_down(h, _data[n], n); 233 234 } 234 235 } 235 data.pop_back();236 _data.pop_back(); 236 237 } 237 238 … … 240 241 /// 241 242 /// This function returns the priority of item \c i. 243 /// \param i The item. 242 244 /// \pre \c i must be in the heap. 243 /// \param i The item.244 245 Prio operator[](const Item &i) const { 245 int idx = iim[i];246 return data[idx].second;246 int idx = _iim[i]; 247 return _data[idx].second; 247 248 } 248 249 … … 255 256 /// \param p The priority. 256 257 void set(const Item &i, const Prio &p) { 257 int idx = iim[i];258 int idx = _iim[i]; 258 259 if( idx < 0 ) { 259 260 push(i,p); 260 261 } 261 else if( comp(p,data[idx].second) ) {262 else if( _comp(p, _data[idx].second) ) { 262 263 bubble_up(idx, Pair(i,p)); 263 264 } 264 265 else { 265 bubble_down(idx, Pair(i,p), data.size());266 bubble_down(idx, Pair(i,p), _data.size()); 266 267 } 267 268 } … … 270 271 /// 271 272 /// This method decreases the priority of item \c i to \c p. 273 /// \param i The item. 274 /// \param p The priority. 272 275 /// \pre \c i must be stored in the heap with priority at least \c 273 276 /// p relative to \c Compare. 277 void decrease(const Item &i, const Prio &p) { 278 int idx = _iim[i]; 279 bubble_up(idx, Pair(i,p)); 280 } 281 282 /// \brief Increases the priority of \c i to \c p. 283 /// 284 /// This method sets the priority of item \c i to \c p. 274 285 /// \param i The item. 275 286 /// \param p The priority. 276 void decrease(const Item &i, const Prio &p) {277 int idx = iim[i];278 bubble_up(idx, Pair(i,p));279 }280 281 /// \brief Increases the priority of \c i to \c p.282 ///283 /// This method sets the priority of item \c i to \c p.284 287 /// \pre \c i must be stored in the heap with priority at most \c 285 288 /// p relative to \c Compare. 286 /// \param i The item.287 /// \param p The priority.288 289 void increase(const Item &i, const Prio &p) { 289 int idx = iim[i];290 bubble_down(idx, Pair(i,p), data.size());290 int idx = _iim[i]; 291 bubble_down(idx, Pair(i,p), _data.size()); 291 292 } 292 293 … … 300 301 /// \param i The item. 301 302 State state(const Item &i) const { 302 int s = iim[i];303 int s = _iim[i]; 303 304 if( s>=0 ) 304 305 s=0; … … 320 321 erase(i); 321 322 } 322 iim[i] = st;323 _iim[i] = st; 323 324 break; 324 325 case IN_HEAP: … … 334 335 /// with the same prioriority as prevoiusly the \c i item. 335 336 void replace(const Item& i, const Item& j) { 336 int idx = iim[i];337 iim.set(i,iim[j]);338 iim.set(j, idx);339 data[idx].first = j;337 int idx = _iim[i]; 338 _iim.set(i, _iim[j]); 339 _iim.set(j, idx); 340 _data[idx].first = j; 340 341 } 341 342 -
lemon/bits/alteration_notifier.h
r314 r463 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 36 36 // a container. 37 37 // 38 // The simple graph 's can be refered as two containers, onenode container39 // and one edge container. But they are not standard containersthey40 // does not store values directly they are just key continars for more41 // value containers which are thenode and edge maps.42 // 43 // The graph's node and edge sets can be changed as we add or erase38 // The simple graphs can be refered as two containers: a node container 39 // and an edge container. But they do not store values directly, they 40 // are just key continars for more value containers, which are the 41 // node and edge maps. 42 // 43 // The node and edge sets of the graphs can be changed as we add or erase 44 44 // nodes and edges in the graph. LEMON would like to handle easily 45 45 // that the node and edge maps should contain values for all nodes or 46 46 // edges. If we want to check on every indicing if the map contains 47 47 // the current indicing key that cause a drawback in the performance 48 // in the library. We use another solution we notify all maps about48 // in the library. We use another solution: we notify all maps about 49 49 // an alteration in the graph, which cause only drawback on the 50 50 // alteration of the graph. 51 51 // 52 // This class provides an interface to the container. The \e first() and \e 53 // next() member functions make possible to iterate on the keys of the 54 // container. The \e id() function returns an integer id for each key. 55 // The \e maxId() function gives back an upper bound of the ids. 52 // This class provides an interface to a node or edge container. 53 // The first() and next() member functions make possible 54 // to iterate on the keys of the container. 55 // The id() function returns an integer id for each key. 56 // The maxId() function gives back an upper bound of the ids. 56 57 // 57 58 // For the proper functonality of this class, we should notify it 58 // about each alteration in the container. The alterations have four type 59 // a s \e add(), \e erase(), \e build() and \e clear(). The \e add() and60 // \e erase() signalsthat only one or few items added or erased to or61 // from the graph. If all items are erased from the graph or from an empty62 // graph a new graph is buildedthen it can be signaled with the59 // about each alteration in the container. The alterations have four type: 60 // add(), erase(), build() and clear(). The add() and 61 // erase() signal that only one or few items added or erased to or 62 // from the graph. If all items are erased from the graph or if a new graph 63 // is built from an empty graph, then it can be signaled with the 63 64 // clear() and build() members. Important rule that if we erase items 64 // from graph we should first signal the alteration and after that erase65 // from graphs we should first signal the alteration and after that erase 65 66 // them from the container, on the other way on item addition we should 66 67 // first extend the container and just after that signal the alteration. 67 68 // 68 69 // The alteration can be observed with a class inherited from the 69 // \eObserverBase nested class. The signals can be handled with70 // ObserverBase nested class. The signals can be handled with 70 71 // overriding the virtual functions defined in the base class. The 71 72 // observer base can be attached to the notifier with the 72 // \eattach() member and can be detached with detach() function. The73 // attach() member and can be detached with detach() function. The 73 74 // alteration handlers should not call any function which signals 74 75 // an other alteration in the same notifier and should not 75 76 // detach any observer from the notifier. 76 77 // 77 // Alteration observers try to be exception safe. If an \eadd() or78 // a \eclear() function throws an exception then the remaining78 // Alteration observers try to be exception safe. If an add() or 79 // a clear() function throws an exception then the remaining 79 80 // observeres will not be notified and the fulfilled additions will 80 // be rolled back by calling the \e erase() or \e clear()81 // functions. Thence the \e erase() and \e clear() should not throw82 // exception. Actullay, it can be throw only \ref ImmediateDetach83 // exceptionwhich detach the observer from the notifier.84 // 85 // There are some placewhen the alteration observing is not completly81 // be rolled back by calling the erase() or clear() functions. 82 // Hence erase() and clear() should not throw exception. 83 // Actullay, they can throw only \ref ImmediateDetach exception, 84 // which detach the observer from the notifier. 85 // 86 // There are some cases, when the alteration observing is not completly 86 87 // reliable. If we want to carry out the node degree in the graph 87 // as in the \ref InDegMap and we use the reverse Edge that cause88 // as in the \ref InDegMap and we use the reverseArc(), then it cause 88 89 // unreliable functionality. Because the alteration observing signals 89 // only erasing and adding but not the reversing it will stores bad90 // degrees. The sub graph adaptors cannot signal the alterations because91 // just a setting in the filter map can modify the graph and this cannot92 // be watched in any way.90 // only erasing and adding but not the reversing, it will stores bad 91 // degrees. Apart form that the subgraph adaptors cannot even signal 92 // the alterations because just a setting in the filter map can modify 93 // the graph and this cannot be watched in any way. 93 94 // 94 95 // \param _Container The container which is observed. … … 104 105 typedef _Item Item; 105 106 106 // \brief Exception which can be called from \eclear() and107 // \eerase().108 // 109 // From the \e clear() and \eerase() function only this107 // \brief Exception which can be called from clear() and 108 // erase(). 109 // 110 // From the clear() and erase() function only this 110 111 // exception is allowed to throw. The exception immediatly 111 112 // detaches the current observer from the notifier. Because the 112 // \e clear() and \eerase() should not throw other exceptions113 // clear() and erase() should not throw other exceptions 113 114 // it can be used to invalidate the observer. 114 115 struct ImmediateDetach {}; … … 122 123 // The observer interface contains some pure virtual functions 123 124 // to override. The add() and erase() functions are 124 // to notify the oberver when one item is added or 125 // erased. 125 // to notify the oberver when one item is added or erased. 126 126 // 127 127 // The build() and clear() members are to notify the observer -
lemon/bits/array_map.h
r314 r664 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 37 37 // \brief Graph map based on the array storage. 38 38 // 39 // The ArrayMap template class is graph map structure what 40 // automatically updates the map when a key is added to or erased from 41 // the map. This map uses the allocators to implement 42 // the container functionality. 39 // The ArrayMap template class is graph map structure that automatically 40 // updates the map when a key is added to or erased from the graph. 41 // This map uses the allocators to implement the container functionality. 43 42 // 44 // The template parameters are the Graph the current Item type and43 // The template parameters are the Graph, the current Item type and 45 44 // the Value type of the map. 46 45 template <typename _Graph, typename _Item, typename _Value> … … 48 47 : public ItemSetTraits<_Graph, _Item>::ItemNotifier::ObserverBase { 49 48 public: 50 // The graph type of the maps.51 typedef _Graph Graph ;52 // The item type of the map.49 // The graph type. 50 typedef _Graph GraphType; 51 // The item type. 53 52 typedef _Item Item; 54 53 // The reference map tag. 55 54 typedef True ReferenceMapTag; 56 55 57 // The key type of the map s.56 // The key type of the map. 58 57 typedef _Item Key; 59 58 // The value type of the map. … … 65 64 typedef _Value& Reference; 66 65 66 // The map type. 67 typedef ArrayMap Map; 68 67 69 // The notifier type. 68 70 typedef typename ItemSetTraits<_Graph, _Item>::ItemNotifier Notifier; 69 71 72 private: 73 70 74 // The MapBase of the Map which imlements the core regisitry function. 71 75 typedef typename Notifier::ObserverBase Parent; 72 76 73 private:74 77 typedef std::allocator<Value> Allocator; 75 78 … … 79 82 // 80 83 // Graph initialized map constructor. 81 explicit ArrayMap(const Graph & graph) {84 explicit ArrayMap(const GraphType& graph) { 82 85 Parent::attach(graph.notifier(Item())); 83 86 allocate_memory(); … … 93 96 // 94 97 // It constructs a map and initialize all of the the map. 95 ArrayMap(const Graph & graph, const Value& value) {98 ArrayMap(const GraphType& graph, const Value& value) { 96 99 Parent::attach(graph.notifier(Item())); 97 100 allocate_memory(); … … 137 140 // \brief Template assign operator. 138 141 // 139 // The given parameter should beconform to the ReadMap142 // The given parameter should conform to the ReadMap 140 143 // concecpt and could be indiced by the current item set of 141 144 // the NodeMap. In this case the value for each item … … 201 204 // \brief Adds a new key to the map. 202 205 // 203 // It adds a new key to the map. It called by the observer notifier206 // It adds a new key to the map. It is called by the observer notifier 204 207 // and it overrides the add() member function of the observer base. 205 208 virtual void add(const Key& key) { … … 229 232 // \brief Adds more new keys to the map. 230 233 // 231 // It adds more new keys to the map. It called by the observer notifier234 // It adds more new keys to the map. It is called by the observer notifier 232 235 // and it overrides the add() member function of the observer base. 233 236 virtual void add(const std::vector<Key>& keys) { … … 273 276 // \brief Erase a key from the map. 274 277 // 275 // Erase a key from the map. It called by the observer notifier278 // Erase a key from the map. It is called by the observer notifier 276 279 // and it overrides the erase() member function of the observer base. 277 280 virtual void erase(const Key& key) { … … 282 285 // \brief Erase more keys from the map. 283 286 // 284 // Erase more keys from the map. It called by the observer notifier287 // Erase more keys from the map. It is called by the observer notifier 285 288 // and it overrides the erase() member function of the observer base. 286 289 virtual void erase(const std::vector<Key>& keys) { … … 291 294 } 292 295 293 // \brief Build es the map.294 // 295 // It build es the map. Itcalled by the observer notifier296 // \brief Builds the map. 297 // 298 // It builds the map. It is called by the observer notifier 296 299 // and it overrides the build() member function of the observer base. 297 300 virtual void build() { … … 307 310 // \brief Clear the map. 308 311 // 309 // It erase all items from the map. It called by the observer notifier312 // It erase all items from the map. It is called by the observer notifier 310 313 // and it overrides the clear() member function of the observer base. 311 314 virtual void clear() { -
lemon/bits/base_extender.h
r314 r664 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 31 31 //\ingroup digraphbits 32 32 //\file 33 //\brief Extenders for the digraph types33 //\brief Extenders for the graph types 34 34 namespace lemon { 35 35 … … 39 39 template <typename Base> 40 40 class UndirDigraphExtender : public Base { 41 typedef Base Parent; 41 42 42 43 public: 43 44 44 typedef Base Parent;45 45 typedef typename Parent::Arc Edge; 46 46 typedef typename Parent::Node Node; … … 281 281 template <typename Base> 282 282 class BidirBpGraphExtender : public Base { 283 typedef Base Parent; 284 283 285 public: 284 typedef Base Parent;285 286 typedef BidirBpGraphExtender Digraph; 286 287 -
lemon/bits/bezier.h
r314 r463 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). -
lemon/bits/default_map.h
r523 r674 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 98 98 99 99 100 #if defined HAVE_LONG_LONG100 #if defined LEMON_HAVE_LONG_LONG 101 101 102 102 // long long … … 154 154 class DefaultMap 155 155 : public DefaultMapSelector<_Graph, _Item, _Value>::Map { 156 typedef typename DefaultMapSelector<_Graph, _Item, _Value>::Map Parent; 157 156 158 public: 157 typedef typename DefaultMapSelector<_Graph, _Item, _Value>::Map Parent;158 159 typedef DefaultMap<_Graph, _Item, _Value> Map; 159 160 typedef typename Parent::Graph Graph;160 161 typedef typename Parent::GraphType GraphType; 161 162 typedef typename Parent::Value Value; 162 163 163 explicit DefaultMap(const Graph & graph) : Parent(graph) {}164 DefaultMap(const Graph & graph, const Value& value)164 explicit DefaultMap(const GraphType& graph) : Parent(graph) {} 165 DefaultMap(const GraphType& graph, const Value& value) 165 166 : Parent(graph, value) {} 166 167 -
lemon/bits/enable_if.h
r314 r463 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). -
lemon/bits/graph_extender.h
r314 r664 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 30 30 //\ingroup graphbits 31 31 //\file 32 //\brief Extenders for the digraph types32 //\brief Extenders for the graph types 33 33 namespace lemon { 34 34 35 35 // \ingroup graphbits 36 36 // 37 // \brief Extender for the Digraphs37 // \brief Extender for the digraph implementations 38 38 template <typename Base> 39 39 class DigraphExtender : public Base { 40 typedef Base Parent; 41 40 42 public: 41 43 42 typedef Base Parent;43 44 typedef DigraphExtender Digraph; 44 45 … … 219 220 class NodeMap 220 221 : public MapExtender<DefaultMap<Digraph, Node, _Value> > { 221 public:222 typedef DigraphExtender Digraph;223 222 typedef MapExtender<DefaultMap<Digraph, Node, _Value> > Parent; 224 223 224 public: 225 225 explicit NodeMap(const Digraph& digraph) 226 226 : Parent(digraph) {} … … 244 244 class ArcMap 245 245 : public MapExtender<DefaultMap<Digraph, Arc, _Value> > { 246 public:247 typedef DigraphExtender Digraph;248 246 typedef MapExtender<DefaultMap<Digraph, Arc, _Value> > Parent; 249 247 248 public: 250 249 explicit ArcMap(const Digraph& digraph) 251 250 : Parent(digraph) {} … … 331 330 template <typename Base> 332 331 class GraphExtender : public Base { 332 typedef Base Parent; 333 333 334 public: 334 335 335 typedef Base Parent;336 336 typedef GraphExtender Graph; 337 337 … … 602 602 class NodeMap 603 603 : public MapExtender<DefaultMap<Graph, Node, _Value> > { 604 public:605 typedef GraphExtender Graph;606 604 typedef MapExtender<DefaultMap<Graph, Node, _Value> > Parent; 607 605 606 public: 608 607 NodeMap(const Graph& graph) 609 608 : Parent(graph) {} … … 627 626 class ArcMap 628 627 : public MapExtender<DefaultMap<Graph, Arc, _Value> > { 629 public:630 typedef GraphExtender Graph;631 628 typedef MapExtender<DefaultMap<Graph, Arc, _Value> > Parent; 632 629 630 public: 633 631 ArcMap(const Graph& graph) 634 632 : Parent(graph) {} … … 652 650 class EdgeMap 653 651 : public MapExtender<DefaultMap<Graph, Edge, _Value> > { 654 public:655 typedef GraphExtender Graph;656 652 typedef MapExtender<DefaultMap<Graph, Edge, _Value> > Parent; 657 653 654 public: 658 655 EdgeMap(const Graph& graph) 659 656 : Parent(graph) {} -
lemon/bits/map_extender.h
r314 r664 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 37 37 template <typename _Map> 38 38 class MapExtender : public _Map { 39 public:40 41 39 typedef _Map Parent; 40 typedef typename Parent::GraphType GraphType; 41 42 public: 43 42 44 typedef MapExtender Map; 43 44 45 typedef typename Parent::Graph Graph;46 45 typedef typename Parent::Key Item; 47 46 48 47 typedef typename Parent::Key Key; 49 48 typedef typename Parent::Value Value; 49 typedef typename Parent::Reference Reference; 50 typedef typename Parent::ConstReference ConstReference; 50 51 51 52 class MapIt; … … 57 58 public: 58 59 59 MapExtender(const Graph & graph)60 MapExtender(const GraphType& graph) 60 61 : Parent(graph) {} 61 62 62 MapExtender(const Graph & graph, const Value& value)63 MapExtender(const GraphType& graph, const Value& value) 63 64 : Parent(graph, value) {} 64 65 … … 76 77 public: 77 78 class MapIt : public Item { 78 public: 79 80 typedef Item Parent; 79 typedef Item Parent; 80 81 public: 82 81 83 typedef typename Map::Value Value; 82 84 … … 115 117 116 118 class ConstMapIt : public Item { 117 public:118 119 typedef Item Parent;119 typedef Item Parent; 120 121 public: 120 122 121 123 typedef typename Map::Value Value; … … 146 148 147 149 class ItemIt : public Item { 148 public:149 150 typedef Item Parent;150 typedef Item Parent; 151 152 public: 151 153 152 154 ItemIt() {} … … 177 179 template <typename _Graph, typename _Map> 178 180 class SubMapExtender : public _Map { 179 public:180 181 181 typedef _Map Parent; 182 typedef _Graph GraphType; 183 184 public: 185 182 186 typedef SubMapExtender Map; 183 184 typedef _Graph Graph;185 186 187 typedef typename Parent::Key Item; 187 188 188 189 typedef typename Parent::Key Key; 189 190 typedef typename Parent::Value Value; 191 typedef typename Parent::Reference Reference; 192 typedef typename Parent::ConstReference ConstReference; 190 193 191 194 class MapIt; … … 197 200 public: 198 201 199 SubMapExtender(const Graph & _graph)202 SubMapExtender(const GraphType& _graph) 200 203 : Parent(_graph), graph(_graph) {} 201 204 202 SubMapExtender(const Graph & _graph, const Value& _value)205 SubMapExtender(const GraphType& _graph, const Value& _value) 203 206 : Parent(_graph, _value), graph(_graph) {} 204 207 … … 220 223 public: 221 224 class MapIt : public Item { 222 public:223 224 typedef Item Parent;225 typedef Item Parent; 226 227 public: 225 228 typedef typename Map::Value Value; 226 229 … … 259 262 260 263 class ConstMapIt : public Item { 261 public:262 263 typedef Item Parent;264 typedef Item Parent; 265 266 public: 264 267 265 268 typedef typename Map::Value Value; … … 290 293 291 294 class ItemIt : public Item { 292 public:293 294 typedef Item Parent;295 typedef Item Parent; 296 297 public: 295 298 296 299 ItemIt() {} … … 317 320 private: 318 321 319 const Graph & graph;322 const GraphType& graph; 320 323 321 324 }; -
lemon/bits/path_dump.h
r209 r576 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 17 17 */ 18 18 19 #ifndef LEMON_BITS_PRED_MAP_PATH_H 20 #define LEMON_BITS_PRED_MAP_PATH_H 19 #ifndef LEMON_BITS_PATH_DUMP_H 20 #define LEMON_BITS_PATH_DUMP_H 21 22 #include <lemon/core.h> 23 #include <lemon/concept_check.h> 21 24 22 25 namespace lemon { -
lemon/bits/traits.h
r314 r663 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 30 30 struct InvalidType {}; 31 31 32 template <typename _Graph, typename _Item>32 template <typename GR, typename _Item> 33 33 class ItemSetTraits {}; 34 34 35 35 36 template <typename G raph, typename Enable = void>36 template <typename GR, typename Enable = void> 37 37 struct NodeNotifierIndicator { 38 38 typedef InvalidType Type; 39 39 }; 40 template <typename G raph>40 template <typename GR> 41 41 struct NodeNotifierIndicator< 42 G raph,43 typename enable_if<typename G raph::NodeNotifier::Notifier, void>::type44 > { 45 typedef typename G raph::NodeNotifier Type;46 }; 47 48 template <typename _Graph>49 class ItemSetTraits< _Graph, typename _Graph::Node> {42 GR, 43 typename enable_if<typename GR::NodeNotifier::Notifier, void>::type 44 > { 45 typedef typename GR::NodeNotifier Type; 46 }; 47 48 template <typename GR> 49 class ItemSetTraits<GR, typename GR::Node> { 50 50 public: 51 51 52 typedef _Graph Graph; 53 54 typedef typename Graph::Node Item; 55 typedef typename Graph::NodeIt ItemIt; 56 57 typedef typename NodeNotifierIndicator<Graph>::Type ItemNotifier; 58 59 template <typename _Value> 60 class Map : public Graph::template NodeMap<_Value> { 52 typedef GR Graph; 53 typedef GR Digraph; 54 55 typedef typename GR::Node Item; 56 typedef typename GR::NodeIt ItemIt; 57 58 typedef typename NodeNotifierIndicator<GR>::Type ItemNotifier; 59 60 template <typename V> 61 class Map : public GR::template NodeMap<V> { 62 typedef typename GR::template NodeMap<V> Parent; 63 61 64 public: 62 typedef typename Graph::template NodeMap<_Value> Parent; 63 typedef typename Graph::template NodeMap<_Value> Type; 65 typedef typename GR::template NodeMap<V> Type; 64 66 typedef typename Parent::Value Value; 65 67 66 Map(const G raph& _digraph) : Parent(_digraph) {}67 Map(const G raph& _digraph, const Value& _value)68 Map(const GR& _digraph) : Parent(_digraph) {} 69 Map(const GR& _digraph, const Value& _value) 68 70 : Parent(_digraph, _value) {} 69 71 … … 72 74 }; 73 75 74 template <typename G raph, typename Enable = void>76 template <typename GR, typename Enable = void> 75 77 struct ArcNotifierIndicator { 76 78 typedef InvalidType Type; 77 79 }; 78 template <typename G raph>80 template <typename GR> 79 81 struct ArcNotifierIndicator< 80 G raph,81 typename enable_if<typename G raph::ArcNotifier::Notifier, void>::type82 > { 83 typedef typename G raph::ArcNotifier Type;84 }; 85 86 template <typename _Graph>87 class ItemSetTraits< _Graph, typename _Graph::Arc> {82 GR, 83 typename enable_if<typename GR::ArcNotifier::Notifier, void>::type 84 > { 85 typedef typename GR::ArcNotifier Type; 86 }; 87 88 template <typename GR> 89 class ItemSetTraits<GR, typename GR::Arc> { 88 90 public: 89 91 90 typedef _Graph Graph; 91 92 typedef typename Graph::Arc Item; 93 typedef typename Graph::ArcIt ItemIt; 94 95 typedef typename ArcNotifierIndicator<Graph>::Type ItemNotifier; 96 97 template <typename _Value> 98 class Map : public Graph::template ArcMap<_Value> { 92 typedef GR Graph; 93 typedef GR Digraph; 94 95 typedef typename GR::Arc Item; 96 typedef typename GR::ArcIt ItemIt; 97 98 typedef typename ArcNotifierIndicator<GR>::Type ItemNotifier; 99 100 template <typename V> 101 class Map : public GR::template ArcMap<V> { 102 typedef typename GR::template ArcMap<V> Parent; 103 99 104 public: 100 typedef typename Graph::template ArcMap<_Value> Parent; 101 typedef typename Graph::template ArcMap<_Value> Type; 105 typedef typename GR::template ArcMap<V> Type; 102 106 typedef typename Parent::Value Value; 103 107 104 Map(const G raph& _digraph) : Parent(_digraph) {}105 Map(const G raph& _digraph, const Value& _value)108 Map(const GR& _digraph) : Parent(_digraph) {} 109 Map(const GR& _digraph, const Value& _value) 106 110 : Parent(_digraph, _value) {} 107 111 }; … … 109 113 }; 110 114 111 template <typename G raph, typename Enable = void>115 template <typename GR, typename Enable = void> 112 116 struct EdgeNotifierIndicator { 113 117 typedef InvalidType Type; 114 118 }; 115 template <typename G raph>119 template <typename GR> 116 120 struct EdgeNotifierIndicator< 117 G raph,118 typename enable_if<typename G raph::EdgeNotifier::Notifier, void>::type119 > { 120 typedef typename G raph::EdgeNotifier Type;121 }; 122 123 template <typename _Graph>124 class ItemSetTraits< _Graph, typename _Graph::Edge> {121 GR, 122 typename enable_if<typename GR::EdgeNotifier::Notifier, void>::type 123 > { 124 typedef typename GR::EdgeNotifier Type; 125 }; 126 127 template <typename GR> 128 class ItemSetTraits<GR, typename GR::Edge> { 125 129 public: 126 130 127 typedef _Graph Graph; 128 129 typedef typename Graph::Edge Item; 130 typedef typename Graph::EdgeIt ItemIt; 131 132 typedef typename EdgeNotifierIndicator<Graph>::Type ItemNotifier; 133 134 template <typename _Value> 135 class Map : public Graph::template EdgeMap<_Value> { 131 typedef GR Graph; 132 typedef GR Digraph; 133 134 typedef typename GR::Edge Item; 135 typedef typename GR::EdgeIt ItemIt; 136 137 typedef typename EdgeNotifierIndicator<GR>::Type ItemNotifier; 138 139 template <typename V> 140 class Map : public GR::template EdgeMap<V> { 141 typedef typename GR::template EdgeMap<V> Parent; 142 136 143 public: 137 typedef typename Graph::template EdgeMap<_Value> Parent; 138 typedef typename Graph::template EdgeMap<_Value> Type; 144 typedef typename GR::template EdgeMap<V> Type; 139 145 typedef typename Parent::Value Value; 140 146 141 Map(const G raph& _digraph) : Parent(_digraph) {}142 Map(const G raph& _digraph, const Value& _value)147 Map(const GR& _digraph) : Parent(_digraph) {} 148 Map(const GR& _digraph, const Value& _value) 143 149 : Parent(_digraph, _value) {} 144 150 }; … … 205 211 // Indicators for the tags 206 212 207 template <typename G raph, typename Enable = void>213 template <typename GR, typename Enable = void> 208 214 struct NodeNumTagIndicator { 209 215 static const bool value = false; 210 216 }; 211 217 212 template <typename G raph>218 template <typename GR> 213 219 struct NodeNumTagIndicator< 214 Graph, 215 typename enable_if<typename Graph::NodeNumTag, void>::type 216 > { 217 static const bool value = true; 218 }; 219 220 template <typename Graph, typename Enable = void> 220 GR, 221 typename enable_if<typename GR::NodeNumTag, void>::type 222 > { 223 static const bool value = true; 224 }; 225 226 template <typename GR, typename Enable = void> 227 struct ArcNumTagIndicator { 228 static const bool value = false; 229 }; 230 231 template <typename GR> 232 struct ArcNumTagIndicator< 233 GR, 234 typename enable_if<typename GR::ArcNumTag, void>::type 235 > { 236 static const bool value = true; 237 }; 238 239 template <typename GR, typename Enable = void> 221 240 struct EdgeNumTagIndicator { 222 241 static const bool value = false; 223 242 }; 224 243 225 template <typename G raph>244 template <typename GR> 226 245 struct EdgeNumTagIndicator< 227 Graph, 228 typename enable_if<typename Graph::EdgeNumTag, void>::type 229 > { 230 static const bool value = true; 231 }; 232 233 template <typename Graph, typename Enable = void> 246 GR, 247 typename enable_if<typename GR::EdgeNumTag, void>::type 248 > { 249 static const bool value = true; 250 }; 251 252 template <typename GR, typename Enable = void> 253 struct FindArcTagIndicator { 254 static const bool value = false; 255 }; 256 257 template <typename GR> 258 struct FindArcTagIndicator< 259 GR, 260 typename enable_if<typename GR::FindArcTag, void>::type 261 > { 262 static const bool value = true; 263 }; 264 265 template <typename GR, typename Enable = void> 234 266 struct FindEdgeTagIndicator { 235 267 static const bool value = false; 236 268 }; 237 269 238 template <typename G raph>270 template <typename GR> 239 271 struct FindEdgeTagIndicator< 240 G raph,241 typename enable_if<typename G raph::FindEdgeTag, void>::type242 > { 243 static const bool value = true; 244 }; 245 246 template <typename G raph, typename Enable = void>272 GR, 273 typename enable_if<typename GR::FindEdgeTag, void>::type 274 > { 275 static const bool value = true; 276 }; 277 278 template <typename GR, typename Enable = void> 247 279 struct UndirectedTagIndicator { 248 280 static const bool value = false; 249 281 }; 250 282 251 template <typename G raph>283 template <typename GR> 252 284 struct UndirectedTagIndicator< 253 G raph,254 typename enable_if<typename G raph::UndirectedTag, void>::type255 > { 256 static const bool value = true; 257 }; 258 259 template <typename G raph, typename Enable = void>285 GR, 286 typename enable_if<typename GR::UndirectedTag, void>::type 287 > { 288 static const bool value = true; 289 }; 290 291 template <typename GR, typename Enable = void> 260 292 struct BuildTagIndicator { 261 293 static const bool value = false; 262 294 }; 263 295 264 template <typename G raph>296 template <typename GR> 265 297 struct BuildTagIndicator< 266 G raph,267 typename enable_if<typename G raph::BuildTag, void>::type298 GR, 299 typename enable_if<typename GR::BuildTag, void>::type 268 300 > { 269 301 static const bool value = true; -
lemon/bits/vector_map.h
r314 r664 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 39 39 // \brief Graph map based on the std::vector storage. 40 40 // 41 // The VectorMap template class is graph map structure what42 // automatically updates the map when a key is added to or erased from43 // the map. This map type uses thestd::vector to store the values.41 // The VectorMap template class is graph map structure that automatically 42 // updates the map when a key is added to or erased from the graph. 43 // This map type uses std::vector to store the values. 44 44 // 45 45 // \tparam _Graph The graph this map is attached to. … … 57 57 58 58 // The graph type of the map. 59 typedef _Graph Graph ;59 typedef _Graph GraphType; 60 60 // The item type of the map. 61 61 typedef _Item Item; … … 73 73 // The map type. 74 74 typedef VectorMap Map; 75 // The base class of the map.76 typedef typename Notifier::ObserverBase Parent;77 75 78 76 // The reference type of the map; … … 81 79 typedef typename Container::const_reference ConstReference; 82 80 81 private: 82 83 // The base class of the map. 84 typedef typename Notifier::ObserverBase Parent; 85 86 public: 83 87 84 88 // \brief Constructor to attach the new map into the notifier. … … 86 90 // It constructs a map and attachs it into the notifier. 87 91 // It adds all the items of the graph to the map. 88 VectorMap(const Graph & graph) {92 VectorMap(const GraphType& graph) { 89 93 Parent::attach(graph.notifier(Item())); 90 94 container.resize(Parent::notifier()->maxId() + 1); … … 95 99 // It constructs a map uses a given value to initialize the map. 96 100 // It adds all the items of the graph to the map. 97 VectorMap(const Graph & graph, const Value& value) {101 VectorMap(const GraphType& graph, const Value& value) { 98 102 Parent::attach(graph.notifier(Item())); 99 103 container.resize(Parent::notifier()->maxId() + 1, value); … … 125 129 // \brief Template assign operator. 126 130 // 127 // The given parameter should beconform to the ReadMap131 // The given parameter should conform to the ReadMap 128 132 // concecpt and could be indiced by the current item set of 129 133 // the NodeMap. In this case the value for each item … … 170 174 // \brief Adds a new key to the map. 171 175 // 172 // It adds a new key to the map. It called by the observer notifier176 // It adds a new key to the map. It is called by the observer notifier 173 177 // and it overrides the add() member function of the observer base. 174 178 virtual void add(const Key& key) { … … 181 185 // \brief Adds more new keys to the map. 182 186 // 183 // It adds more new keys to the map. It called by the observer notifier187 // It adds more new keys to the map. It is called by the observer notifier 184 188 // and it overrides the add() member function of the observer base. 185 189 virtual void add(const std::vector<Key>& keys) { … … 196 200 // \brief Erase a key from the map. 197 201 // 198 // Erase a key from the map. It called by the observer notifier202 // Erase a key from the map. It is called by the observer notifier 199 203 // and it overrides the erase() member function of the observer base. 200 204 virtual void erase(const Key& key) { … … 204 208 // \brief Erase more keys from the map. 205 209 // 206 // Erase more keys from the map. Itcalled by the observer notifier210 // It erases more keys from the map. It is called by the observer notifier 207 211 // and it overrides the erase() member function of the observer base. 208 212 virtual void erase(const std::vector<Key>& keys) { … … 212 216 } 213 217 214 // \brief Build esthe map.215 // 216 // It build es the map. Itcalled by the observer notifier218 // \brief Build the map. 219 // 220 // It builds the map. It is called by the observer notifier 217 221 // and it overrides the build() member function of the observer base. 218 222 virtual void build() { … … 224 228 // \brief Clear the map. 225 229 // 226 // It erase all items from the map. Itcalled by the observer notifier230 // It erases all items from the map. It is called by the observer notifier 227 231 // and it overrides the clear() member function of the observer base. 228 232 virtual void clear() { -
lemon/bits/windows.h
r511 r576 17 17 */ 18 18 19 #ifndef LEMON_ WINDOWS_H20 #define LEMON_ WINDOWS_H19 #ifndef LEMON_BITS_WINDOWS_H 20 #define LEMON_BITS_WINDOWS_H 21 21 22 22 #include <string> -
lemon/color.cc
r209 r463 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). -
lemon/color.h
r313 r463 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). -
lemon/concept_check.h
r285 r463 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). -
lemon/concepts/digraph.h
r263 r627 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 17 17 */ 18 18 19 #ifndef LEMON_CONCEPT _DIGRAPH_H20 #define LEMON_CONCEPT _DIGRAPH_H19 #ifndef LEMON_CONCEPTS_DIGRAPH_H 20 #define LEMON_CONCEPTS_DIGRAPH_H 21 21 22 22 ///\ingroup graph_concepts … … 422 422 Node oppositeNode(const Node&, const Arc&) const { return INVALID; } 423 423 424 /// \brief Read write map of the nodes to type \c T. 425 /// 426 /// ReadWrite map of the nodes to type \c T. 427 /// \sa Reference 424 /// \brief Reference map of the nodes to type \c T. 425 /// 426 /// Reference map of the nodes to type \c T. 428 427 template<class T> 429 class NodeMap : public Re adWriteMap< Node, T> {428 class NodeMap : public ReferenceMap<Node, T, T&, const T&> { 430 429 public: 431 430 … … 437 436 private: 438 437 ///Copy constructor 439 NodeMap(const NodeMap& nm) : ReadWriteMap< Node, T >(nm) { } 438 NodeMap(const NodeMap& nm) : 439 ReferenceMap<Node, T, T&, const T&>(nm) { } 440 440 ///Assignment operator 441 441 template <typename CMap> … … 446 446 }; 447 447 448 /// \brief Re ad write map of the arcs to type \c T.448 /// \brief Reference map of the arcs to type \c T. 449 449 /// 450 450 /// Reference map of the arcs to type \c T. 451 /// \sa Reference452 451 template<class T> 453 class ArcMap : public Re adWriteMap<Arc,T> {452 class ArcMap : public ReferenceMap<Arc, T, T&, const T&> { 454 453 public: 455 454 … … 460 459 private: 461 460 ///Copy constructor 462 ArcMap(const ArcMap& em) : ReadWriteMap<Arc,T>(em) { } 461 ArcMap(const ArcMap& em) : 462 ReferenceMap<Arc, T, T&, const T&>(em) { } 463 463 ///Assignment operator 464 464 template <typename CMap> … … 472 472 struct Constraints { 473 473 void constraints() { 474 checkConcept<BaseDigraphComponent, _Digraph>(); 474 475 checkConcept<IterableDigraphComponent<>, _Digraph>(); 475 476 checkConcept<IDableDigraphComponent<>, _Digraph>(); … … 485 486 486 487 487 #endif // LEMON_CONCEPT_DIGRAPH_H488 #endif -
lemon/concepts/graph.h
r263 r627 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 21 21 ///\brief The concept of Undirected Graphs. 22 22 23 #ifndef LEMON_CONCEPT _GRAPH_H24 #define LEMON_CONCEPT _GRAPH_H23 #ifndef LEMON_CONCEPTS_GRAPH_H 24 #define LEMON_CONCEPTS_GRAPH_H 25 25 26 26 #include <lemon/concepts/graph_components.h> 27 #include <lemon/concepts/graph.h>28 27 #include <lemon/core.h> 29 28 … … 499 498 }; 500 499 501 /// \brief Read write map of the nodes to type \c T. 502 /// 503 /// ReadWrite map of the nodes to type \c T. 504 /// \sa Reference 500 /// \brief Reference map of the nodes to type \c T. 501 /// 502 /// Reference map of the nodes to type \c T. 505 503 template<class T> 506 class NodeMap : public Re adWriteMap< Node, T>504 class NodeMap : public ReferenceMap<Node, T, T&, const T&> 507 505 { 508 506 public: … … 515 513 private: 516 514 ///Copy constructor 517 NodeMap(const NodeMap& nm) : ReadWriteMap< Node, T >(nm) { } 515 NodeMap(const NodeMap& nm) : 516 ReferenceMap<Node, T, T&, const T&>(nm) { } 518 517 ///Assignment operator 519 518 template <typename CMap> … … 524 523 }; 525 524 526 /// \brief Read write map of the directed arcs to type \c T. 527 /// 528 /// Reference map of the directed arcs to type \c T. 529 /// \sa Reference 525 /// \brief Reference map of the arcs to type \c T. 526 /// 527 /// Reference map of the arcs to type \c T. 530 528 template<class T> 531 class ArcMap : public Re adWriteMap<Arc,T>529 class ArcMap : public ReferenceMap<Arc, T, T&, const T&> 532 530 { 533 531 public: … … 539 537 private: 540 538 ///Copy constructor 541 ArcMap(const ArcMap& em) : ReadWriteMap<Arc,T>(em) { } 539 ArcMap(const ArcMap& em) : 540 ReferenceMap<Arc, T, T&, const T&>(em) { } 542 541 ///Assignment operator 543 542 template <typename CMap> … … 548 547 }; 549 548 550 /// Read write map of the edges to type \c T. 551 552 /// Reference map of the arcs to type \c T. 553 /// \sa Reference 549 /// Reference map of the edges to type \c T. 550 551 /// Reference map of the edges to type \c T. 554 552 template<class T> 555 class EdgeMap : public Re adWriteMap<Edge,T>553 class EdgeMap : public ReferenceMap<Edge, T, T&, const T&> 556 554 { 557 555 public: … … 563 561 private: 564 562 ///Copy constructor 565 EdgeMap(const EdgeMap& em) : ReadWriteMap<Edge,T>(em) {} 563 EdgeMap(const EdgeMap& em) : 564 ReferenceMap<Edge, T, T&, const T&>(em) {} 566 565 ///Assignment operator 567 566 template <typename CMap> … … 603 602 /// \brief Opposite node on an arc 604 603 /// 605 /// \return the opposite of the given Node on the given Edge604 /// \return The opposite of the given node on the given edge. 606 605 Node oppositeNode(Node, Edge) const { return INVALID; } 607 606 608 607 /// \brief First node of the edge. 609 608 /// 610 /// \return the first node of the given Edge.609 /// \return The first node of the given edge. 611 610 /// 612 611 /// Naturally edges don't have direction and thus 613 /// don't have source and target node. But we use these two methods614 /// to query the two nodes of the arc. The direction of the arc615 /// which arises this way is called the inherent direction of the612 /// don't have source and target node. However we use \c u() and \c v() 613 /// methods to query the two nodes of the arc. The direction of the 614 /// arc which arises this way is called the inherent direction of the 616 615 /// edge, and is used to define the "default" direction 617 616 /// of the directed versions of the arcs. 618 /// \sa direction 617 /// \sa v() 618 /// \sa direction() 619 619 Node u(Edge) const { return INVALID; } 620 620 621 621 /// \brief Second node of the edge. 622 /// 623 /// \return The second node of the given edge. 624 /// 625 /// Naturally edges don't have direction and thus 626 /// don't have source and target node. However we use \c u() and \c v() 627 /// methods to query the two nodes of the arc. The direction of the 628 /// arc which arises this way is called the inherent direction of the 629 /// edge, and is used to define the "default" direction 630 /// of the directed versions of the arcs. 631 /// \sa u() 632 /// \sa direction() 622 633 Node v(Edge) const { return INVALID; } 623 634 … … 738 749 struct Constraints { 739 750 void constraints() { 751 checkConcept<BaseGraphComponent, _Graph>(); 740 752 checkConcept<IterableGraphComponent<>, _Graph>(); 741 753 checkConcept<IDableGraphComponent<>, _Graph>(); -
lemon/concepts/graph_components.h
r313 r664 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 21 21 ///\brief The concept of graph components. 22 22 23 24 #ifndef LEMON_CONCEPT_GRAPH_COMPONENTS_H 25 #define LEMON_CONCEPT_GRAPH_COMPONENTS_H 23 #ifndef LEMON_CONCEPTS_GRAPH_COMPONENTS_H 24 #define LEMON_CONCEPTS_GRAPH_COMPONENTS_H 26 25 27 26 #include <lemon/core.h> … … 33 32 namespace concepts { 34 33 35 /// \brief Skeleton class for graph Node and Arc types36 /// 37 /// This class describes the interface of Node and Arc (andEdge38 /// in undirected graphs) subtypes ofgraph types.34 /// \brief Concept class for \c Node, \c Arc and \c Edge types. 35 /// 36 /// This class describes the concept of \c Node, \c Arc and \c Edge 37 /// subtypes of digraph and graph types. 39 38 /// 40 39 /// \note This class is a template class so that we can use it to 41 /// create graph skeleton classes. The reason for this is than Node 42 /// and Arc types should \em not derive from the same base class. 43 /// For Node you should instantiate it with character 'n' and for Arc 44 /// with 'a'. 45 40 /// create graph skeleton classes. The reason for this is that \c Node 41 /// and \c Arc (or \c Edge) types should \e not derive from the same 42 /// base class. For \c Node you should instantiate it with character 43 /// \c 'n', for \c Arc with \c 'a' and for \c Edge with \c 'e'. 46 44 #ifndef DOXYGEN 47 template <char _selector= '0'>45 template <char sel = '0'> 48 46 #endif 49 47 class GraphItem { … … 51 49 /// \brief Default constructor. 52 50 /// 51 /// Default constructor. 53 52 /// \warning The default constructor is not required to set 54 53 /// the item to some well-defined value. So you should consider it 55 54 /// as uninitialized. 56 55 GraphItem() {} 56 57 57 /// \brief Copy constructor. 58 58 /// 59 59 /// Copy constructor. 60 ///61 60 GraphItem(const GraphItem &) {} 62 /// \brief Invalid constructor \& conversion. 63 /// 64 /// This constructor initializes the item to be invalid. 61 62 /// \brief Constructor for conversion from \c INVALID. 63 /// 64 /// Constructor for conversion from \c INVALID. 65 /// It initializes the item to be invalid. 65 66 /// \sa Invalid for more details. 66 67 GraphItem(Invalid) {} 67 /// \brief Assign operator for nodes. 68 /// 69 /// The nodes are assignable. 70 /// 71 GraphItem& operator=(GraphItem const&) { return *this; } 68 69 /// \brief Assignment operator. 70 /// 71 /// Assignment operator for the item. 72 GraphItem& operator=(const GraphItem&) { return *this; } 73 72 74 /// \brief Equality operator. 73 75 /// 74 /// Two iterators are equal if and only if they represents the75 /// same node in the graph or both are invalid.76 bool operator==(GraphItem) const { return false; } 76 /// Equality operator. 77 bool operator==(const GraphItem&) const { return false; } 78 77 79 /// \brief Inequality operator. 78 80 /// 79 /// \sa operator==(const Node& n)80 ///81 bool operator!=(GraphItem) const { return false; } 82 83 /// \brief Artificial ordering operator.84 /// 85 /// To allow the use of graph descriptors as key type in std::map or86 /// similar associative container we require this.81 /// Inequality operator. 82 bool operator!=(const GraphItem&) const { return false; } 83 84 /// \brief Ordering operator. 85 /// 86 /// This operator defines an ordering of the items. 87 /// It makes possible to use graph item types as key types in 88 /// associative containers (e.g. \c std::map). 87 89 /// 88 90 /// \note This operator only have to define some strict ordering of 89 91 /// the items; this order has nothing to do with the iteration 90 92 /// ordering of the items. 91 bool operator<( GraphItem) const { return false; }93 bool operator<(const GraphItem&) const { return false; } 92 94 93 95 template<typename _GraphItem> … … 101 103 102 104 bool b; 103 // b = (ia == ib) && (ia != ib) && (ia < ib);104 105 b = (ia == ib) && (ia != ib); 105 106 b = (ia == INVALID) && (ib != INVALID); … … 112 113 }; 113 114 114 /// \brief An empty base directed graph class. 115 /// 116 /// This class provides the minimal set of features needed for a 117 /// directed graph structure. All digraph concepts have to be 118 /// conform to this base directed graph. It just provides types 119 /// for nodes and arcs and functions to get the source and the 120 /// target of the arcs. 115 /// \brief Base skeleton class for directed graphs. 116 /// 117 /// This class describes the base interface of directed graph types. 118 /// All digraph %concepts have to conform to this class. 119 /// It just provides types for nodes and arcs and functions 120 /// to get the source and the target nodes of arcs. 121 121 class BaseDigraphComponent { 122 122 public: … … 126 126 /// \brief Node class of the digraph. 127 127 /// 128 /// This class represents the Nodes of the digraph. 129 /// 128 /// This class represents the nodes of the digraph. 130 129 typedef GraphItem<'n'> Node; 131 130 132 131 /// \brief Arc class of the digraph. 133 132 /// 134 /// This class represents the Arcs of the digraph. 135 /// 136 typedef GraphItem<'e'> Arc; 137 138 /// \brief Gives back the target node of an arc. 139 /// 140 /// Gives back the target node of an arc. 141 /// 142 Node target(const Arc&) const { return INVALID;} 143 144 /// \brief Gives back the source node of an arc. 145 /// 146 /// Gives back the source node of an arc. 147 /// 148 Node source(const Arc&) const { return INVALID;} 149 150 /// \brief Gives back the opposite node on the given arc. 151 /// 152 /// Gives back the opposite node on the given arc. 133 /// This class represents the arcs of the digraph. 134 typedef GraphItem<'a'> Arc; 135 136 /// \brief Return the source node of an arc. 137 /// 138 /// This function returns the source node of an arc. 139 Node source(const Arc&) const { return INVALID; } 140 141 /// \brief Return the target node of an arc. 142 /// 143 /// This function returns the target node of an arc. 144 Node target(const Arc&) const { return INVALID; } 145 146 /// \brief Return the opposite node on the given arc. 147 /// 148 /// This function returns the opposite node on the given arc. 153 149 Node oppositeNode(const Node&, const Arc&) const { 154 150 return INVALID; … … 176 172 }; 177 173 178 /// \brief An empty base undirected graph class. 179 /// 180 /// This class provides the minimal set of features needed for an 181 /// undirected graph structure. All undirected graph concepts have 182 /// to be conform to this base graph. It just provides types for 183 /// nodes, arcs and edges and functions to get the 184 /// source and the target of the arcs and edges, 185 /// conversion from arcs to edges and function to get 186 /// both direction of the edges. 174 /// \brief Base skeleton class for undirected graphs. 175 /// 176 /// This class describes the base interface of undirected graph types. 177 /// All graph %concepts have to conform to this class. 178 /// It extends the interface of \ref BaseDigraphComponent with an 179 /// \c Edge type and functions to get the end nodes of edges, 180 /// to convert from arcs to edges and to get both direction of edges. 187 181 class BaseGraphComponent : public BaseDigraphComponent { 188 182 public: 183 184 typedef BaseGraphComponent Graph; 185 189 186 typedef BaseDigraphComponent::Node Node; 190 187 typedef BaseDigraphComponent::Arc Arc; 191 /// \brief Undirected arc class of the graph. 192 /// 193 /// This class represents the edges of the graph. 194 /// The undirected graphs can be used as a directed graph which 195 /// for each arc contains the opposite arc too so the graph is 196 /// bidirected. The edge represents two opposite 197 /// directed arcs. 198 class Edge : public GraphItem<'u'> { 188 189 /// \brief Undirected edge class of the graph. 190 /// 191 /// This class represents the undirected edges of the graph. 192 /// Undirected graphs can be used as directed graphs, each edge is 193 /// represented by two opposite directed arcs. 194 class Edge : public GraphItem<'e'> { 195 typedef GraphItem<'e'> Parent; 196 199 197 public: 200 typedef GraphItem<'u'> Parent;201 198 /// \brief Default constructor. 202 199 /// 200 /// Default constructor. 203 201 /// \warning The default constructor is not required to set 204 202 /// the item to some well-defined value. So you should consider it 205 203 /// as uninitialized. 206 204 Edge() {} 205 207 206 /// \brief Copy constructor. 208 207 /// 209 208 /// Copy constructor. 210 ///211 209 Edge(const Edge &) : Parent() {} 212 /// \brief Invalid constructor \& conversion. 213 /// 214 /// This constructor initializes the item to be invalid. 210 211 /// \brief Constructor for conversion from \c INVALID. 212 /// 213 /// Constructor for conversion from \c INVALID. 214 /// It initializes the item to be invalid. 215 215 /// \sa Invalid for more details. 216 216 Edge(Invalid) {} 217 /// \brief Converter from arc to edge. 218 /// 217 218 /// \brief Constructor for conversion from an arc. 219 /// 220 /// Constructor for conversion from an arc. 219 221 /// Besides the core graph item functionality each arc should 220 222 /// be convertible to the represented edge. 221 223 Edge(const Arc&) {} 222 /// \brief Assign arc to edge. 223 /// 224 225 /// \brief Assign an arc to an edge. 226 /// 227 /// This function assigns an arc to an edge. 224 228 /// Besides the core graph item functionality each arc should 225 229 /// be convertible to the represented edge. … … 227 231 }; 228 232 229 /// \brief Returns the direction of the arc. 233 /// \brief Return one end node of an edge. 234 /// 235 /// This function returns one end node of an edge. 236 Node u(const Edge&) const { return INVALID; } 237 238 /// \brief Return the other end node of an edge. 239 /// 240 /// This function returns the other end node of an edge. 241 Node v(const Edge&) const { return INVALID; } 242 243 /// \brief Return a directed arc related to an edge. 244 /// 245 /// This function returns a directed arc from its direction and the 246 /// represented edge. 247 Arc direct(const Edge&, bool) const { return INVALID; } 248 249 /// \brief Return a directed arc related to an edge. 250 /// 251 /// This function returns a directed arc from its source node and the 252 /// represented edge. 253 Arc direct(const Edge&, const Node&) const { return INVALID; } 254 255 /// \brief Return the direction of the arc. 230 256 /// 231 257 /// Returns the direction of the arc. Each arc represents an … … 234 260 bool direction(const Arc&) const { return true; } 235 261 236 /// \brief Returns the directed arc. 237 /// 238 /// Returns the directed arc from its direction and the 239 /// represented edge. 240 Arc direct(const Edge&, bool) const { return INVALID;} 241 242 /// \brief Returns the directed arc. 243 /// 244 /// Returns the directed arc from its source and the 245 /// represented edge. 246 Arc direct(const Edge&, const Node&) const { return INVALID;} 247 248 /// \brief Returns the opposite arc. 249 /// 250 /// Returns the opposite arc. It is the arc representing the 251 /// same edge and has opposite direction. 252 Arc oppositeArc(const Arc&) const { return INVALID;} 253 254 /// \brief Gives back one ending of an edge. 255 /// 256 /// Gives back one ending of an edge. 257 Node u(const Edge&) const { return INVALID;} 258 259 /// \brief Gives back the other ending of an edge. 260 /// 261 /// Gives back the other ending of an edge. 262 Node v(const Edge&) const { return INVALID;} 262 /// \brief Return the opposite arc. 263 /// 264 /// This function returns the opposite arc, i.e. the arc representing 265 /// the same edge and has opposite direction. 266 Arc oppositeArc(const Arc&) const { return INVALID; } 263 267 264 268 template <typename _Graph> … … 270 274 void constraints() { 271 275 checkConcept<BaseDigraphComponent, _Graph>(); 272 checkConcept<GraphItem<' u'>, Edge>();276 checkConcept<GraphItem<'e'>, Edge>(); 273 277 { 274 278 Node n; … … 278 282 n = graph.v(ue); 279 283 e = graph.direct(ue, true); 284 e = graph.direct(ue, false); 280 285 e = graph.direct(ue, n); 281 286 e = graph.oppositeArc(e); … … 291 296 }; 292 297 293 /// \brief An empty idable base digraph class.294 /// 295 /// This class provides beside the core digraph features296 /// core id functions for the digraph structure.297 /// The most of the base digraphs should be conform to this concept.298 /// Th e id's are unique and immutable.299 template <typename _Base= BaseDigraphComponent>300 class IDableDigraphComponent : public _Base{301 public: 302 303 typedef _BaseBase;298 /// \brief Skeleton class for \e idable directed graphs. 299 /// 300 /// This class describes the interface of \e idable directed graphs. 301 /// It extends \ref BaseDigraphComponent with the core ID functions. 302 /// The ids of the items must be unique and immutable. 303 /// This concept is part of the Digraph concept. 304 template <typename BAS = BaseDigraphComponent> 305 class IDableDigraphComponent : public BAS { 306 public: 307 308 typedef BAS Base; 304 309 typedef typename Base::Node Node; 305 310 typedef typename Base::Arc Arc; 306 311 307 /// \brief Gives back an unique integer id for the Node. 308 /// 309 /// Gives back an unique integer id for the Node. 310 /// 311 int id(const Node&) const { return -1;} 312 313 /// \brief Gives back the node by the unique id. 314 /// 315 /// Gives back the node by the unique id. 316 /// If the digraph does not contain node with the given id 317 /// then the result of the function is undetermined. 318 Node nodeFromId(int) const { return INVALID;} 319 320 /// \brief Gives back an unique integer id for the Arc. 321 /// 322 /// Gives back an unique integer id for the Arc. 323 /// 324 int id(const Arc&) const { return -1;} 325 326 /// \brief Gives back the arc by the unique id. 327 /// 328 /// Gives back the arc by the unique id. 329 /// If the digraph does not contain arc with the given id 330 /// then the result of the function is undetermined. 331 Arc arcFromId(int) const { return INVALID;} 332 333 /// \brief Gives back an integer greater or equal to the maximum 334 /// Node id. 335 /// 336 /// Gives back an integer greater or equal to the maximum Node 337 /// id. 338 int maxNodeId() const { return -1;} 339 340 /// \brief Gives back an integer greater or equal to the maximum 341 /// Arc id. 342 /// 343 /// Gives back an integer greater or equal to the maximum Arc 344 /// id. 345 int maxArcId() const { return -1;} 312 /// \brief Return a unique integer id for the given node. 313 /// 314 /// This function returns a unique integer id for the given node. 315 int id(const Node&) const { return -1; } 316 317 /// \brief Return the node by its unique id. 318 /// 319 /// This function returns the node by its unique id. 320 /// If the digraph does not contain a node with the given id, 321 /// then the result of the function is undefined. 322 Node nodeFromId(int) const { return INVALID; } 323 324 /// \brief Return a unique integer id for the given arc. 325 /// 326 /// This function returns a unique integer id for the given arc. 327 int id(const Arc&) const { return -1; } 328 329 /// \brief Return the arc by its unique id. 330 /// 331 /// This function returns the arc by its unique id. 332 /// If the digraph does not contain an arc with the given id, 333 /// then the result of the function is undefined. 334 Arc arcFromId(int) const { return INVALID; } 335 336 /// \brief Return an integer greater or equal to the maximum 337 /// node id. 338 /// 339 /// This function returns an integer greater or equal to the 340 /// maximum node id. 341 int maxNodeId() const { return -1; } 342 343 /// \brief Return an integer greater or equal to the maximum 344 /// arc id. 345 /// 346 /// This function returns an integer greater or equal to the 347 /// maximum arc id. 348 int maxArcId() const { return -1; } 346 349 347 350 template <typename _Digraph> … … 369 372 }; 370 373 371 /// \brief An empty idable base undirected graph class. 372 /// 373 /// This class provides beside the core undirected graph features 374 /// core id functions for the undirected graph structure. The 375 /// most of the base undirected graphs should be conform to this 376 /// concept. The id's are unique and immutable. 377 template <typename _Base = BaseGraphComponent> 378 class IDableGraphComponent : public IDableDigraphComponent<_Base> { 379 public: 380 381 typedef _Base Base; 374 /// \brief Skeleton class for \e idable undirected graphs. 375 /// 376 /// This class describes the interface of \e idable undirected 377 /// graphs. It extends \ref IDableDigraphComponent with the core ID 378 /// functions of undirected graphs. 379 /// The ids of the items must be unique and immutable. 380 /// This concept is part of the Graph concept. 381 template <typename BAS = BaseGraphComponent> 382 class IDableGraphComponent : public IDableDigraphComponent<BAS> { 383 public: 384 385 typedef BAS Base; 382 386 typedef typename Base::Edge Edge; 383 387 384 using IDableDigraphComponent<_Base>::id; 385 386 /// \brief Gives back an unique integer id for the Edge. 387 /// 388 /// Gives back an unique integer id for the Edge. 389 /// 390 int id(const Edge&) const { return -1;} 391 392 /// \brief Gives back the edge by the unique id. 393 /// 394 /// Gives back the edge by the unique id. If the 395 /// graph does not contain arc with the given id then the 396 /// result of the function is undetermined. 397 Edge edgeFromId(int) const { return INVALID;} 398 399 /// \brief Gives back an integer greater or equal to the maximum 400 /// Edge id. 401 /// 402 /// Gives back an integer greater or equal to the maximum Edge 403 /// id. 404 int maxEdgeId() const { return -1;} 388 using IDableDigraphComponent<Base>::id; 389 390 /// \brief Return a unique integer id for the given edge. 391 /// 392 /// This function returns a unique integer id for the given edge. 393 int id(const Edge&) const { return -1; } 394 395 /// \brief Return the edge by its unique id. 396 /// 397 /// This function returns the edge by its unique id. 398 /// If the graph does not contain an edge with the given id, 399 /// then the result of the function is undefined. 400 Edge edgeFromId(int) const { return INVALID; } 401 402 /// \brief Return an integer greater or equal to the maximum 403 /// edge id. 404 /// 405 /// This function returns an integer greater or equal to the 406 /// maximum edge id. 407 int maxEdgeId() const { return -1; } 405 408 406 409 template <typename _Graph> … … 408 411 409 412 void constraints() { 410 checkConcept<Base, _Graph >();411 413 checkConcept<IDableDigraphComponent<Base>, _Graph >(); 412 414 typename _Graph::Edge edge; … … 422 424 }; 423 425 424 /// \brief Skeleton class for graph NodeIt and ArcIt425 /// 426 /// Skeleton class for graph NodeIt and ArcIt.427 /// 428 template <typename _Graph, typename _Item>429 class GraphItemIt : public _Item {426 /// \brief Concept class for \c NodeIt, \c ArcIt and \c EdgeIt types. 427 /// 428 /// This class describes the concept of \c NodeIt, \c ArcIt and 429 /// \c EdgeIt subtypes of digraph and graph types. 430 template <typename GR, typename Item> 431 class GraphItemIt : public Item { 430 432 public: 431 433 /// \brief Default constructor. 432 434 /// 433 /// @warning The default constructor sets the iterator 434 /// to an undefined value. 435 /// Default constructor. 436 /// \warning The default constructor is not required to set 437 /// the iterator to some well-defined value. So you should consider it 438 /// as uninitialized. 435 439 GraphItemIt() {} 440 436 441 /// \brief Copy constructor. 437 442 /// 438 443 /// Copy constructor. 439 /// 440 GraphItemIt(const GraphItemIt& ) {} 441 /// \brief Sets the iterator to the first item. 442 /// 443 /// Sets the iterator to the first item of \c the graph. 444 /// 445 explicit GraphItemIt(const _Graph&) {} 446 /// \brief Invalid constructor \& conversion. 447 /// 448 /// This constructor initializes the item to be invalid. 444 GraphItemIt(const GraphItemIt& it) : Item(it) {} 445 446 /// \brief Constructor that sets the iterator to the first item. 447 /// 448 /// Constructor that sets the iterator to the first item. 449 explicit GraphItemIt(const GR&) {} 450 451 /// \brief Constructor for conversion from \c INVALID. 452 /// 453 /// Constructor for conversion from \c INVALID. 454 /// It initializes the iterator to be invalid. 449 455 /// \sa Invalid for more details. 450 456 GraphItemIt(Invalid) {} 451 /// \brief Assign operator for items. 452 /// 453 /// The items are assignable.454 /// 457 458 /// \brief Assignment operator. 459 /// 460 /// Assignment operator for the iterator. 455 461 GraphItemIt& operator=(const GraphItemIt&) { return *this; } 456 /// \brief Next item. 457 /// 458 /// Assign the iterator to the next item. 459 /// 462 463 /// \brief Increment the iterator. 464 /// 465 /// This operator increments the iterator, i.e. assigns it to the 466 /// next item. 460 467 GraphItemIt& operator++() { return *this; } 468 461 469 /// \brief Equality operator 462 470 /// 471 /// Equality operator. 463 472 /// Two iterators are equal if and only if they point to the 464 473 /// same object or both are invalid. 465 474 bool operator==(const GraphItemIt&) const { return true;} 475 466 476 /// \brief Inequality operator 467 477 /// 468 /// \sa operator==(Node n) 469 /// 478 /// Inequality operator. 479 /// Two iterators are equal if and only if they point to the 480 /// same object or both are invalid. 470 481 bool operator!=(const GraphItemIt&) const { return true;} 471 482 … … 473 484 struct Constraints { 474 485 void constraints() { 486 checkConcept<GraphItem<>, _GraphItemIt>(); 475 487 _GraphItemIt it1(g); 476 488 _GraphItemIt it2; 489 _GraphItemIt it3 = it1; 490 _GraphItemIt it4 = INVALID; 477 491 478 492 it2 = ++it1; … … 480 494 ++(++it1); 481 495 482 _Item bi = it1;496 Item bi = it1; 483 497 bi = it2; 484 498 } 485 _Graph& g; 486 }; 487 }; 488 489 /// \brief Skeleton class for graph InArcIt and OutArcIt 490 /// 491 /// \note Because InArcIt and OutArcIt may not inherit from the same 492 /// base class, the _selector is a additional template parameter. For 493 /// InArcIt you should instantiate it with character 'i' and for 494 /// OutArcIt with 'o'. 495 template <typename _Graph, 496 typename _Item = typename _Graph::Arc, 497 typename _Base = typename _Graph::Node, 498 char _selector = '0'> 499 class GraphIncIt : public _Item { 499 const GR& g; 500 }; 501 }; 502 503 /// \brief Concept class for \c InArcIt, \c OutArcIt and 504 /// \c IncEdgeIt types. 505 /// 506 /// This class describes the concept of \c InArcIt, \c OutArcIt 507 /// and \c IncEdgeIt subtypes of digraph and graph types. 508 /// 509 /// \note Since these iterator classes do not inherit from the same 510 /// base class, there is an additional template parameter (selector) 511 /// \c sel. For \c InArcIt you should instantiate it with character 512 /// \c 'i', for \c OutArcIt with \c 'o' and for \c IncEdgeIt with \c 'e'. 513 template <typename GR, 514 typename Item = typename GR::Arc, 515 typename Base = typename GR::Node, 516 char sel = '0'> 517 class GraphIncIt : public Item { 500 518 public: 501 519 /// \brief Default constructor. 502 520 /// 503 /// @warning The default constructor sets the iterator 504 /// to an undefined value. 521 /// Default constructor. 522 /// \warning The default constructor is not required to set 523 /// the iterator to some well-defined value. So you should consider it 524 /// as uninitialized. 505 525 GraphIncIt() {} 526 506 527 /// \brief Copy constructor. 507 528 /// 508 529 /// Copy constructor. 509 /// 510 GraphIncIt(GraphIncIt const& gi) : _Item(gi) {} 511 /// \brief Sets the iterator to the first arc incoming into or outgoing 512 /// from the node. 513 /// 514 /// Sets the iterator to the first arc incoming into or outgoing 515 /// from the node. 516 /// 517 explicit GraphIncIt(const _Graph&, const _Base&) {} 518 /// \brief Invalid constructor \& conversion. 519 /// 520 /// This constructor initializes the item to be invalid. 530 GraphIncIt(const GraphIncIt& it) : Item(it) {} 531 532 /// \brief Constructor that sets the iterator to the first 533 /// incoming or outgoing arc. 534 /// 535 /// Constructor that sets the iterator to the first arc 536 /// incoming to or outgoing from the given node. 537 explicit GraphIncIt(const GR&, const Base&) {} 538 539 /// \brief Constructor for conversion from \c INVALID. 540 /// 541 /// Constructor for conversion from \c INVALID. 542 /// It initializes the iterator to be invalid. 521 543 /// \sa Invalid for more details. 522 544 GraphIncIt(Invalid) {} 523 /// \brief Assign operator for iterators. 524 /// 525 /// The iterators are assignable. 526 /// 527 GraphIncIt& operator=(GraphIncIt const&) { return *this; } 528 /// \brief Next item. 529 /// 530 /// Assign the iterator to the next item. 531 /// 545 546 /// \brief Assignment operator. 547 /// 548 /// Assignment operator for the iterator. 549 GraphIncIt& operator=(const GraphIncIt&) { return *this; } 550 551 /// \brief Increment the iterator. 552 /// 553 /// This operator increments the iterator, i.e. assigns it to the 554 /// next arc incoming to or outgoing from the given node. 532 555 GraphIncIt& operator++() { return *this; } 533 556 534 557 /// \brief Equality operator 535 558 /// 559 /// Equality operator. 536 560 /// Two iterators are equal if and only if they point to the 537 561 /// same object or both are invalid. … … 540 564 /// \brief Inequality operator 541 565 /// 542 /// \sa operator==(Node n) 543 /// 566 /// Inequality operator. 567 /// Two iterators are equal if and only if they point to the 568 /// same object or both are invalid. 544 569 bool operator!=(const GraphIncIt&) const { return true;} 545 570 … … 547 572 struct Constraints { 548 573 void constraints() { 549 checkConcept<GraphItem< _selector>, _GraphIncIt>();574 checkConcept<GraphItem<sel>, _GraphIncIt>(); 550 575 _GraphIncIt it1(graph, node); 551 576 _GraphIncIt it2; 577 _GraphIncIt it3 = it1; 578 _GraphIncIt it4 = INVALID; 552 579 553 580 it2 = ++it1; 554 581 ++it2 = it1; 555 582 ++(++it1); 556 _Item e = it1;583 Item e = it1; 557 584 e = it2; 558 559 } 560 561 _Item arc; 562 _Base node; 563 _Graph graph; 564 _GraphIncIt it; 565 }; 566 }; 567 568 569 /// \brief An empty iterable digraph class. 570 /// 571 /// This class provides beside the core digraph features 572 /// iterator based iterable interface for the digraph structure. 585 } 586 const Base& node; 587 const GR& graph; 588 }; 589 }; 590 591 /// \brief Skeleton class for iterable directed graphs. 592 /// 593 /// This class describes the interface of iterable directed 594 /// graphs. It extends \ref BaseDigraphComponent with the core 595 /// iterable interface. 573 596 /// This concept is part of the Digraph concept. 574 template <typename _Base= BaseDigraphComponent>575 class IterableDigraphComponent : public _Base{576 577 public: 578 579 typedef _BaseBase;597 template <typename BAS = BaseDigraphComponent> 598 class IterableDigraphComponent : public BAS { 599 600 public: 601 602 typedef BAS Base; 580 603 typedef typename Base::Node Node; 581 604 typedef typename Base::Arc Arc; … … 583 606 typedef IterableDigraphComponent Digraph; 584 607 585 /// \name Base iteration586 /// 587 /// This interface provides functions for iteration on digraph items 608 /// \name Base Iteration 609 /// 610 /// This interface provides functions for iteration on digraph items. 588 611 /// 589 612 /// @{ 590 613 591 /// \brief Gives back the first node in the iterating order. 592 /// 593 /// Gives back the first node in the iterating order. 594 /// 614 /// \brief Return the first node. 615 /// 616 /// This function gives back the first node in the iteration order. 595 617 void first(Node&) const {} 596 618 597 /// \brief Gives back the next node in the iterating order. 598 /// 599 /// Gives back the next node in the iterating order. 600 /// 619 /// \brief Return the next node. 620 /// 621 /// This function gives back the next node in the iteration order. 601 622 void next(Node&) const {} 602 623 603 /// \brief Gives back the first arc in the iterating order. 604 /// 605 /// Gives back the first arc in the iterating order. 606 /// 624 /// \brief Return the first arc. 625 /// 626 /// This function gives back the first arc in the iteration order. 607 627 void first(Arc&) const {} 608 628 609 /// \brief Gives back the next arc in the iterating order. 610 /// 611 /// Gives back the next arc in the iterating order. 612 /// 629 /// \brief Return the next arc. 630 /// 631 /// This function gives back the next arc in the iteration order. 613 632 void next(Arc&) const {} 614 633 615 616 /// \brief Gives back the first of the arcs point to the given 617 /// node. 618 /// 619 /// Gives back the first of the arcs point to the given node. 620 /// 634 /// \brief Return the first arc incomming to the given node. 635 /// 636 /// This function gives back the first arc incomming to the 637 /// given node. 621 638 void firstIn(Arc&, const Node&) const {} 622 639 623 /// \brief Gives back the next of the arcs points to the given 624 /// node. 625 /// 626 /// Gives back the next of the arcs points to the given node. 627 /// 640 /// \brief Return the next arc incomming to the given node. 641 /// 642 /// This function gives back the next arc incomming to the 643 /// given node. 628 644 void nextIn(Arc&) const {} 629 645 630 /// \brief Gives back the first of the arcs start from the 646 /// \brief Return the first arc outgoing form the given node. 647 /// 648 /// This function gives back the first arc outgoing form the 631 649 /// given node. 632 ///633 /// Gives back the first of the arcs start from the given node.634 ///635 650 void firstOut(Arc&, const Node&) const {} 636 651 637 /// \brief Gives back the next of the arcs start from the given 638 /// node. 639 /// 640 /// Gives back the next of the arcs start from the given node. 641 /// 652 /// \brief Return the next arc outgoing form the given node. 653 /// 654 /// This function gives back the next arc outgoing form the 655 /// given node. 642 656 void nextOut(Arc&) const {} 643 657 644 658 /// @} 645 659 646 /// \name Class based iteration647 /// 648 /// This interface provides functions for iteration on digraph items660 /// \name Class Based Iteration 661 /// 662 /// This interface provides iterator classes for digraph items. 649 663 /// 650 664 /// @{ … … 656 670 typedef GraphItemIt<Digraph, Node> NodeIt; 657 671 658 /// \brief This iterator goes through each node.659 /// 660 /// This iterator goes through each node.672 /// \brief This iterator goes through each arc. 673 /// 674 /// This iterator goes through each arc. 661 675 /// 662 676 typedef GraphItemIt<Digraph, Arc> ArcIt; … … 664 678 /// \brief This iterator goes trough the incoming arcs of a node. 665 679 /// 666 /// This iterator goes trough the \e inc coming arcs of a certain node680 /// This iterator goes trough the \e incoming arcs of a certain node 667 681 /// of a digraph. 668 682 typedef GraphIncIt<Digraph, Arc, Node, 'i'> InArcIt; … … 676 690 /// \brief The base node of the iterator. 677 691 /// 678 /// Gives back the base node of the iterator.679 /// It is always the target of the pointed arc.692 /// This function gives back the base node of the iterator. 693 /// It is always the target node of the pointed arc. 680 694 Node baseNode(const InArcIt&) const { return INVALID; } 681 695 682 696 /// \brief The running node of the iterator. 683 697 /// 684 /// Gives back the running node of the iterator.685 /// It is always the source of the pointed arc.698 /// This function gives back the running node of the iterator. 699 /// It is always the source node of the pointed arc. 686 700 Node runningNode(const InArcIt&) const { return INVALID; } 687 701 688 702 /// \brief The base node of the iterator. 689 703 /// 690 /// Gives back the base node of the iterator.691 /// It is always the source of the pointed arc.704 /// This function gives back the base node of the iterator. 705 /// It is always the source node of the pointed arc. 692 706 Node baseNode(const OutArcIt&) const { return INVALID; } 693 707 694 708 /// \brief The running node of the iterator. 695 709 /// 696 /// Gives back the running node of the iterator.697 /// It is always the target of the pointed arc.710 /// This function gives back the running node of the iterator. 711 /// It is always the target node of the pointed arc. 698 712 Node runningNode(const OutArcIt&) const { return INVALID; } 699 713 … … 737 751 738 752 typename _Digraph::Node n; 739 typename _Digraph::InArcIt ieit(INVALID);740 typename _Digraph::OutArcIt oeit(INVALID);741 n = digraph.baseNode(i eit);742 n = digraph.runningNode(i eit);743 n = digraph.baseNode(o eit);744 n = digraph.runningNode(o eit);753 const typename _Digraph::InArcIt iait(INVALID); 754 const typename _Digraph::OutArcIt oait(INVALID); 755 n = digraph.baseNode(iait); 756 n = digraph.runningNode(iait); 757 n = digraph.baseNode(oait); 758 n = digraph.runningNode(oait); 745 759 ignore_unused_variable_warning(n); 746 760 } … … 748 762 749 763 const _Digraph& digraph; 750 751 752 }; 753 754 /// \brief An empty iterable undirected graph class.755 /// 756 /// This class provides beside the core graph features iterator757 /// based iterable interface for the undirected graph structure.764 }; 765 }; 766 767 /// \brief Skeleton class for iterable undirected graphs. 768 /// 769 /// This class describes the interface of iterable undirected 770 /// graphs. It extends \ref IterableDigraphComponent with the core 771 /// iterable interface of undirected graphs. 758 772 /// This concept is part of the Graph concept. 759 template <typename _Base= BaseGraphComponent>760 class IterableGraphComponent : public IterableDigraphComponent< _Base> {761 public: 762 763 typedef _BaseBase;773 template <typename BAS = BaseGraphComponent> 774 class IterableGraphComponent : public IterableDigraphComponent<BAS> { 775 public: 776 777 typedef BAS Base; 764 778 typedef typename Base::Node Node; 765 779 typedef typename Base::Arc Arc; … … 769 783 typedef IterableGraphComponent Graph; 770 784 771 /// \name Base iteration 772 /// 773 /// This interface provides functions for iteration on graph items 785 /// \name Base Iteration 786 /// 787 /// This interface provides functions for iteration on edges. 788 /// 774 789 /// @{ 775 790 776 using IterableDigraphComponent<_Base>::first; 777 using IterableDigraphComponent<_Base>::next; 778 779 /// \brief Gives back the first edge in the iterating 780 /// order. 781 /// 782 /// Gives back the first edge in the iterating order. 783 /// 791 using IterableDigraphComponent<Base>::first; 792 using IterableDigraphComponent<Base>::next; 793 794 /// \brief Return the first edge. 795 /// 796 /// This function gives back the first edge in the iteration order. 784 797 void first(Edge&) const {} 785 798 786 /// \brief Gives back the next edge in the iterating 787 /// order. 788 /// 789 /// Gives back the next edge in the iterating order. 790 /// 799 /// \brief Return the next edge. 800 /// 801 /// This function gives back the next edge in the iteration order. 791 802 void next(Edge&) const {} 792 803 793 794 /// \brief Gives back the first of the edges from the 804 /// \brief Return the first edge incident to the given node. 805 /// 806 /// This function gives back the first edge incident to the given 807 /// node. The bool parameter gives back the direction for which the 808 /// source node of the directed arc representing the edge is the 795 809 /// given node. 796 ///797 /// Gives back the first of the edges from the given798 /// node. The bool parameter gives back that direction which799 /// gives a good direction of the edge so the source of the800 /// directed arc is the given node.801 810 void firstInc(Edge&, bool&, const Node&) const {} 802 811 … … 804 813 /// given node. 805 814 /// 806 /// Gives back the next of the edges from the given 807 /// node. The bool parameter should be used as the \c firstInc() 808 /// use it. 815 /// This function gives back the next edge incident to the given 816 /// node. The bool parameter should be used as \c firstInc() use it. 809 817 void nextInc(Edge&, bool&) const {} 810 818 811 using IterableDigraphComponent< _Base>::baseNode;812 using IterableDigraphComponent< _Base>::runningNode;819 using IterableDigraphComponent<Base>::baseNode; 820 using IterableDigraphComponent<Base>::runningNode; 813 821 814 822 /// @} 815 823 816 /// \name Class based iteration817 /// 818 /// This interface provides functions for iteration on graph items824 /// \name Class Based Iteration 825 /// 826 /// This interface provides iterator classes for edges. 819 827 /// 820 828 /// @{ 821 829 822 /// \brief This iterator goes through each node.823 /// 824 /// This iterator goes through each node.830 /// \brief This iterator goes through each edge. 831 /// 832 /// This iterator goes through each edge. 825 833 typedef GraphItemIt<Graph, Edge> EdgeIt; 826 /// \brief This iterator goes trough the incident arcs of a 834 835 /// \brief This iterator goes trough the incident edges of a 827 836 /// node. 828 837 /// 829 /// This iterator goes trough the incident arcs of a certain838 /// This iterator goes trough the incident edges of a certain 830 839 /// node of a graph. 831 typedef GraphIncIt<Graph, Edge, Node, 'u'> IncEdgeIt; 840 typedef GraphIncIt<Graph, Edge, Node, 'e'> IncEdgeIt; 841 832 842 /// \brief The base node of the iterator. 833 843 /// 834 /// Gives back the base node of the iterator.844 /// This function gives back the base node of the iterator. 835 845 Node baseNode(const IncEdgeIt&) const { return INVALID; } 836 846 837 847 /// \brief The running node of the iterator. 838 848 /// 839 /// Gives back the running node of the iterator.849 /// This function gives back the running node of the iterator. 840 850 Node runningNode(const IncEdgeIt&) const { return INVALID; } 841 851 … … 866 876 typename _Graph::EdgeIt >(); 867 877 checkConcept<GraphIncIt<_Graph, typename _Graph::Edge, 868 typename _Graph::Node, ' u'>, typename _Graph::IncEdgeIt>();878 typename _Graph::Node, 'e'>, typename _Graph::IncEdgeIt>(); 869 879 870 880 typename _Graph::Node n; 871 typename _Graph::IncEdgeIt ueit(INVALID);872 n = graph.baseNode( ueit);873 n = graph.runningNode( ueit);881 const typename _Graph::IncEdgeIt ieit(INVALID); 882 n = graph.baseNode(ieit); 883 n = graph.runningNode(ieit); 874 884 } 875 885 } 876 886 877 887 const _Graph& graph; 878 879 880 }; 881 882 /// \brief An empty alteration notifier digraph class.883 /// 884 /// This class provides beside the core digraph featuresalteration885 /// notifier interface for the digraph structure. Thisimplements888 }; 889 }; 890 891 /// \brief Skeleton class for alterable directed graphs. 892 /// 893 /// This class describes the interface of alterable directed 894 /// graphs. It extends \ref BaseDigraphComponent with the alteration 895 /// notifier interface. It implements 886 896 /// an observer-notifier pattern for each digraph item. More 887 897 /// obsevers can be registered into the notifier and whenever an 888 /// alteration occured in the digraph all the observers will 898 /// alteration occured in the digraph all the observers will be 889 899 /// notified about it. 890 template <typename _Base= BaseDigraphComponent>891 class AlterableDigraphComponent : public _Base{892 public: 893 894 typedef _BaseBase;900 template <typename BAS = BaseDigraphComponent> 901 class AlterableDigraphComponent : public BAS { 902 public: 903 904 typedef BAS Base; 895 905 typedef typename Base::Node Node; 896 906 typedef typename Base::Arc Arc; 897 907 898 908 899 /// The node observer registry.909 /// Node alteration notifier class. 900 910 typedef AlterationNotifier<AlterableDigraphComponent, Node> 901 911 NodeNotifier; 902 /// The arc observer registry.912 /// Arc alteration notifier class. 903 913 typedef AlterationNotifier<AlterableDigraphComponent, Arc> 904 914 ArcNotifier; 905 915 906 /// \brief Gives backthe node alteration notifier.907 /// 908 /// Gives back the node alteration notifier.916 /// \brief Return the node alteration notifier. 917 /// 918 /// This function gives back the node alteration notifier. 909 919 NodeNotifier& notifier(Node) const { 910 return NodeNotifier();920 return NodeNotifier(); 911 921 } 912 922 913 /// \brief Gives backthe arc alteration notifier.914 /// 915 /// Gives back the arc alteration notifier.923 /// \brief Return the arc alteration notifier. 924 /// 925 /// This function gives back the arc alteration notifier. 916 926 ArcNotifier& notifier(Arc) const { 917 927 return ArcNotifier(); … … 933 943 934 944 const _Digraph& digraph; 935 936 }; 937 938 }; 939 940 /// \brief An empty alteration notifier undirected graph class. 941 /// 942 /// This class provides beside the core graph features alteration 943 /// notifier interface for the graph structure. This implements 944 /// an observer-notifier pattern for each graph item. More 945 }; 946 }; 947 948 /// \brief Skeleton class for alterable undirected graphs. 949 /// 950 /// This class describes the interface of alterable undirected 951 /// graphs. It extends \ref AlterableDigraphComponent with the alteration 952 /// notifier interface of undirected graphs. It implements 953 /// an observer-notifier pattern for the edges. More 945 954 /// obsevers can be registered into the notifier and whenever an 946 /// alteration occured in the graph all the observers will 955 /// alteration occured in the graph all the observers will be 947 956 /// notified about it. 948 template <typename _Base= BaseGraphComponent>949 class AlterableGraphComponent : public AlterableDigraphComponent< _Base> {950 public: 951 952 typedef _BaseBase;957 template <typename BAS = BaseGraphComponent> 958 class AlterableGraphComponent : public AlterableDigraphComponent<BAS> { 959 public: 960 961 typedef BAS Base; 953 962 typedef typename Base::Edge Edge; 954 963 955 964 956 /// The arc observer registry.965 /// Edge alteration notifier class. 957 966 typedef AlterationNotifier<AlterableGraphComponent, Edge> 958 967 EdgeNotifier; 959 968 960 /// \brief Gives back the arcalteration notifier.961 /// 962 /// Gives back the arcalteration notifier.969 /// \brief Return the edge alteration notifier. 970 /// 971 /// This function gives back the edge alteration notifier. 963 972 EdgeNotifier& notifier(Edge) const { 964 973 return EdgeNotifier(); … … 968 977 struct Constraints { 969 978 void constraints() { 970 checkConcept<Alterable GraphComponent<Base>, _Graph>();979 checkConcept<AlterableDigraphComponent<Base>, _Graph>(); 971 980 typename _Graph::EdgeNotifier& uen 972 981 = graph.notifier(typename _Graph::Edge()); … … 975 984 976 985 const _Graph& graph; 977 978 }; 979 980 }; 981 982 /// \brief Class describing the concept of graph maps 983 /// 984 /// This class describes the common interface of the graph maps 985 /// (NodeMap, ArcMap), that is maps that can be used to 986 /// associate data to graph descriptors (nodes or arcs). 987 template <typename _Graph, typename _Item, typename _Value> 988 class GraphMap : public ReadWriteMap<_Item, _Value> { 989 public: 990 991 typedef ReadWriteMap<_Item, _Value> Parent; 992 993 /// The graph type of the map. 994 typedef _Graph Graph; 986 }; 987 }; 988 989 /// \brief Concept class for standard graph maps. 990 /// 991 /// This class describes the concept of standard graph maps, i.e. 992 /// the \c NodeMap, \c ArcMap and \c EdgeMap subtypes of digraph and 993 /// graph types, which can be used for associating data to graph items. 994 /// The standard graph maps must conform to the ReferenceMap concept. 995 template <typename GR, typename K, typename V> 996 class GraphMap : public ReferenceMap<K, V, V&, const V&> { 997 typedef ReferenceMap<K, V, V&, const V&> Parent; 998 999 public: 1000 995 1001 /// The key type of the map. 996 typedef _ItemKey;1002 typedef K Key; 997 1003 /// The value type of the map. 998 typedef _Value Value; 1004 typedef V Value; 1005 /// The reference type of the map. 1006 typedef Value& Reference; 1007 /// The const reference type of the map. 1008 typedef const Value& ConstReference; 1009 1010 // The reference map tag. 1011 typedef True ReferenceMapTag; 999 1012 1000 1013 /// \brief Construct a new map. 1001 1014 /// 1002 1015 /// Construct a new map for the graph. 1003 explicit GraphMap(const G raph&) {}1016 explicit GraphMap(const GR&) {} 1004 1017 /// \brief Construct a new map with default value. 1005 1018 /// 1006 /// Construct a new map for the graph and initali se the values.1007 GraphMap(const G raph&, const Value&) {}1019 /// Construct a new map for the graph and initalize the values. 1020 GraphMap(const GR&, const Value&) {} 1008 1021 1009 1022 private: … … 1013 1026 GraphMap(const GraphMap&) : Parent() {} 1014 1027 1015 /// \brief Assign operator.1016 /// 1017 /// Assign operator. It does not mofify the underlying graph,1028 /// \brief Assignment operator. 1029 /// 1030 /// Assignment operator. It does not mofify the underlying graph, 1018 1031 /// it just iterates on the current item set and set the map 1019 1032 /// with the value returned by the assigned map. … … 1028 1041 struct Constraints { 1029 1042 void constraints() { 1030 checkConcept<ReadWriteMap<Key, Value>, _Map >(); 1031 // Construction with a graph parameter 1032 _Map a(g); 1033 // Constructor with a graph and a default value parameter 1034 _Map a2(g,t); 1035 // Copy constructor. 1036 // _Map b(c); 1037 1043 checkConcept 1044 <ReferenceMap<Key, Value, Value&, const Value&>, _Map>(); 1045 _Map m1(g); 1046 _Map m2(g,t); 1047 1048 // Copy constructor 1049 // _Map m3(m); 1050 1051 // Assignment operator 1038 1052 // ReadMap<Key, Value> cmap; 1039 // b= cmap;1040 1041 ignore_unused_variable_warning( a);1042 ignore_unused_variable_warning( a2);1043 // ignore_unused_variable_warning( b);1044 } 1045 1046 const _Map & c;1047 const G raph&g;1053 // m3 = cmap; 1054 1055 ignore_unused_variable_warning(m1); 1056 ignore_unused_variable_warning(m2); 1057 // ignore_unused_variable_warning(m3); 1058 } 1059 1060 const _Map &m; 1061 const GR &g; 1048 1062 const typename GraphMap::Value &t; 1049 1063 }; … … 1051 1065 }; 1052 1066 1053 /// \brief An empty mappable digraph class. 1054 /// 1055 /// This class provides beside the core digraph features 1056 /// map interface for the digraph structure. 1067 /// \brief Skeleton class for mappable directed graphs. 1068 /// 1069 /// This class describes the interface of mappable directed graphs. 1070 /// It extends \ref BaseDigraphComponent with the standard digraph 1071 /// map classes, namely \c NodeMap and \c ArcMap. 1057 1072 /// This concept is part of the Digraph concept. 1058 template <typename _Base= BaseDigraphComponent>1059 class MappableDigraphComponent : public _Base{1060 public: 1061 1062 typedef _BaseBase;1073 template <typename BAS = BaseDigraphComponent> 1074 class MappableDigraphComponent : public BAS { 1075 public: 1076 1077 typedef BAS Base; 1063 1078 typedef typename Base::Node Node; 1064 1079 typedef typename Base::Arc Arc; … … 1066 1081 typedef MappableDigraphComponent Digraph; 1067 1082 1068 /// \brief ReadWrite map of the nodes. 1069 /// 1070 /// ReadWrite map of the nodes. 1071 /// 1072 template <typename _Value> 1073 class NodeMap : public GraphMap<Digraph, Node, _Value> { 1083 /// \brief Standard graph map for the nodes. 1084 /// 1085 /// Standard graph map for the nodes. 1086 /// It conforms to the ReferenceMap concept. 1087 template <typename V> 1088 class NodeMap : public GraphMap<MappableDigraphComponent, Node, V> { 1089 typedef GraphMap<MappableDigraphComponent, Node, V> Parent; 1090 1074 1091 public: 1075 typedef GraphMap<MappableDigraphComponent, Node, _Value> Parent;1076 1077 1092 /// \brief Construct a new map. 1078 1093 /// … … 1083 1098 /// \brief Construct a new map with default value. 1084 1099 /// 1085 /// Construct a new map for the digraph and initali se the values.1086 NodeMap(const MappableDigraphComponent& digraph, const _Value& value)1100 /// Construct a new map for the digraph and initalize the values. 1101 NodeMap(const MappableDigraphComponent& digraph, const V& value) 1087 1102 : Parent(digraph, value) {} 1088 1103 … … 1093 1108 NodeMap(const NodeMap& nm) : Parent(nm) {} 1094 1109 1095 /// \brief Assign operator.1096 /// 1097 /// Assign operator.1110 /// \brief Assignment operator. 1111 /// 1112 /// Assignment operator. 1098 1113 template <typename CMap> 1099 1114 NodeMap& operator=(const CMap&) { 1100 checkConcept<ReadMap<Node, _Value>, CMap>();1115 checkConcept<ReadMap<Node, V>, CMap>(); 1101 1116 return *this; 1102 1117 } … … 1104 1119 }; 1105 1120 1106 /// \brief ReadWrite map of the arcs. 1107 /// 1108 /// ReadWrite map of the arcs. 1109 /// 1110 template <typename _Value> 1111 class ArcMap : public GraphMap<Digraph, Arc, _Value> { 1121 /// \brief Standard graph map for the arcs. 1122 /// 1123 /// Standard graph map for the arcs. 1124 /// It conforms to the ReferenceMap concept. 1125 template <typename V> 1126 class ArcMap : public GraphMap<MappableDigraphComponent, Arc, V> { 1127 typedef GraphMap<MappableDigraphComponent, Arc, V> Parent; 1128 1112 1129 public: 1113 typedef GraphMap<MappableDigraphComponent, Arc, _Value> Parent;1114 1115 1130 /// \brief Construct a new map. 1116 1131 /// … … 1121 1136 /// \brief Construct a new map with default value. 1122 1137 /// 1123 /// Construct a new map for the digraph and initali se the values.1124 ArcMap(const MappableDigraphComponent& digraph, const _Value& value)1138 /// Construct a new map for the digraph and initalize the values. 1139 ArcMap(const MappableDigraphComponent& digraph, const V& value) 1125 1140 : Parent(digraph, value) {} 1126 1141 … … 1131 1146 ArcMap(const ArcMap& nm) : Parent(nm) {} 1132 1147 1133 /// \brief Assign operator.1134 /// 1135 /// Assign operator.1148 /// \brief Assignment operator. 1149 /// 1150 /// Assignment operator. 1136 1151 template <typename CMap> 1137 1152 ArcMap& operator=(const CMap&) { 1138 checkConcept<ReadMap<Arc, _Value>, CMap>();1153 checkConcept<ReadMap<Arc, V>, CMap>(); 1139 1154 return *this; 1140 1155 } … … 1183 1198 } 1184 1199 1185 _Digraph& digraph; 1186 }; 1187 }; 1188 1189 /// \brief An empty mappable base bipartite graph class. 1190 /// 1191 /// This class provides beside the core graph features 1192 /// map interface for the graph structure. 1200 const _Digraph& digraph; 1201 }; 1202 }; 1203 1204 /// \brief Skeleton class for mappable undirected graphs. 1205 /// 1206 /// This class describes the interface of mappable undirected graphs. 1207 /// It extends \ref MappableDigraphComponent with the standard graph 1208 /// map class for edges (\c EdgeMap). 1193 1209 /// This concept is part of the Graph concept. 1194 template <typename _Base= BaseGraphComponent>1195 class MappableGraphComponent : public MappableDigraphComponent< _Base> {1196 public: 1197 1198 typedef _BaseBase;1210 template <typename BAS = BaseGraphComponent> 1211 class MappableGraphComponent : public MappableDigraphComponent<BAS> { 1212 public: 1213 1214 typedef BAS Base; 1199 1215 typedef typename Base::Edge Edge; 1200 1216 1201 1217 typedef MappableGraphComponent Graph; 1202 1218 1203 /// \brief ReadWrite map of the edges. 1204 /// 1205 /// ReadWrite map of the edges. 1206 /// 1207 template <typename _Value> 1208 class EdgeMap : public GraphMap<Graph, Edge, _Value> { 1219 /// \brief Standard graph map for the edges. 1220 /// 1221 /// Standard graph map for the edges. 1222 /// It conforms to the ReferenceMap concept. 1223 template <typename V> 1224 class EdgeMap : public GraphMap<MappableGraphComponent, Edge, V> { 1225 typedef GraphMap<MappableGraphComponent, Edge, V> Parent; 1226 1209 1227 public: 1210 typedef GraphMap<MappableGraphComponent, Edge, _Value> Parent;1211 1212 1228 /// \brief Construct a new map. 1213 1229 /// … … 1218 1234 /// \brief Construct a new map with default value. 1219 1235 /// 1220 /// Construct a new map for the graph and initali se the values.1221 EdgeMap(const MappableGraphComponent& graph, const _Value& value)1236 /// Construct a new map for the graph and initalize the values. 1237 EdgeMap(const MappableGraphComponent& graph, const V& value) 1222 1238 : Parent(graph, value) {} 1223 1239 … … 1228 1244 EdgeMap(const EdgeMap& nm) : Parent(nm) {} 1229 1245 1230 /// \brief Assign operator.1231 /// 1232 /// Assign operator.1246 /// \brief Assignment operator. 1247 /// 1248 /// Assignment operator. 1233 1249 template <typename CMap> 1234 1250 EdgeMap& operator=(const CMap&) { 1235 checkConcept<ReadMap<Edge, _Value>, CMap>();1251 checkConcept<ReadMap<Edge, V>, CMap>(); 1236 1252 return *this; 1237 1253 } … … 1250 1266 1251 1267 void constraints() { 1252 checkConcept<Mappable GraphComponent<Base>, _Graph>();1268 checkConcept<MappableDigraphComponent<Base>, _Graph>(); 1253 1269 1254 1270 { // int map test … … 1267 1283 } 1268 1284 1269 _Graph& graph; 1270 }; 1271 }; 1272 1273 /// \brief An empty extendable digraph class. 1274 /// 1275 /// This class provides beside the core digraph features digraph 1276 /// extendable interface for the digraph structure. The main 1277 /// difference between the base and this interface is that the 1278 /// digraph alterations should handled already on this level. 1279 template <typename _Base = BaseDigraphComponent> 1280 class ExtendableDigraphComponent : public _Base { 1281 public: 1282 typedef _Base Base; 1283 1284 typedef typename _Base::Node Node; 1285 typedef typename _Base::Arc Arc; 1286 1287 /// \brief Adds a new node to the digraph. 1288 /// 1289 /// Adds a new node to the digraph. 1290 /// 1285 const _Graph& graph; 1286 }; 1287 }; 1288 1289 /// \brief Skeleton class for extendable directed graphs. 1290 /// 1291 /// This class describes the interface of extendable directed graphs. 1292 /// It extends \ref BaseDigraphComponent with functions for adding 1293 /// nodes and arcs to the digraph. 1294 /// This concept requires \ref AlterableDigraphComponent. 1295 template <typename BAS = BaseDigraphComponent> 1296 class ExtendableDigraphComponent : public BAS { 1297 public: 1298 typedef BAS Base; 1299 1300 typedef typename Base::Node Node; 1301 typedef typename Base::Arc Arc; 1302 1303 /// \brief Add a new node to the digraph. 1304 /// 1305 /// This function adds a new node to the digraph. 1291 1306 Node addNode() { 1292 1307 return INVALID; 1293 1308 } 1294 1309 1295 /// \brief Adds a new arc connects the given two nodes. 1296 /// 1297 /// Adds a new arc connects the the given two nodes. 1310 /// \brief Add a new arc connecting the given two nodes. 1311 /// 1312 /// This function adds a new arc connecting the given two nodes 1313 /// of the digraph. 1298 1314 Arc addArc(const Node&, const Node&) { 1299 1315 return INVALID; … … 1315 1331 }; 1316 1332 1317 /// \brief An empty extendable base undirected graph class. 1318 /// 1319 /// This class provides beside the core undirected graph features 1320 /// core undircted graph extend interface for the graph structure. 1321 /// The main difference between the base and this interface is 1322 /// that the graph alterations should handled already on this 1323 /// level. 1324 template <typename _Base = BaseGraphComponent> 1325 class ExtendableGraphComponent : public _Base { 1326 public: 1327 1328 typedef _Base Base; 1329 typedef typename _Base::Node Node; 1330 typedef typename _Base::Edge Edge; 1331 1332 /// \brief Adds a new node to the graph. 1333 /// 1334 /// Adds a new node to the graph. 1335 /// 1333 /// \brief Skeleton class for extendable undirected graphs. 1334 /// 1335 /// This class describes the interface of extendable undirected graphs. 1336 /// It extends \ref BaseGraphComponent with functions for adding 1337 /// nodes and edges to the graph. 1338 /// This concept requires \ref AlterableGraphComponent. 1339 template <typename BAS = BaseGraphComponent> 1340 class ExtendableGraphComponent : public BAS { 1341 public: 1342 1343 typedef BAS Base; 1344 typedef typename Base::Node Node; 1345 typedef typename Base::Edge Edge; 1346 1347 /// \brief Add a new node to the digraph. 1348 /// 1349 /// This function adds a new node to the digraph. 1336 1350 Node addNode() { 1337 1351 return INVALID; 1338 1352 } 1339 1353 1340 /// \brief Adds a new arc connects the given two nodes. 1341 /// 1342 /// Adds a new arc connects the the given two nodes. 1343 Edge addArc(const Node&, const Node&) { 1354 /// \brief Add a new edge connecting the given two nodes. 1355 /// 1356 /// This function adds a new edge connecting the given two nodes 1357 /// of the graph. 1358 Edge addEdge(const Node&, const Node&) { 1344 1359 return INVALID; 1345 1360 } … … 1360 1375 }; 1361 1376 1362 /// \brief An empty erasable digraph class.1363 /// 1364 /// This class provides beside the core digraph features core erase1365 /// functions for the digraph structure. The main difference between1366 /// the base and this interface is that the digraph alterations1367 /// should handled already on this level.1368 template <typename _Base= BaseDigraphComponent>1369 class ErasableDigraphComponent : public _Base{1370 public: 1371 1372 typedef _BaseBase;1377 /// \brief Skeleton class for erasable directed graphs. 1378 /// 1379 /// This class describes the interface of erasable directed graphs. 1380 /// It extends \ref BaseDigraphComponent with functions for removing 1381 /// nodes and arcs from the digraph. 1382 /// This concept requires \ref AlterableDigraphComponent. 1383 template <typename BAS = BaseDigraphComponent> 1384 class ErasableDigraphComponent : public BAS { 1385 public: 1386 1387 typedef BAS Base; 1373 1388 typedef typename Base::Node Node; 1374 1389 typedef typename Base::Arc Arc; … … 1376 1391 /// \brief Erase a node from the digraph. 1377 1392 /// 1378 /// Erase a node from the digraph. This function should1379 /// erase all arcs connectingto the node.1393 /// This function erases the given node from the digraph and all arcs 1394 /// connected to the node. 1380 1395 void erase(const Node&) {} 1381 1396 1382 1397 /// \brief Erase an arc from the digraph. 1383 1398 /// 1384 /// Erase an arc from the digraph. 1385 /// 1399 /// This function erases the given arc from the digraph. 1386 1400 void erase(const Arc&) {} 1387 1401 … … 1390 1404 void constraints() { 1391 1405 checkConcept<Base, _Digraph>(); 1392 typename _Digraph::Node node;1406 const typename _Digraph::Node node(INVALID); 1393 1407 digraph.erase(node); 1394 typename _Digraph::Arc arc;1408 const typename _Digraph::Arc arc(INVALID); 1395 1409 digraph.erase(arc); 1396 1410 } … … 1400 1414 }; 1401 1415 1402 /// \brief An empty erasable base undirected graph class.1403 /// 1404 /// This class provides beside the core undirected graph features1405 /// core erase functions for the undirceted graph structure. The1406 /// main difference between the base and this interface is that1407 /// the graph alterations should handled already on this level.1408 template <typename _Base= BaseGraphComponent>1409 class ErasableGraphComponent : public _Base{1410 public: 1411 1412 typedef _BaseBase;1416 /// \brief Skeleton class for erasable undirected graphs. 1417 /// 1418 /// This class describes the interface of erasable undirected graphs. 1419 /// It extends \ref BaseGraphComponent with functions for removing 1420 /// nodes and edges from the graph. 1421 /// This concept requires \ref AlterableGraphComponent. 1422 template <typename BAS = BaseGraphComponent> 1423 class ErasableGraphComponent : public BAS { 1424 public: 1425 1426 typedef BAS Base; 1413 1427 typedef typename Base::Node Node; 1414 1428 typedef typename Base::Edge Edge; … … 1416 1430 /// \brief Erase a node from the graph. 1417 1431 /// 1418 /// Erase a node from the graph. This function should erase1419 /// arcs connectingto the node.1432 /// This function erases the given node from the graph and all edges 1433 /// connected to the node. 1420 1434 void erase(const Node&) {} 1421 1435 1422 /// \brief Erase an arc from the graph. 1423 /// 1424 /// Erase an arc from the graph. 1425 /// 1436 /// \brief Erase an edge from the digraph. 1437 /// 1438 /// This function erases the given edge from the digraph. 1426 1439 void erase(const Edge&) {} 1427 1440 … … 1430 1443 void constraints() { 1431 1444 checkConcept<Base, _Graph>(); 1432 typename _Graph::Node node;1445 const typename _Graph::Node node(INVALID); 1433 1446 graph.erase(node); 1434 typename _Graph::Edge edge;1447 const typename _Graph::Edge edge(INVALID); 1435 1448 graph.erase(edge); 1436 1449 } … … 1440 1453 }; 1441 1454 1442 /// \brief An empty clearable base digraph class.1443 /// 1444 /// This class provides beside the core digraph features core clear1445 /// functions for the digraph structure. The main difference between1446 /// the base and this interface is that the digraph alterations1447 /// should handled already on this level.1448 template <typename _Base= BaseDigraphComponent>1449 class ClearableDigraphComponent : public _Base{1450 public: 1451 1452 typedef _BaseBase;1455 /// \brief Skeleton class for clearable directed graphs. 1456 /// 1457 /// This class describes the interface of clearable directed graphs. 1458 /// It extends \ref BaseDigraphComponent with a function for clearing 1459 /// the digraph. 1460 /// This concept requires \ref AlterableDigraphComponent. 1461 template <typename BAS = BaseDigraphComponent> 1462 class ClearableDigraphComponent : public BAS { 1463 public: 1464 1465 typedef BAS Base; 1453 1466 1454 1467 /// \brief Erase all nodes and arcs from the digraph. 1455 1468 /// 1456 /// Erase all nodes and arcs from the digraph. 1457 /// 1469 /// This function erases all nodes and arcs from the digraph. 1458 1470 void clear() {} 1459 1471 … … 1465 1477 } 1466 1478 1467 _Digraph digraph; 1468 }; 1469 }; 1470 1471 /// \brief An empty clearable base undirected graph class. 1472 /// 1473 /// This class provides beside the core undirected graph features 1474 /// core clear functions for the undirected graph structure. The 1475 /// main difference between the base and this interface is that 1476 /// the graph alterations should handled already on this level. 1477 template <typename _Base = BaseGraphComponent> 1478 class ClearableGraphComponent : public ClearableDigraphComponent<_Base> { 1479 public: 1480 1481 typedef _Base Base; 1479 _Digraph& digraph; 1480 }; 1481 }; 1482 1483 /// \brief Skeleton class for clearable undirected graphs. 1484 /// 1485 /// This class describes the interface of clearable undirected graphs. 1486 /// It extends \ref BaseGraphComponent with a function for clearing 1487 /// the graph. 1488 /// This concept requires \ref AlterableGraphComponent. 1489 template <typename BAS = BaseGraphComponent> 1490 class ClearableGraphComponent : public ClearableDigraphComponent<BAS> { 1491 public: 1492 1493 typedef BAS Base; 1494 1495 /// \brief Erase all nodes and edges from the graph. 1496 /// 1497 /// This function erases all nodes and edges from the graph. 1498 void clear() {} 1482 1499 1483 1500 template <typename _Graph> 1484 1501 struct Constraints { 1485 1502 void constraints() { 1486 checkConcept<ClearableGraphComponent<Base>, _Graph>(); 1487 } 1488 1489 _Graph graph; 1503 checkConcept<Base, _Graph>(); 1504 graph.clear(); 1505 } 1506 1507 _Graph& graph; 1490 1508 }; 1491 1509 }; -
lemon/concepts/heap.h
r290 r631 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 21 21 ///\brief The concept of heaps. 22 22 23 #ifndef LEMON_CONCEPT _HEAP_H24 #define LEMON_CONCEPT _HEAP_H23 #ifndef LEMON_CONCEPTS_HEAP_H 24 #define LEMON_CONCEPTS_HEAP_H 25 25 26 26 #include <lemon/core.h> 27 #include <lemon/concept_check.h> 27 28 28 29 namespace lemon { … … 35 36 /// \brief The heap concept. 36 37 /// 37 /// Concept class describing the main interface of heaps. 38 template <typename Priority, typename ItemIntMap> 38 /// Concept class describing the main interface of heaps. A \e heap 39 /// is a data structure for storing items with specified values called 40 /// \e priorities in such a way that finding the item with minimum 41 /// priority is efficient. In a heap one can change the priority of an 42 /// item, add or erase an item, etc. 43 /// 44 /// \tparam PR Type of the priority of the items. 45 /// \tparam IM A read and writable item map with int values, used 46 /// internally to handle the cross references. 47 /// \tparam Comp A functor class for the ordering of the priorities. 48 /// The default is \c std::less<PR>. 49 #ifdef DOXYGEN 50 template <typename PR, typename IM, typename Comp = std::less<PR> > 51 #else 52 template <typename PR, typename IM> 53 #endif 39 54 class Heap { 40 55 public: 41 56 57 /// Type of the item-int map. 58 typedef IM ItemIntMap; 59 /// Type of the priorities. 60 typedef PR Prio; 42 61 /// Type of the items stored in the heap. 43 62 typedef typename ItemIntMap::Key Item; 44 45 /// Type of the priorities.46 typedef Priority Prio;47 63 48 64 /// \brief Type to represent the states of the items. … … 53 69 /// the user. 54 70 /// 55 /// The \c ItemIntMap must be initialized in such a way, that it56 /// assigns \c PRE_HEAP (<tt>-1</tt>) to every item.71 /// The item-int map must be initialized in such way that it assigns 72 /// \c PRE_HEAP (<tt>-1</tt>) to any element to be put in the heap. 57 73 enum State { 58 IN_HEAP = 0, 59 PRE_HEAP = -1, 60 POST_HEAP = -2 74 IN_HEAP = 0, ///< = 0. The "in heap" state constant. 75 PRE_HEAP = -1, ///< = -1. The "pre heap" state constant. 76 POST_HEAP = -2 ///< = -2. The "post heap" state constant. 61 77 }; 62 78 … … 119 135 /// 120 136 /// Returns the priority of the given item. 137 /// \param i The item. 121 138 /// \pre \c i must be in the heap. 122 /// \param i The item.123 139 Prio operator[](const Item &i) const {} 124 140 … … 137 153 /// 138 154 /// Decreases the priority of an item to the given value. 155 /// \param i The item. 156 /// \param p The priority. 139 157 /// \pre \c i must be stored in the heap with priority at least \c p. 158 void decrease(const Item &i, const Prio &p) {} 159 160 /// \brief Increases the priority of an item to the given value. 161 /// 162 /// Increases the priority of an item to the given value. 140 163 /// \param i The item. 141 164 /// \param p The priority. 142 void decrease(const Item &i, const Prio &p) {}143 144 /// \brief Increases the priority of an item to the given value.145 ///146 /// Increases the priority of an item to the given value.147 165 /// \pre \c i must be stored in the heap with priority at most \c p. 148 /// \param i The item.149 /// \param p The priority.150 166 void increase(const Item &i, const Prio &p) {} 151 167 … … 243 259 } // namespace lemon 244 260 } 245 #endif // LEMON_CONCEPT_PATH_H261 #endif -
lemon/concepts/maps.h
r314 r576 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 17 17 */ 18 18 19 #ifndef LEMON_CONCEPT _MAPS_H20 #define LEMON_CONCEPT _MAPS_H19 #ifndef LEMON_CONCEPTS_MAPS_H 20 #define LEMON_CONCEPTS_MAPS_H 21 21 22 22 #include <lemon/core.h> … … 214 214 } //namespace lemon 215 215 216 #endif // LEMON_CONCEPT_MAPS_H216 #endif -
lemon/concepts/path.h
r281 r606 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 22 22 /// 23 23 24 #ifndef LEMON_CONCEPT _PATH_H25 #define LEMON_CONCEPT _PATH_H24 #ifndef LEMON_CONCEPTS_PATH_H 25 #define LEMON_CONCEPTS_PATH_H 26 26 27 27 #include <lemon/core.h> … … 39 39 /// A skeleton structure for representing directed paths in a 40 40 /// digraph. 41 /// \tparam _DigraphThe digraph type in which the path is.41 /// \tparam GR The digraph type in which the path is. 42 42 /// 43 43 /// In a sense, the path can be treated as a list of arcs. The … … 46 46 /// paths cannot store the source. 47 47 /// 48 template <typename _Digraph>48 template <typename GR> 49 49 class Path { 50 50 public: 51 51 52 52 /// Type of the underlying digraph. 53 typedef _DigraphDigraph;53 typedef GR Digraph; 54 54 /// Arc type of the underlying digraph. 55 55 typedef typename Digraph::Arc Arc; … … 206 206 /// assigned to a real path and the dumpers can be implemented as 207 207 /// an adaptor class to the predecessor map. 208 209 /// \tparam _DigraphThe digraph type in which the path is.208 /// 209 /// \tparam GR The digraph type in which the path is. 210 210 /// 211 211 /// The paths can be constructed from any path type by a 212 212 /// template constructor or a template assignment operator. 213 /// 214 template <typename _Digraph> 213 template <typename GR> 215 214 class PathDumper { 216 215 public: 217 216 218 217 /// Type of the underlying digraph. 219 typedef _DigraphDigraph;218 typedef GR Digraph; 220 219 /// Arc type of the underlying digraph. 221 220 typedef typename Digraph::Arc Arc; … … 306 305 } // namespace lemon 307 306 308 #endif // LEMON_CONCEPT_PATH_H307 #endif -
lemon/config.h.cmake
r515 r674 1 #cmakedefine HAVE_LONG_LONG 1 1 #cmakedefine LEMON_HAVE_LONG_LONG 1 2 #cmakedefine LEMON_HAVE_LP 1 3 #cmakedefine LEMON_HAVE_MIP 1 4 #cmakedefine LEMON_HAVE_GLPK 1 5 #cmakedefine LEMON_HAVE_CPLEX 1 6 #cmakedefine LEMON_HAVE_CLP 1 7 #cmakedefine LEMON_HAVE_CBC 1 -
lemon/config.h.in
r515 r674 1 /* Define to 1 if you have long long */ 2 #undef LEMON_HAVE_LONG_LONG 3 4 /* Define to 1 if you have any LP solver. */ 5 #undef LEMON_HAVE_LP 6 7 /* Define to 1 if you have any MIP solver. */ 8 #undef LEMON_HAVE_MIP 9 1 10 /* Define to 1 if you have CPLEX. */ 2 #undef HAVE_CPLEX11 #undef LEMON_HAVE_CPLEX 3 12 4 13 /* Define to 1 if you have GLPK. */ 5 #undef HAVE_GLPK14 #undef LEMON_HAVE_GLPK 6 15 7 /* Define to 1 if you have long long */ 8 #undef HAVE_LONG_LONG 16 /* Define to 1 if you have SOPLEX */ 17 #undef LEMON_HAVE_SOPLEX 18 19 /* Define to 1 if you have CLP */ 20 #undef LEMON_HAVE_CLP 21 22 /* Define to 1 if you have CBC */ 23 #undef LEMON_HAVE_CBC -
lemon/core.h
r523 r664 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 1035 1035 ///\sa findArc() 1036 1036 ///\sa ArcLookUp, AllArcLookUp, DynArcLookUp 1037 template <typename _Graph> 1038 class ConArcIt : public _Graph::Arc { 1037 template <typename GR> 1038 class ConArcIt : public GR::Arc { 1039 typedef typename GR::Arc Parent; 1040 1039 1041 public: 1040 1042 1041 typedef _Graph Graph; 1042 typedef typename Graph::Arc Parent; 1043 1044 typedef typename Graph::Arc Arc; 1045 typedef typename Graph::Node Node; 1043 typedef typename GR::Arc Arc; 1044 typedef typename GR::Node Node; 1046 1045 1047 1046 /// \brief Constructor. … … 1049 1048 /// Construct a new ConArcIt iterating on the arcs that 1050 1049 /// connects nodes \c u and \c v. 1051 ConArcIt(const G raph& g, Node u, Node v) : _graph(g) {1050 ConArcIt(const GR& g, Node u, Node v) : _graph(g) { 1052 1051 Parent::operator=(findArc(_graph, u, v)); 1053 1052 } … … 1056 1055 /// 1057 1056 /// Construct a new ConArcIt that continues the iterating from arc \c a. 1058 ConArcIt(const G raph& g, Arc a) : Parent(a), _graph(g) {}1057 ConArcIt(const GR& g, Arc a) : Parent(a), _graph(g) {} 1059 1058 1060 1059 /// \brief Increment operator. … … 1067 1066 } 1068 1067 private: 1069 const G raph& _graph;1068 const GR& _graph; 1070 1069 }; 1071 1070 … … 1158 1157 /// 1159 1158 ///\sa findEdge() 1160 template <typename _Graph> 1161 class ConEdgeIt : public _Graph::Edge { 1159 template <typename GR> 1160 class ConEdgeIt : public GR::Edge { 1161 typedef typename GR::Edge Parent; 1162 1162 1163 public: 1163 1164 1164 typedef _Graph Graph; 1165 typedef typename Graph::Edge Parent; 1166 1167 typedef typename Graph::Edge Edge; 1168 typedef typename Graph::Node Node; 1165 typedef typename GR::Edge Edge; 1166 typedef typename GR::Node Node; 1169 1167 1170 1168 /// \brief Constructor. … … 1172 1170 /// Construct a new ConEdgeIt iterating on the edges that 1173 1171 /// connects nodes \c u and \c v. 1174 ConEdgeIt(const G raph& g, Node u, Node v) : _graph(g), _u(u), _v(v) {1172 ConEdgeIt(const GR& g, Node u, Node v) : _graph(g), _u(u), _v(v) { 1175 1173 Parent::operator=(findEdge(_graph, _u, _v)); 1176 1174 } … … 1179 1177 /// 1180 1178 /// Construct a new ConEdgeIt that continues iterating from edge \c e. 1181 ConEdgeIt(const G raph& g, Edge e) : Parent(e), _graph(g) {}1179 ConEdgeIt(const GR& g, Edge e) : Parent(e), _graph(g) {} 1182 1180 1183 1181 /// \brief Increment operator. … … 1189 1187 } 1190 1188 private: 1191 const G raph& _graph;1189 const GR& _graph; 1192 1190 Node _u, _v; 1193 1191 }; … … 1212 1210 ///queries. 1213 1211 /// 1214 ///\tparam G The type of the underlying digraph.1212 ///\tparam GR The type of the underlying digraph. 1215 1213 /// 1216 1214 ///\sa ArcLookUp 1217 1215 ///\sa AllArcLookUp 1218 template <class G>1216 template <typename GR> 1219 1217 class DynArcLookUp 1220 : protected ItemSetTraits<G , typename G::Arc>::ItemNotifier::ObserverBase1218 : protected ItemSetTraits<GR, typename GR::Arc>::ItemNotifier::ObserverBase 1221 1219 { 1220 typedef typename ItemSetTraits<GR, typename GR::Arc> 1221 ::ItemNotifier::ObserverBase Parent; 1222 1223 TEMPLATE_DIGRAPH_TYPEDEFS(GR); 1224 1222 1225 public: 1223 typedef typename ItemSetTraits<G, typename G::Arc> 1224 ::ItemNotifier::ObserverBase Parent; 1225 1226 TEMPLATE_DIGRAPH_TYPEDEFS(G); 1227 typedef G Digraph; 1226 1227 /// The Digraph type 1228 typedef GR Digraph; 1228 1229 1229 1230 protected: 1230 1231 1231 class AutoNodeMap : public ItemSetTraits<G, Node>::template Map<Arc>::Type { 1232 class AutoNodeMap : public ItemSetTraits<GR, Node>::template Map<Arc>::Type { 1233 typedef typename ItemSetTraits<GR, Node>::template Map<Arc>::Type Parent; 1234 1232 1235 public: 1233 1236 1234 typedef typename ItemSetTraits<G, Node>::template Map<Arc>::Type Parent; 1235 1236 AutoNodeMap(const G& digraph) : Parent(digraph, INVALID) {} 1237 AutoNodeMap(const GR& digraph) : Parent(digraph, INVALID) {} 1237 1238 1238 1239 virtual void add(const Node& node) { … … 1257 1258 } 1258 1259 }; 1259 1260 const Digraph &_g;1261 AutoNodeMap _head;1262 typename Digraph::template ArcMap<Arc> _parent;1263 typename Digraph::template ArcMap<Arc> _left;1264 typename Digraph::template ArcMap<Arc> _right;1265 1260 1266 1261 class ArcLess { … … 1274 1269 }; 1275 1270 1271 protected: 1272 1273 const Digraph &_g; 1274 AutoNodeMap _head; 1275 typename Digraph::template ArcMap<Arc> _parent; 1276 typename Digraph::template ArcMap<Arc> _left; 1277 typename Digraph::template ArcMap<Arc> _right; 1278 1276 1279 public: 1277 1280 … … 1316 1319 virtual void clear() { 1317 1320 for(NodeIt n(_g);n!=INVALID;++n) { 1318 _head .set(n, INVALID);1321 _head[n] = INVALID; 1319 1322 } 1320 1323 } … … 1323 1326 Node s = _g.source(arc); 1324 1327 Node t = _g.target(arc); 1325 _left .set(arc, INVALID);1326 _right .set(arc, INVALID);1328 _left[arc] = INVALID; 1329 _right[arc] = INVALID; 1327 1330 1328 1331 Arc e = _head[s]; 1329 1332 if (e == INVALID) { 1330 _head .set(s, arc);1331 _parent .set(arc, INVALID);1333 _head[s] = arc; 1334 _parent[arc] = INVALID; 1332 1335 return; 1333 1336 } … … 1335 1338 if (t < _g.target(e)) { 1336 1339 if (_left[e] == INVALID) { 1337 _left .set(e, arc);1338 _parent .set(arc, e);1340 _left[e] = arc; 1341 _parent[arc] = e; 1339 1342 splay(arc); 1340 1343 return; … … 1344 1347 } else { 1345 1348 if (_right[e] == INVALID) { 1346 _right .set(e, arc);1347 _parent .set(arc, e);1349 _right[e] = arc; 1350 _parent[arc] = e; 1348 1351 splay(arc); 1349 1352 return; … … 1358 1361 if (_left[arc] == INVALID) { 1359 1362 if (_right[arc] != INVALID) { 1360 _parent .set(_right[arc], _parent[arc]);1363 _parent[_right[arc]] = _parent[arc]; 1361 1364 } 1362 1365 if (_parent[arc] != INVALID) { 1363 1366 if (_left[_parent[arc]] == arc) { 1364 _left .set(_parent[arc], _right[arc]);1367 _left[_parent[arc]] = _right[arc]; 1365 1368 } else { 1366 _right .set(_parent[arc], _right[arc]);1369 _right[_parent[arc]] = _right[arc]; 1367 1370 } 1368 1371 } else { 1369 _head .set(_g.source(arc), _right[arc]);1372 _head[_g.source(arc)] = _right[arc]; 1370 1373 } 1371 1374 } else if (_right[arc] == INVALID) { 1372 _parent .set(_left[arc], _parent[arc]);1375 _parent[_left[arc]] = _parent[arc]; 1373 1376 if (_parent[arc] != INVALID) { 1374 1377 if (_left[_parent[arc]] == arc) { 1375 _left .set(_parent[arc], _left[arc]);1378 _left[_parent[arc]] = _left[arc]; 1376 1379 } else { 1377 _right .set(_parent[arc], _left[arc]);1380 _right[_parent[arc]] = _left[arc]; 1378 1381 } 1379 1382 } else { 1380 _head .set(_g.source(arc), _left[arc]);1383 _head[_g.source(arc)] = _left[arc]; 1381 1384 } 1382 1385 } else { … … 1388 1391 } 1389 1392 Arc s = _parent[e]; 1390 _right .set(_parent[e], _left[e]);1393 _right[_parent[e]] = _left[e]; 1391 1394 if (_left[e] != INVALID) { 1392 _parent .set(_left[e], _parent[e]);1395 _parent[_left[e]] = _parent[e]; 1393 1396 } 1394 1397 1395 _left .set(e, _left[arc]);1396 _parent .set(_left[arc], e);1397 _right .set(e, _right[arc]);1398 _parent .set(_right[arc], e);1399 1400 _parent .set(e, _parent[arc]);1398 _left[e] = _left[arc]; 1399 _parent[_left[arc]] = e; 1400 _right[e] = _right[arc]; 1401 _parent[_right[arc]] = e; 1402 1403 _parent[e] = _parent[arc]; 1401 1404 if (_parent[arc] != INVALID) { 1402 1405 if (_left[_parent[arc]] == arc) { 1403 _left .set(_parent[arc], e);1406 _left[_parent[arc]] = e; 1404 1407 } else { 1405 _right .set(_parent[arc], e);1408 _right[_parent[arc]] = e; 1406 1409 } 1407 1410 } 1408 1411 splay(s); 1409 1412 } else { 1410 _right .set(e, _right[arc]);1411 _parent .set(_right[arc], e);1412 _parent .set(e, _parent[arc]);1413 _right[e] = _right[arc]; 1414 _parent[_right[arc]] = e; 1415 _parent[e] = _parent[arc]; 1413 1416 1414 1417 if (_parent[arc] != INVALID) { 1415 1418 if (_left[_parent[arc]] == arc) { 1416 _left .set(_parent[arc], e);1419 _left[_parent[arc]] = e; 1417 1420 } else { 1418 _right .set(_parent[arc], e);1421 _right[_parent[arc]] = e; 1419 1422 } 1420 1423 } else { 1421 _head .set(_g.source(arc), e);1424 _head[_g.source(arc)] = e; 1422 1425 } 1423 1426 } … … 1431 1434 if (a < m) { 1432 1435 Arc left = refreshRec(v,a,m-1); 1433 _left .set(me, left);1434 _parent .set(left, me);1436 _left[me] = left; 1437 _parent[left] = me; 1435 1438 } else { 1436 _left .set(me, INVALID);1439 _left[me] = INVALID; 1437 1440 } 1438 1441 if (m < b) { 1439 1442 Arc right = refreshRec(v,m+1,b); 1440 _right .set(me, right);1441 _parent .set(right, me);1443 _right[me] = right; 1444 _parent[right] = me; 1442 1445 } else { 1443 _right .set(me, INVALID);1446 _right[me] = INVALID; 1444 1447 } 1445 1448 return me; … … 1453 1456 std::sort(v.begin(),v.end(),ArcLess(_g)); 1454 1457 Arc head = refreshRec(v,0,v.size()-1); 1455 _head .set(n, head);1456 _parent .set(head, INVALID);1457 } 1458 else _head .set(n, INVALID);1458 _head[n] = head; 1459 _parent[head] = INVALID; 1460 } 1461 else _head[n] = INVALID; 1459 1462 } 1460 1463 } … … 1462 1465 void zig(Arc v) { 1463 1466 Arc w = _parent[v]; 1464 _parent .set(v, _parent[w]);1465 _parent .set(w, v);1466 _left .set(w, _right[v]);1467 _right .set(v, w);1467 _parent[v] = _parent[w]; 1468 _parent[w] = v; 1469 _left[w] = _right[v]; 1470 _right[v] = w; 1468 1471 if (_parent[v] != INVALID) { 1469 1472 if (_right[_parent[v]] == w) { 1470 _right .set(_parent[v], v);1473 _right[_parent[v]] = v; 1471 1474 } else { 1472 _left .set(_parent[v], v);1475 _left[_parent[v]] = v; 1473 1476 } 1474 1477 } 1475 1478 if (_left[w] != INVALID){ 1476 _parent .set(_left[w], w);1479 _parent[_left[w]] = w; 1477 1480 } 1478 1481 } … … 1480 1483 void zag(Arc v) { 1481 1484 Arc w = _parent[v]; 1482 _parent .set(v, _parent[w]);1483 _parent .set(w, v);1484 _right .set(w, _left[v]);1485 _left .set(v, w);1485 _parent[v] = _parent[w]; 1486 _parent[w] = v; 1487 _right[w] = _left[v]; 1488 _left[v] = w; 1486 1489 if (_parent[v] != INVALID){ 1487 1490 if (_left[_parent[v]] == w) { 1488 _left .set(_parent[v], v);1491 _left[_parent[v]] = v; 1489 1492 } else { 1490 _right .set(_parent[v], v);1493 _right[_parent[v]] = v; 1491 1494 } 1492 1495 } 1493 1496 if (_right[w] != INVALID){ 1494 _parent .set(_right[w], w);1497 _parent[_right[w]] = w; 1495 1498 } 1496 1499 } … … 1624 1627 ///(<em>O</em>(<em>m</em> log<em>m</em>)) to the number of arcs). 1625 1628 /// 1626 ///\tparam G The type of the underlying digraph.1629 ///\tparam GR The type of the underlying digraph. 1627 1630 /// 1628 1631 ///\sa DynArcLookUp 1629 1632 ///\sa AllArcLookUp 1630 template<class G >1633 template<class GR> 1631 1634 class ArcLookUp 1632 1635 { 1636 TEMPLATE_DIGRAPH_TYPEDEFS(GR); 1637 1633 1638 public: 1634 TEMPLATE_DIGRAPH_TYPEDEFS(G); 1635 typedef G Digraph; 1639 1640 /// The Digraph type 1641 typedef GR Digraph; 1636 1642 1637 1643 protected: … … 1734 1740 ///(<em>O</em>(<em>m</em> log<em>m</em>)) to the number of arcs). 1735 1741 /// 1736 ///\tparam G The type of the underlying digraph.1742 ///\tparam GR The type of the underlying digraph. 1737 1743 /// 1738 1744 ///\sa DynArcLookUp 1739 1745 ///\sa ArcLookUp 1740 template<class G >1741 class AllArcLookUp : public ArcLookUp<G >1746 template<class GR> 1747 class AllArcLookUp : public ArcLookUp<GR> 1742 1748 { 1743 using ArcLookUp<G>::_g; 1744 using ArcLookUp<G>::_right; 1745 using ArcLookUp<G>::_left; 1746 using ArcLookUp<G>::_head; 1747 1748 TEMPLATE_DIGRAPH_TYPEDEFS(G); 1749 typedef G Digraph; 1750 1751 typename Digraph::template ArcMap<Arc> _next; 1749 using ArcLookUp<GR>::_g; 1750 using ArcLookUp<GR>::_right; 1751 using ArcLookUp<GR>::_left; 1752 using ArcLookUp<GR>::_head; 1753 1754 TEMPLATE_DIGRAPH_TYPEDEFS(GR); 1755 1756 typename GR::template ArcMap<Arc> _next; 1752 1757 1753 1758 Arc refreshNext(Arc head,Arc next=INVALID) … … 1768 1773 1769 1774 public: 1775 1776 /// The Digraph type 1777 typedef GR Digraph; 1778 1770 1779 ///Constructor 1771 1780 … … 1774 1783 ///It builds up the search database, which remains valid until the digraph 1775 1784 ///changes. 1776 AllArcLookUp(const Digraph &g) : ArcLookUp<G >(g), _next(g) {refreshNext();}1785 AllArcLookUp(const Digraph &g) : ArcLookUp<GR>(g), _next(g) {refreshNext();} 1777 1786 1778 1787 ///Refresh the data structure at a node. … … 1784 1793 void refresh(Node n) 1785 1794 { 1786 ArcLookUp<G >::refresh(n);1795 ArcLookUp<GR>::refresh(n); 1787 1796 refreshNext(_head[n]); 1788 1797 } … … 1831 1840 Arc operator()(Node s, Node t, Arc prev=INVALID) const {} 1832 1841 #else 1833 using ArcLookUp<G >::operator() ;1842 using ArcLookUp<GR>::operator() ; 1834 1843 Arc operator()(Node s, Node t, Arc prev) const 1835 1844 { -
lemon/counter.h
r209 r463 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). -
lemon/dfs.h
r319 r631 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 50 50 ///It must meet the \ref concepts::WriteMap "WriteMap" concept. 51 51 typedef typename Digraph::template NodeMap<typename Digraph::Arc> PredMap; 52 ///Instantiates a PredMap.53 54 ///This function instantiates a PredMap.52 ///Instantiates a \c PredMap. 53 54 ///This function instantiates a \ref PredMap. 55 55 ///\param g is the digraph, to which we would like to define the 56 /// PredMap.56 ///\ref PredMap. 57 57 static PredMap *createPredMap(const Digraph &g) 58 58 { … … 65 65 ///It must meet the \ref concepts::WriteMap "WriteMap" concept. 66 66 typedef NullMap<typename Digraph::Node,bool> ProcessedMap; 67 ///Instantiates a ProcessedMap.68 69 ///This function instantiates a ProcessedMap.67 ///Instantiates a \c ProcessedMap. 68 69 ///This function instantiates a \ref ProcessedMap. 70 70 ///\param g is the digraph, to which 71 ///we would like to define the ProcessedMap71 ///we would like to define the \ref ProcessedMap. 72 72 #ifdef DOXYGEN 73 73 static ProcessedMap *createProcessedMap(const Digraph &g) … … 84 84 ///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept. 85 85 typedef typename Digraph::template NodeMap<bool> ReachedMap; 86 ///Instantiates a ReachedMap.87 88 ///This function instantiates a ReachedMap.86 ///Instantiates a \c ReachedMap. 87 88 ///This function instantiates a \ref ReachedMap. 89 89 ///\param g is the digraph, to which 90 ///we would like to define the ReachedMap.90 ///we would like to define the \ref ReachedMap. 91 91 static ReachedMap *createReachedMap(const Digraph &g) 92 92 { … … 99 99 ///It must meet the \ref concepts::WriteMap "WriteMap" concept. 100 100 typedef typename Digraph::template NodeMap<int> DistMap; 101 ///Instantiates a DistMap.102 103 ///This function instantiates a DistMap.101 ///Instantiates a \c DistMap. 102 103 ///This function instantiates a \ref DistMap. 104 104 ///\param g is the digraph, to which we would like to define the 105 /// DistMap.105 ///\ref DistMap. 106 106 static DistMap *createDistMap(const Digraph &g) 107 107 { … … 120 120 /// 121 121 ///\tparam GR The type of the digraph the algorithm runs on. 122 ///The default value is \ref ListDigraph. The value of GR is not used 123 ///directly by \ref Dfs, it is only passed to \ref DfsDefaultTraits. 124 ///\tparam TR Traits class to set various data types used by the algorithm. 125 ///The default traits class is 126 ///\ref DfsDefaultTraits "DfsDefaultTraits<GR>". 127 ///See \ref DfsDefaultTraits for the documentation of 128 ///a Dfs traits class. 122 ///The default type is \ref ListDigraph. 129 123 #ifdef DOXYGEN 130 124 template <typename GR, … … 152 146 typedef PredMapPath<Digraph, PredMap> Path; 153 147 154 ///The traits class.148 ///The \ref DfsDefaultTraits "traits class" of the algorithm. 155 149 typedef TR Traits; 156 150 … … 213 207 typedef Dfs Create; 214 208 215 ///\name Named template parameters209 ///\name Named Template Parameters 216 210 217 211 ///@{ … … 227 221 }; 228 222 ///\brief \ref named-templ-param "Named parameter" for setting 229 /// PredMap type.223 ///\c PredMap type. 230 224 /// 231 225 ///\ref named-templ-param "Named parameter" for setting 232 ///PredMap type. 226 ///\c PredMap type. 227 ///It must meet the \ref concepts::WriteMap "WriteMap" concept. 233 228 template <class T> 234 229 struct SetPredMap : public Dfs<Digraph, SetPredMapTraits<T> > { … … 246 241 }; 247 242 ///\brief \ref named-templ-param "Named parameter" for setting 248 /// DistMap type.243 ///\c DistMap type. 249 244 /// 250 245 ///\ref named-templ-param "Named parameter" for setting 251 ///DistMap type. 246 ///\c DistMap type. 247 ///It must meet the \ref concepts::WriteMap "WriteMap" concept. 252 248 template <class T> 253 249 struct SetDistMap : public Dfs< Digraph, SetDistMapTraits<T> > { … … 265 261 }; 266 262 ///\brief \ref named-templ-param "Named parameter" for setting 267 /// ReachedMap type.263 ///\c ReachedMap type. 268 264 /// 269 265 ///\ref named-templ-param "Named parameter" for setting 270 ///ReachedMap type. 266 ///\c ReachedMap type. 267 ///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept. 271 268 template <class T> 272 269 struct SetReachedMap : public Dfs< Digraph, SetReachedMapTraits<T> > { … … 284 281 }; 285 282 ///\brief \ref named-templ-param "Named parameter" for setting 286 /// ProcessedMap type.283 ///\c ProcessedMap type. 287 284 /// 288 285 ///\ref named-templ-param "Named parameter" for setting 289 ///ProcessedMap type. 286 ///\c ProcessedMap type. 287 ///It must meet the \ref concepts::WriteMap "WriteMap" concept. 290 288 template <class T> 291 289 struct SetProcessedMap : public Dfs< Digraph, SetProcessedMapTraits<T> > { … … 301 299 }; 302 300 ///\brief \ref named-templ-param "Named parameter" for setting 303 /// ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>.301 ///\c ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>. 304 302 /// 305 303 ///\ref named-templ-param "Named parameter" for setting 306 /// ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>.304 ///\c ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>. 307 305 ///If you don't set it explicitly, it will be automatically allocated. 308 306 struct SetStandardProcessedMap : … … 339 337 340 338 ///Sets the map that stores the predecessor arcs. 341 ///If you don't use this function before calling \ref run(), 342 ///it will allocate one. The destructor deallocates this 343 ///automatically allocated map, of course. 339 ///If you don't use this function before calling \ref run(Node) "run()" 340 ///or \ref init(), an instance will be allocated automatically. 341 ///The destructor deallocates this automatically allocated map, 342 ///of course. 344 343 ///\return <tt> (*this) </tt> 345 344 Dfs &predMap(PredMap &m) … … 356 355 357 356 ///Sets the map that indicates which nodes are reached. 358 ///If you don't use this function before calling \ref run(), 359 ///it will allocate one. The destructor deallocates this 360 ///automatically allocated map, of course. 357 ///If you don't use this function before calling \ref run(Node) "run()" 358 ///or \ref init(), an instance will be allocated automatically. 359 ///The destructor deallocates this automatically allocated map, 360 ///of course. 361 361 ///\return <tt> (*this) </tt> 362 362 Dfs &reachedMap(ReachedMap &m) … … 373 373 374 374 ///Sets the map that indicates which nodes are processed. 375 ///If you don't use this function before calling \ref run(), 376 ///it will allocate one. The destructor deallocates this 377 ///automatically allocated map, of course. 375 ///If you don't use this function before calling \ref run(Node) "run()" 376 ///or \ref init(), an instance will be allocated automatically. 377 ///The destructor deallocates this automatically allocated map, 378 ///of course. 378 379 ///\return <tt> (*this) </tt> 379 380 Dfs &processedMap(ProcessedMap &m) … … 391 392 ///Sets the map that stores the distances of the nodes calculated by 392 393 ///the algorithm. 393 ///If you don't use this function before calling \ref run(), 394 ///it will allocate one. The destructor deallocates this 395 ///automatically allocated map, of course. 394 ///If you don't use this function before calling \ref run(Node) "run()" 395 ///or \ref init(), an instance will be allocated automatically. 396 ///The destructor deallocates this automatically allocated map, 397 ///of course. 396 398 ///\return <tt> (*this) </tt> 397 399 Dfs &distMap(DistMap &m) … … 407 409 public: 408 410 409 ///\name Execution control 410 ///The simplest way to execute the algorithm is to use 411 ///one of the member functions called \ref lemon::Dfs::run() "run()". 412 ///\n 413 ///If you need more control on the execution, first you must call 414 ///\ref lemon::Dfs::init() "init()", then you can add a source node 415 ///with \ref lemon::Dfs::addSource() "addSource()". 416 ///Finally \ref lemon::Dfs::start() "start()" will perform the 417 ///actual path computation. 411 ///\name Execution Control 412 ///The simplest way to execute the DFS algorithm is to use one of the 413 ///member functions called \ref run(Node) "run()".\n 414 ///If you need more control on the execution, first you have to call 415 ///\ref init(), then you can add a source node with \ref addSource() 416 ///and perform the actual computation with \ref start(). 417 ///This procedure can be repeated if there are nodes that have not 418 ///been reached. 418 419 419 420 ///@{ 420 421 422 ///\brief Initializes the internal data structures. 423 /// 421 424 ///Initializes the internal data structures. 422 423 ///Initializes the internal data structures.424 ///425 425 void init() 426 426 { … … 439 439 ///Adds a new source node to the set of nodes to be processed. 440 440 /// 441 ///\pre The stack must be empty. (Otherwise the algorithm gives 442 ///false results.) 443 /// 444 ///\warning Distances will be wrong (or at least strange) in case of 445 ///multiple sources. 441 ///\pre The stack must be empty. Otherwise the algorithm gives 442 ///wrong results. (One of the outgoing arcs of all the source nodes 443 ///except for the last one will not be visited and distances will 444 ///also be wrong.) 446 445 void addSource(Node s) 447 446 { … … 507 506 } 508 507 509 ///\brief Returns \c false if there are nodes 510 ///to be processed. 511 /// 512 ///Returns \c false if there are nodes 513 ///to be processed in the queue (stack). 508 ///Returns \c false if there are nodes to be processed. 509 510 ///Returns \c false if there are nodes to be processed 511 ///in the queue (stack). 514 512 bool emptyQueue() const { return _stack_head<0; } 515 513 516 514 ///Returns the number of the nodes to be processed. 517 515 518 ///Returns the number of the nodes to be processed in the queue (stack). 516 ///Returns the number of the nodes to be processed 517 ///in the queue (stack). 519 518 int queueSize() const { return _stack_head+1; } 520 519 … … 638 637 /// 639 638 ///The algorithm computes 640 ///- the %DFS tree ,641 ///- the distance of each node from the root in the %DFS tree.639 ///- the %DFS tree (forest), 640 ///- the distance of each node from the root(s) in the %DFS tree. 642 641 /// 643 642 ///\note <tt>d.run()</tt> is just a shortcut of the following code. … … 664 663 665 664 ///\name Query Functions 666 ///The result of the %DFS algorithm can be obtained using these665 ///The results of the DFS algorithm can be obtained using these 667 666 ///functions.\n 668 ///Either \ref lemon::Dfs::run() "run()" or \ref lemon::Dfs::start()669 /// "start()" must be calledbefore using them.667 ///Either \ref run(Node) "run()" or \ref start() should be called 668 ///before using them. 670 669 671 670 ///@{ … … 675 674 ///Returns the DFS path to a node. 676 675 /// 677 ///\warning \c t should be reach able from the root.678 /// 679 ///\pre Either \ref run( ) or \ref start() must be called before680 /// using this function.676 ///\warning \c t should be reached from the root(s). 677 /// 678 ///\pre Either \ref run(Node) "run()" or \ref init() 679 ///must be called before using this function. 681 680 Path path(Node t) const { return Path(*G, *_pred, t); } 682 681 683 ///The distance of a node from the root .684 685 ///Returns the distance of a node from the root .686 /// 687 ///\warning If node \c v is not reach able from the root, then682 ///The distance of a node from the root(s). 683 684 ///Returns the distance of a node from the root(s). 685 /// 686 ///\warning If node \c v is not reached from the root(s), then 688 687 ///the return value of this function is undefined. 689 688 /// 690 ///\pre Either \ref run( ) or \ref start() must be called before691 /// using this function.689 ///\pre Either \ref run(Node) "run()" or \ref init() 690 ///must be called before using this function. 692 691 int dist(Node v) const { return (*_dist)[v]; } 693 692 … … 695 694 696 695 ///This function returns the 'previous arc' of the %DFS tree for the 697 ///node \c v, i.e. it returns the last arc of a %DFS path from the698 ///root to \c v. It is \c INVALID 699 /// if \c v is not reachable from theroot(s) or if \c v is a root.696 ///node \c v, i.e. it returns the last arc of a %DFS path from a 697 ///root to \c v. It is \c INVALID if \c v is not reached from the 698 ///root(s) or if \c v is a root. 700 699 /// 701 700 ///The %DFS tree used here is equal to the %DFS tree used in 702 701 ///\ref predNode(). 703 702 /// 704 ///\pre Either \ref run( ) or \ref start() must be called before using705 /// this function.703 ///\pre Either \ref run(Node) "run()" or \ref init() 704 ///must be called before using this function. 706 705 Arc predArc(Node v) const { return (*_pred)[v];} 707 706 … … 710 709 ///This function returns the 'previous node' of the %DFS 711 710 ///tree for the node \c v, i.e. it returns the last but one node 712 ///from a %DFS path from theroot to \c v. It is \c INVALID713 ///if \c v is not reach ablefrom the root(s) or if \c v is a root.711 ///from a %DFS path from a root to \c v. It is \c INVALID 712 ///if \c v is not reached from the root(s) or if \c v is a root. 714 713 /// 715 714 ///The %DFS tree used here is equal to the %DFS tree used in 716 715 ///\ref predArc(). 717 716 /// 718 ///\pre Either \ref run( ) or \ref start() must be called before719 /// using this function.717 ///\pre Either \ref run(Node) "run()" or \ref init() 718 ///must be called before using this function. 720 719 Node predNode(Node v) const { return (*_pred)[v]==INVALID ? INVALID: 721 720 G->source((*_pred)[v]); } … … 727 726 ///distances of the nodes calculated by the algorithm. 728 727 /// 729 ///\pre Either \ref run( )or \ref init()728 ///\pre Either \ref run(Node) "run()" or \ref init() 730 729 ///must be called before using this function. 731 730 const DistMap &distMap() const { return *_dist;} … … 737 736 ///arcs, which form the DFS tree. 738 737 /// 739 ///\pre Either \ref run( )or \ref init()738 ///\pre Either \ref run(Node) "run()" or \ref init() 740 739 ///must be called before using this function. 741 740 const PredMap &predMap() const { return *_pred;} 742 741 743 ///Checks if a node is reachable from the root(s). 744 745 ///Returns \c true if \c v is reachable from the root(s). 746 ///\pre Either \ref run() or \ref start() 742 ///Checks if a node is reached from the root(s). 743 744 ///Returns \c true if \c v is reached from the root(s). 745 /// 746 ///\pre Either \ref run(Node) "run()" or \ref init() 747 747 ///must be called before using this function. 748 748 bool reached(Node v) const { return (*_reached)[v]; } … … 890 890 /// This auxiliary class is created to implement the 891 891 /// \ref dfs() "function-type interface" of \ref Dfs algorithm. 892 /// It does not have own \ref run( ) method, it uses the functions893 /// and features of the plain \ref Dfs.892 /// It does not have own \ref run(Node) "run()" method, it uses the 893 /// functions and features of the plain \ref Dfs. 894 894 /// 895 895 /// This class should only be used through the \ref dfs() function, … … 1111 1111 /// bool reached = dfs(g).path(p).dist(d).run(s,t); 1112 1112 ///\endcode 1113 1114 ///\warning Don't forget to put the \ref DfsWizard::run() "run()" 1113 ///\warning Don't forget to put the \ref DfsWizard::run(Node) "run()" 1115 1114 ///to the end of the parameter list. 1116 1115 ///\sa DfsWizard … … 1128 1127 /// This class defines the interface of the DfsVisit events, and 1129 1128 /// it could be the base of a real visitor class. 1130 template <typename _Digraph>1129 template <typename GR> 1131 1130 struct DfsVisitor { 1132 typedef _DigraphDigraph;1131 typedef GR Digraph; 1133 1132 typedef typename Digraph::Arc Arc; 1134 1133 typedef typename Digraph::Node Node; … … 1166 1165 }; 1167 1166 #else 1168 template <typename _Digraph>1167 template <typename GR> 1169 1168 struct DfsVisitor { 1170 typedef _DigraphDigraph;1169 typedef GR Digraph; 1171 1170 typedef typename Digraph::Arc Arc; 1172 1171 typedef typename Digraph::Node Node; … … 1201 1200 /// Default traits class of DfsVisit class. 1202 1201 /// \tparam _Digraph The type of the digraph the algorithm runs on. 1203 template<class _Digraph>1202 template<class GR> 1204 1203 struct DfsVisitDefaultTraits { 1205 1204 1206 1205 /// \brief The type of the digraph the algorithm runs on. 1207 typedef _DigraphDigraph;1206 typedef GR Digraph; 1208 1207 1209 1208 /// \brief The type of the map that indicates which nodes are reached. … … 1226 1225 /// \ingroup search 1227 1226 /// 1228 /// \brief %DFS algorithm class with visitor interface.1227 /// \brief DFS algorithm class with visitor interface. 1229 1228 /// 1230 /// This class provides an efficient implementation of the %DFS algorithm1229 /// This class provides an efficient implementation of the DFS algorithm 1231 1230 /// with visitor interface. 1232 1231 /// 1233 /// The %DfsVisit class provides an alternative interface to the Dfs1232 /// The DfsVisit class provides an alternative interface to the Dfs 1234 1233 /// class. It works with callback mechanism, the DfsVisit object calls 1235 1234 /// the member functions of the \c Visitor class on every DFS event. … … 1240 1239 /// instead. 1241 1240 /// 1242 /// \tparam _DigraphThe type of the digraph the algorithm runs on.1243 /// The default value is1244 /// \ref ListDigraph. The value of _Digraph is not used directly by1245 /// \ref DfsVisit,it is only passed to \ref DfsVisitDefaultTraits.1246 /// \tparam _VisitorThe Visitor type that is used by the algorithm.1247 /// \ref DfsVisitor "DfsVisitor< _Digraph>" is an empty visitor, which1241 /// \tparam GR The type of the digraph the algorithm runs on. 1242 /// The default type is \ref ListDigraph. 1243 /// The value of GR is not used directly by \ref DfsVisit, 1244 /// it is only passed to \ref DfsVisitDefaultTraits. 1245 /// \tparam VS The Visitor type that is used by the algorithm. 1246 /// \ref DfsVisitor "DfsVisitor<GR>" is an empty visitor, which 1248 1247 /// does not observe the DFS events. If you want to observe the DFS 1249 1248 /// events, you should implement your own visitor class. 1250 /// \tparam _TraitsTraits class to set various data types used by the1249 /// \tparam TR Traits class to set various data types used by the 1251 1250 /// algorithm. The default traits class is 1252 /// \ref DfsVisitDefaultTraits "DfsVisitDefaultTraits< _Digraph>".1251 /// \ref DfsVisitDefaultTraits "DfsVisitDefaultTraits<GR>". 1253 1252 /// See \ref DfsVisitDefaultTraits for the documentation of 1254 1253 /// a DFS visit traits class. 1255 1254 #ifdef DOXYGEN 1256 template <typename _Digraph, typename _Visitor, typename _Traits>1255 template <typename GR, typename VS, typename TR> 1257 1256 #else 1258 template <typename _Digraph= ListDigraph,1259 typename _Visitor = DfsVisitor<_Digraph>,1260 typename _Traits = DfsVisitDefaultTraits<_Digraph> >1257 template <typename GR = ListDigraph, 1258 typename VS = DfsVisitor<GR>, 1259 typename TR = DfsVisitDefaultTraits<GR> > 1261 1260 #endif 1262 1261 class DfsVisit { … … 1264 1263 1265 1264 ///The traits class. 1266 typedef _TraitsTraits;1265 typedef TR Traits; 1267 1266 1268 1267 ///The type of the digraph the algorithm runs on. … … 1270 1269 1271 1270 ///The visitor type used by the algorithm. 1272 typedef _VisitorVisitor;1271 typedef VS Visitor; 1273 1272 1274 1273 ///The type of the map that indicates which nodes are reached. … … 1310 1309 typedef DfsVisit Create; 1311 1310 1312 /// \name Named template parameters1311 /// \name Named Template Parameters 1313 1312 1314 1313 ///@{ … … 1352 1351 /// 1353 1352 /// Sets the map that indicates which nodes are reached. 1354 /// If you don't use this function before calling \ref run(), 1355 /// it will allocate one. The destructor deallocates this 1356 /// automatically allocated map, of course. 1353 /// If you don't use this function before calling \ref run(Node) "run()" 1354 /// or \ref init(), an instance will be allocated automatically. 1355 /// The destructor deallocates this automatically allocated map, 1356 /// of course. 1357 1357 /// \return <tt> (*this) </tt> 1358 1358 DfsVisit &reachedMap(ReachedMap &m) { … … 1367 1367 public: 1368 1368 1369 /// \name Execution control 1370 /// The simplest way to execute the algorithm is to use 1371 /// one of the member functions called \ref lemon::DfsVisit::run() 1372 /// "run()". 1373 /// \n 1374 /// If you need more control on the execution, first you must call 1375 /// \ref lemon::DfsVisit::init() "init()", then you can add several 1376 /// source nodes with \ref lemon::DfsVisit::addSource() "addSource()". 1377 /// Finally \ref lemon::DfsVisit::start() "start()" will perform the 1378 /// actual path computation. 1369 /// \name Execution Control 1370 /// The simplest way to execute the DFS algorithm is to use one of the 1371 /// member functions called \ref run(Node) "run()".\n 1372 /// If you need more control on the execution, first you have to call 1373 /// \ref init(), then you can add a source node with \ref addSource() 1374 /// and perform the actual computation with \ref start(). 1375 /// This procedure can be repeated if there are nodes that have not 1376 /// been reached. 1379 1377 1380 1378 /// @{ … … 1392 1390 } 1393 1391 1394 ///Adds a new source node. 1395 1396 ///Adds a new source node to the set of nodes to be processed. 1397 /// 1398 ///\pre The stack must be empty. (Otherwise the algorithm gives 1399 ///false results.) 1400 /// 1401 ///\warning Distances will be wrong (or at least strange) in case of 1402 ///multiple sources. 1392 /// \brief Adds a new source node. 1393 /// 1394 /// Adds a new source node to the set of nodes to be processed. 1395 /// 1396 /// \pre The stack must be empty. Otherwise the algorithm gives 1397 /// wrong results. (One of the outgoing arcs of all the source nodes 1398 /// except for the last one will not be visited and distances will 1399 /// also be wrong.) 1403 1400 void addSource(Node s) 1404 1401 { … … 1414 1411 } else { 1415 1412 _visitor->leave(s); 1413 _visitor->stop(s); 1416 1414 } 1417 1415 } … … 1590 1588 /// 1591 1589 /// The algorithm computes 1592 /// - the %DFS tree ,1593 /// - the distance of each node from the root in the %DFS tree.1590 /// - the %DFS tree (forest), 1591 /// - the distance of each node from the root(s) in the %DFS tree. 1594 1592 /// 1595 1593 /// \note <tt>d.run()</tt> is just a shortcut of the following code. … … 1616 1614 1617 1615 /// \name Query Functions 1618 /// The result of the %DFS algorithm can be obtained using these1616 /// The results of the DFS algorithm can be obtained using these 1619 1617 /// functions.\n 1620 /// Either \ref lemon::DfsVisit::run() "run()" or1621 /// \ref lemon::DfsVisit::start() "start()" must be called before1622 /// using them. 1618 /// Either \ref run(Node) "run()" or \ref start() should be called 1619 /// before using them. 1620 1623 1621 ///@{ 1624 1622 1625 /// \brief Checks if a node is reachable from the root(s). 1626 /// 1627 /// Returns \c true if \c v is reachable from the root(s). 1628 /// \pre Either \ref run() or \ref start() 1623 /// \brief Checks if a node is reached from the root(s). 1624 /// 1625 /// Returns \c true if \c v is reached from the root(s). 1626 /// 1627 /// \pre Either \ref run(Node) "run()" or \ref init() 1629 1628 /// must be called before using this function. 1630 bool reached(Node v) { return (*_reached)[v]; }1629 bool reached(Node v) const { return (*_reached)[v]; } 1631 1630 1632 1631 ///@} -
lemon/dijkstra.h
r412 r631 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 39 39 /// This operation traits class defines all computational operations and 40 40 /// constants which are used in the Dijkstra algorithm. 41 template <typename V alue>41 template <typename V> 42 42 struct DijkstraDefaultOperationTraits { 43 /// \e 44 typedef V Value; 43 45 /// \brief Gives back the zero value of the type. 44 46 static Value zero() { … … 59 61 ///Default traits class of Dijkstra class. 60 62 ///\tparam GR The type of the digraph. 61 ///\tparam L MThe type of the length map.62 template< class GR, class LM>63 ///\tparam LEN The type of the length map. 64 template<typename GR, typename LEN> 63 65 struct DijkstraDefaultTraits 64 66 { … … 70 72 ///The type of the map that stores the arc lengths. 71 73 ///It must meet the \ref concepts::ReadMap "ReadMap" concept. 72 typedef L MLengthMap;74 typedef LEN LengthMap; 73 75 ///The type of the length of the arcs. 74 typedef typename L M::Value Value;75 76 /// Operation traits for Dijkstra algorithm.76 typedef typename LEN::Value Value; 77 78 /// Operation traits for %Dijkstra algorithm. 77 79 78 80 /// This class defines the operations that are used in the algorithm. … … 85 87 /// Usually it is \c Digraph::NodeMap<int>. 86 88 typedef typename Digraph::template NodeMap<int> HeapCrossRef; 87 ///Instantiates a \ refHeapCrossRef.89 ///Instantiates a \c HeapCrossRef. 88 90 89 91 ///This function instantiates a \ref HeapCrossRef. … … 95 97 } 96 98 97 ///The heap type used by the Dijkstra algorithm.99 ///The heap type used by the %Dijkstra algorithm. 98 100 99 101 ///The heap type used by the Dijkstra algorithm. … … 101 103 ///\sa BinHeap 102 104 ///\sa Dijkstra 103 typedef BinHeap<typename L M::Value, HeapCrossRef, std::less<Value> > Heap;104 ///Instantiates a \ refHeap.105 typedef BinHeap<typename LEN::Value, HeapCrossRef, std::less<Value> > Heap; 106 ///Instantiates a \c Heap. 105 107 106 108 ///This function instantiates a \ref Heap. … … 117 119 ///It must meet the \ref concepts::WriteMap "WriteMap" concept. 118 120 typedef typename Digraph::template NodeMap<typename Digraph::Arc> PredMap; 119 ///Instantiates a PredMap.120 121 ///This function instantiates a PredMap.121 ///Instantiates a \c PredMap. 122 123 ///This function instantiates a \ref PredMap. 122 124 ///\param g is the digraph, to which we would like to define the 123 /// PredMap.125 ///\ref PredMap. 124 126 static PredMap *createPredMap(const Digraph &g) 125 127 { … … 133 135 ///By default it is a NullMap. 134 136 typedef NullMap<typename Digraph::Node,bool> ProcessedMap; 135 ///Instantiates a ProcessedMap.136 137 ///This function instantiates a ProcessedMap.137 ///Instantiates a \c ProcessedMap. 138 139 ///This function instantiates a \ref ProcessedMap. 138 140 ///\param g is the digraph, to which 139 ///we would like to define the ProcessedMap141 ///we would like to define the \ref ProcessedMap. 140 142 #ifdef DOXYGEN 141 143 static ProcessedMap *createProcessedMap(const Digraph &g) … … 151 153 ///The type of the map that stores the distances of the nodes. 152 154 ///It must meet the \ref concepts::WriteMap "WriteMap" concept. 153 typedef typename Digraph::template NodeMap<typename L M::Value> DistMap;154 ///Instantiates a DistMap.155 156 ///This function instantiates a DistMap.155 typedef typename Digraph::template NodeMap<typename LEN::Value> DistMap; 156 ///Instantiates a \c DistMap. 157 158 ///This function instantiates a \ref DistMap. 157 159 ///\param g is the digraph, to which we would like to define 158 ///the DistMap160 ///the \ref DistMap. 159 161 static DistMap *createDistMap(const Digraph &g) 160 162 { … … 180 182 /// 181 183 ///\tparam GR The type of the digraph the algorithm runs on. 182 ///The default value is \ref ListDigraph. 183 ///The value of GR is not used directly by \ref Dijkstra, it is only 184 ///passed to \ref DijkstraDefaultTraits. 185 ///\tparam LM A readable arc map that determines the lengths of the 186 ///arcs. It is read once for each arc, so the map may involve in 184 ///The default type is \ref ListDigraph. 185 ///\tparam LEN A \ref concepts::ReadMap "readable" arc map that specifies 186 ///the lengths of the arcs. 187 ///It is read once for each arc, so the map may involve in 187 188 ///relatively time consuming process to compute the arc lengths if 188 189 ///it is necessary. The default map type is \ref 189 ///concepts::Digraph::ArcMap "Digraph::ArcMap<int>". 190 ///The value of LM is not used directly by \ref Dijkstra, it is only 191 ///passed to \ref DijkstraDefaultTraits. 192 ///\tparam TR Traits class to set various data types used by the algorithm. 193 ///The default traits class is \ref DijkstraDefaultTraits 194 ///"DijkstraDefaultTraits<GR,LM>". See \ref DijkstraDefaultTraits 195 ///for the documentation of a Dijkstra traits class. 190 ///concepts::Digraph::ArcMap "GR::ArcMap<int>". 196 191 #ifdef DOXYGEN 197 template <typename GR, typename L M, typename TR>192 template <typename GR, typename LEN, typename TR> 198 193 #else 199 194 template <typename GR=ListDigraph, 200 typename L M=typename GR::template ArcMap<int>,201 typename TR=DijkstraDefaultTraits<GR,L M> >195 typename LEN=typename GR::template ArcMap<int>, 196 typename TR=DijkstraDefaultTraits<GR,LEN> > 202 197 #endif 203 198 class Dijkstra { … … 224 219 ///The heap type used by the algorithm. 225 220 typedef typename TR::Heap Heap; 226 ///The operation traits class. 221 ///\brief The \ref DijkstraDefaultOperationTraits "operation traits class" 222 ///of the algorithm. 227 223 typedef typename TR::OperationTraits OperationTraits; 228 224 229 ///The traits class.225 ///The \ref DijkstraDefaultTraits "traits class" of the algorithm. 230 226 typedef TR Traits; 231 227 … … 240 236 const Digraph *G; 241 237 //Pointer to the length map. 242 const LengthMap * length;238 const LengthMap *_length; 243 239 //Pointer to the map of predecessors arcs. 244 240 PredMap *_pred; … … 291 287 typedef Dijkstra Create; 292 288 293 ///\name Named template parameters289 ///\name Named Template Parameters 294 290 295 291 ///@{ … … 305 301 }; 306 302 ///\brief \ref named-templ-param "Named parameter" for setting 307 /// PredMap type.303 ///\c PredMap type. 308 304 /// 309 305 ///\ref named-templ-param "Named parameter" for setting 310 ///PredMap type. 306 ///\c PredMap type. 307 ///It must meet the \ref concepts::WriteMap "WriteMap" concept. 311 308 template <class T> 312 309 struct SetPredMap … … 325 322 }; 326 323 ///\brief \ref named-templ-param "Named parameter" for setting 327 /// DistMap type.324 ///\c DistMap type. 328 325 /// 329 326 ///\ref named-templ-param "Named parameter" for setting 330 ///DistMap type. 327 ///\c DistMap type. 328 ///It must meet the \ref concepts::WriteMap "WriteMap" concept. 331 329 template <class T> 332 330 struct SetDistMap … … 345 343 }; 346 344 ///\brief \ref named-templ-param "Named parameter" for setting 347 /// ProcessedMap type.345 ///\c ProcessedMap type. 348 346 /// 349 347 ///\ref named-templ-param "Named parameter" for setting 350 ///ProcessedMap type. 348 ///\c ProcessedMap type. 349 ///It must meet the \ref concepts::WriteMap "WriteMap" concept. 351 350 template <class T> 352 351 struct SetProcessedMap … … 363 362 }; 364 363 ///\brief \ref named-templ-param "Named parameter" for setting 365 /// ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>.364 ///\c ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>. 366 365 /// 367 366 ///\ref named-templ-param "Named parameter" for setting 368 /// ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>.367 ///\c ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>. 369 368 ///If you don't set it explicitly, it will be automatically allocated. 370 369 struct SetStandardProcessedMap … … 389 388 }; 390 389 ///\brief \ref named-templ-param "Named parameter" for setting 391 ///heap and cross reference type 390 ///heap and cross reference types 392 391 /// 393 392 ///\ref named-templ-param "Named parameter" for setting heap and cross 394 ///reference type. 393 ///reference types. If this named parameter is used, then external 394 ///heap and cross reference objects must be passed to the algorithm 395 ///using the \ref heap() function before calling \ref run(Node) "run()" 396 ///or \ref init(). 397 ///\sa SetStandardHeap 395 398 template <class H, class CR = typename Digraph::template NodeMap<int> > 396 399 struct SetHeap … … 412 415 }; 413 416 ///\brief \ref named-templ-param "Named parameter" for setting 414 ///heap and cross reference type with automatic allocation417 ///heap and cross reference types with automatic allocation 415 418 /// 416 419 ///\ref named-templ-param "Named parameter" for setting heap and cross 417 ///reference type. It can allocate the heap and the cross reference 418 ///object if the cross reference's constructor waits for the digraph as 419 ///parameter and the heap's constructor waits for the cross reference. 420 ///reference types with automatic allocation. 421 ///They should have standard constructor interfaces to be able to 422 ///automatically created by the algorithm (i.e. the digraph should be 423 ///passed to the constructor of the cross reference and the cross 424 ///reference should be passed to the constructor of the heap). 425 ///However external heap and cross reference objects could also be 426 ///passed to the algorithm using the \ref heap() function before 427 ///calling \ref run(Node) "run()" or \ref init(). 428 ///\sa SetHeap 420 429 template <class H, class CR = typename Digraph::template NodeMap<int> > 421 430 struct SetStandardHeap … … 434 443 /// 435 444 ///\ref named-templ-param "Named parameter" for setting 436 ///\ refOperationTraits type.445 ///\c OperationTraits type. 437 446 template <class T> 438 447 struct SetOperationTraits … … 453 462 454 463 ///Constructor. 455 ///\param _g The digraph the algorithm runs on.456 ///\param _length The length map used by the algorithm.457 Dijkstra(const Digraph& _g, const LengthMap& _length) :458 G(& _g), length(&_length),464 ///\param g The digraph the algorithm runs on. 465 ///\param length The length map used by the algorithm. 466 Dijkstra(const Digraph& g, const LengthMap& length) : 467 G(&g), _length(&length), 459 468 _pred(NULL), local_pred(false), 460 469 _dist(NULL), local_dist(false), … … 480 489 Dijkstra &lengthMap(const LengthMap &m) 481 490 { 482 length = &m;491 _length = &m; 483 492 return *this; 484 493 } … … 487 496 488 497 ///Sets the map that stores the predecessor arcs. 489 ///If you don't use this function before calling \ref run(), 490 ///it will allocate one. The destructor deallocates this 491 ///automatically allocated map, of course. 498 ///If you don't use this function before calling \ref run(Node) "run()" 499 ///or \ref init(), an instance will be allocated automatically. 500 ///The destructor deallocates this automatically allocated map, 501 ///of course. 492 502 ///\return <tt> (*this) </tt> 493 503 Dijkstra &predMap(PredMap &m) … … 504 514 505 515 ///Sets the map that indicates which nodes are processed. 506 ///If you don't use this function before calling \ref run(), 507 ///it will allocate one. The destructor deallocates this 508 ///automatically allocated map, of course. 516 ///If you don't use this function before calling \ref run(Node) "run()" 517 ///or \ref init(), an instance will be allocated automatically. 518 ///The destructor deallocates this automatically allocated map, 519 ///of course. 509 520 ///\return <tt> (*this) </tt> 510 521 Dijkstra &processedMap(ProcessedMap &m) … … 522 533 ///Sets the map that stores the distances of the nodes calculated by the 523 534 ///algorithm. 524 ///If you don't use this function before calling \ref run(), 525 ///it will allocate one. The destructor deallocates this 526 ///automatically allocated map, of course. 535 ///If you don't use this function before calling \ref run(Node) "run()" 536 ///or \ref init(), an instance will be allocated automatically. 537 ///The destructor deallocates this automatically allocated map, 538 ///of course. 527 539 ///\return <tt> (*this) </tt> 528 540 Dijkstra &distMap(DistMap &m) … … 539 551 540 552 ///Sets the heap and the cross reference used by algorithm. 541 ///If you don't use this function before calling \ref run(), 542 ///it will allocate one. The destructor deallocates this 543 ///automatically allocated heap and cross reference, of course. 553 ///If you don't use this function before calling \ref run(Node) "run()" 554 ///or \ref init(), heap and cross reference instances will be 555 ///allocated automatically. 556 ///The destructor deallocates these automatically allocated objects, 557 ///of course. 544 558 ///\return <tt> (*this) </tt> 545 559 Dijkstra &heap(Heap& hp, HeapCrossRef &cr) … … 568 582 public: 569 583 570 ///\name Execution control 571 ///The simplest way to execute the algorithm is to use one of the 572 ///member functions called \ref lemon::Dijkstra::run() "run()". 573 ///\n 574 ///If you need more control on the execution, first you must call 575 ///\ref lemon::Dijkstra::init() "init()", then you can add several 576 ///source nodes with \ref lemon::Dijkstra::addSource() "addSource()". 577 ///Finally \ref lemon::Dijkstra::start() "start()" will perform the 578 ///actual path computation. 584 ///\name Execution Control 585 ///The simplest way to execute the %Dijkstra algorithm is to use 586 ///one of the member functions called \ref run(Node) "run()".\n 587 ///If you need more control on the execution, first you have to call 588 ///\ref init(), then you can add several source nodes with 589 ///\ref addSource(). Finally the actual path computation can be 590 ///performed with one of the \ref start() functions. 579 591 580 592 ///@{ 581 593 594 ///\brief Initializes the internal data structures. 595 /// 582 596 ///Initializes the internal data structures. 583 584 ///Initializes the internal data structures.585 ///586 597 void init() 587 598 { … … 631 642 switch(_heap->state(w)) { 632 643 case Heap::PRE_HEAP: 633 _heap->push(w,OperationTraits::plus(oldvalue, (* length)[e]));644 _heap->push(w,OperationTraits::plus(oldvalue, (*_length)[e])); 634 645 _pred->set(w,e); 635 646 break; 636 647 case Heap::IN_HEAP: 637 648 { 638 Value newvalue = OperationTraits::plus(oldvalue, (* length)[e]);649 Value newvalue = OperationTraits::plus(oldvalue, (*_length)[e]); 639 650 if ( OperationTraits::less(newvalue, (*_heap)[w]) ) { 640 651 _heap->decrease(w, newvalue); … … 659 670 } 660 671 661 ///\brief Returns \c false if there are nodes 662 ///to be processed. 663 /// 664 ///Returns \c false if there are nodes 665 ///to be processed in the priority heap. 672 ///Returns \c false if there are nodes to be processed. 673 674 ///Returns \c false if there are nodes to be processed 675 ///in the priority heap. 666 676 bool emptyQueue() const { return _heap->empty(); } 667 677 668 ///Returns the number of the nodes to be processed in the priority heap669 670 ///Returns the number of the nodes to be processed in the priority heap.671 /// 678 ///Returns the number of the nodes to be processed. 679 680 ///Returns the number of the nodes to be processed 681 ///in the priority heap. 672 682 int queueSize() const { return _heap->size(); } 673 683 … … 790 800 791 801 ///\name Query Functions 792 ///The result of the %Dijkstra algorithm can be obtained using these802 ///The results of the %Dijkstra algorithm can be obtained using these 793 803 ///functions.\n 794 ///Either \ref lemon::Dijkstra::run() "run()" or 795 ///\ref lemon::Dijkstra::start() "start()" must be called before 796 ///using them. 804 ///Either \ref run(Node) "run()" or \ref start() should be called 805 ///before using them. 797 806 798 807 ///@{ … … 802 811 ///Returns the shortest path to a node. 803 812 /// 804 ///\warning \c t should be reach ablefrom the root(s).805 /// 806 ///\pre Either \ref run( ) or \ref start() must be called before807 /// using this function.813 ///\warning \c t should be reached from the root(s). 814 /// 815 ///\pre Either \ref run(Node) "run()" or \ref init() 816 ///must be called before using this function. 808 817 Path path(Node t) const { return Path(*G, *_pred, t); } 809 818 … … 812 821 ///Returns the distance of a node from the root(s). 813 822 /// 814 ///\warning If node \c v is not reach ablefrom the root(s), then823 ///\warning If node \c v is not reached from the root(s), then 815 824 ///the return value of this function is undefined. 816 825 /// 817 ///\pre Either \ref run( ) or \ref start() must be called before818 /// using this function.826 ///\pre Either \ref run(Node) "run()" or \ref init() 827 ///must be called before using this function. 819 828 Value dist(Node v) const { return (*_dist)[v]; } 820 829 … … 823 832 ///This function returns the 'previous arc' of the shortest path 824 833 ///tree for the node \c v, i.e. it returns the last arc of a 825 ///shortest path from the root(s)to \c v. It is \c INVALID if \c v826 ///is not reach ablefrom the root(s) or if \c v is a root.834 ///shortest path from a root to \c v. It is \c INVALID if \c v 835 ///is not reached from the root(s) or if \c v is a root. 827 836 /// 828 837 ///The shortest path tree used here is equal to the shortest path 829 838 ///tree used in \ref predNode(). 830 839 /// 831 ///\pre Either \ref run( ) or \ref start() must be called before832 /// using this function.840 ///\pre Either \ref run(Node) "run()" or \ref init() 841 ///must be called before using this function. 833 842 Arc predArc(Node v) const { return (*_pred)[v]; } 834 843 … … 837 846 ///This function returns the 'previous node' of the shortest path 838 847 ///tree for the node \c v, i.e. it returns the last but one node 839 ///from a shortest path from the root(s)to \c v. It is \c INVALID840 ///if \c v is not reach ablefrom the root(s) or if \c v is a root.848 ///from a shortest path from a root to \c v. It is \c INVALID 849 ///if \c v is not reached from the root(s) or if \c v is a root. 841 850 /// 842 851 ///The shortest path tree used here is equal to the shortest path 843 852 ///tree used in \ref predArc(). 844 853 /// 845 ///\pre Either \ref run( ) or \ref start() must be called before846 /// using this function.854 ///\pre Either \ref run(Node) "run()" or \ref init() 855 ///must be called before using this function. 847 856 Node predNode(Node v) const { return (*_pred)[v]==INVALID ? INVALID: 848 857 G->source((*_pred)[v]); } … … 854 863 ///of the nodes calculated by the algorithm. 855 864 /// 856 ///\pre Either \ref run( )or \ref init()865 ///\pre Either \ref run(Node) "run()" or \ref init() 857 866 ///must be called before using this function. 858 867 const DistMap &distMap() const { return *_dist;} … … 864 873 ///arcs, which form the shortest path tree. 865 874 /// 866 ///\pre Either \ref run( )or \ref init()875 ///\pre Either \ref run(Node) "run()" or \ref init() 867 876 ///must be called before using this function. 868 877 const PredMap &predMap() const { return *_pred;} 869 878 870 ///Checks if a node is reachable from the root(s). 871 872 ///Returns \c true if \c v is reachable from the root(s). 873 ///\pre Either \ref run() or \ref start() 879 ///Checks if a node is reached from the root(s). 880 881 ///Returns \c true if \c v is reached from the root(s). 882 /// 883 ///\pre Either \ref run(Node) "run()" or \ref init() 874 884 ///must be called before using this function. 875 885 bool reached(Node v) const { return (*_heap_cross_ref)[v] != … … 880 890 ///Returns \c true if \c v is processed, i.e. the shortest 881 891 ///path to \c v has already found. 882 ///\pre Either \ref run() or \ref init() 892 /// 893 ///\pre Either \ref run(Node) "run()" or \ref init() 883 894 ///must be called before using this function. 884 895 bool processed(Node v) const { return (*_heap_cross_ref)[v] == … … 889 900 ///Returns the current distance of a node from the root(s). 890 901 ///It may be decreased in the following processes. 891 ///\pre Either \ref run() or \ref init() 902 /// 903 ///\pre Either \ref run(Node) "run()" or \ref init() 892 904 ///must be called before using this function and 893 905 ///node \c v must be reached but not necessarily processed. … … 904 916 ///Default traits class of dijkstra() function. 905 917 ///\tparam GR The type of the digraph. 906 ///\tparam L MThe type of the length map.907 template<class GR, class L M>918 ///\tparam LEN The type of the length map. 919 template<class GR, class LEN> 908 920 struct DijkstraWizardDefaultTraits 909 921 { … … 914 926 ///The type of the map that stores the arc lengths. 915 927 ///It must meet the \ref concepts::ReadMap "ReadMap" concept. 916 typedef L MLengthMap;928 typedef LEN LengthMap; 917 929 ///The type of the length of the arcs. 918 typedef typename L M::Value Value;930 typedef typename LEN::Value Value; 919 931 920 932 /// Operation traits for Dijkstra algorithm. … … 998 1010 ///The type of the map that stores the distances of the nodes. 999 1011 ///It must meet the \ref concepts::WriteMap "WriteMap" concept. 1000 typedef typename Digraph::template NodeMap<typename L M::Value> DistMap;1012 typedef typename Digraph::template NodeMap<typename LEN::Value> DistMap; 1001 1013 ///Instantiates a DistMap. 1002 1014 … … 1024 1036 /// The \ref DijkstraWizardBase is a class to be the default traits of the 1025 1037 /// \ref DijkstraWizard class. 1026 template< class GR,class LM>1027 class DijkstraWizardBase : public DijkstraWizardDefaultTraits<GR,L M>1038 template<typename GR, typename LEN> 1039 class DijkstraWizardBase : public DijkstraWizardDefaultTraits<GR,LEN> 1028 1040 { 1029 typedef DijkstraWizardDefaultTraits<GR,L M> Base;1041 typedef DijkstraWizardDefaultTraits<GR,LEN> Base; 1030 1042 protected: 1031 1043 //The type of the nodes in the digraph. … … 1061 1073 /// \param g The digraph the algorithm runs on. 1062 1074 /// \param l The length map. 1063 DijkstraWizardBase(const GR &g,const L M&l) :1075 DijkstraWizardBase(const GR &g,const LEN &l) : 1064 1076 _g(reinterpret_cast<void*>(const_cast<GR*>(&g))), 1065 _length(reinterpret_cast<void*>(const_cast<L M*>(&l))),1077 _length(reinterpret_cast<void*>(const_cast<LEN*>(&l))), 1066 1078 _processed(0), _pred(0), _dist(0), _path(0), _di(0) {} 1067 1079 … … 1072 1084 /// This auxiliary class is created to implement the 1073 1085 /// \ref dijkstra() "function-type interface" of \ref Dijkstra algorithm. 1074 /// It does not have own \ref run( ) method, it uses the functions1075 /// and features of the plain \ref Dijkstra.1086 /// It does not have own \ref run(Node) "run()" method, it uses the 1087 /// functions and features of the plain \ref Dijkstra. 1076 1088 /// 1077 1089 /// This class should only be used through the \ref dijkstra() function, … … 1268 1280 /// bool reached = dijkstra(g,length).path(p).dist(d).run(s,t); 1269 1281 ///\endcode 1270 ///\warning Don't forget to put the \ref DijkstraWizard::run( ) "run()"1282 ///\warning Don't forget to put the \ref DijkstraWizard::run(Node) "run()" 1271 1283 ///to the end of the parameter list. 1272 1284 ///\sa DijkstraWizard 1273 1285 ///\sa Dijkstra 1274 template< class GR, class LM>1275 DijkstraWizard<DijkstraWizardBase<GR,L M> >1276 dijkstra(const GR &digraph, const L M&length)1286 template<typename GR, typename LEN> 1287 DijkstraWizard<DijkstraWizardBase<GR,LEN> > 1288 dijkstra(const GR &digraph, const LEN &length) 1277 1289 { 1278 return DijkstraWizard<DijkstraWizardBase<GR,L M> >(digraph,length);1290 return DijkstraWizard<DijkstraWizardBase<GR,LEN> >(digraph,length); 1279 1291 } 1280 1292 -
lemon/dim2.h
r314 r463 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). -
lemon/error.h
r291 r463 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). -
lemon/graph_to_eps.h
r511 r664 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 65 65 ///Default traits class of \ref GraphToEps. 66 66 /// 67 ///\ c Gis the type of the underlying graph.68 template<class G >67 ///\param GR is the type of the underlying graph. 68 template<class GR> 69 69 struct DefaultGraphToEpsTraits 70 70 { 71 typedef G Graph; 71 typedef GR Graph; 72 typedef GR Digraph; 72 73 typedef typename Graph::Node Node; 73 74 typedef typename Graph::NodeIt NodeIt; … … 140 141 141 142 ///Constructor 142 ///\param _g Reference to the graph to be printed. 143 ///\param _os Reference to the output stream. 144 ///\param _os Reference to the output stream. 143 ///\param gr Reference to the graph to be printed. 144 ///\param ost Reference to the output stream. 145 145 ///By default it is <tt>std::cout</tt>. 146 ///\param _pros If it is \c true, then the \c ostream referenced by \c _os146 ///\param pros If it is \c true, then the \c ostream referenced by \c os 147 147 ///will be explicitly deallocated by the destructor. 148 DefaultGraphToEpsTraits(const G &_g,std::ostream& _os=std::cout,149 bool _pros=false) :150 g( _g), os(_os),148 DefaultGraphToEpsTraits(const GR &gr, std::ostream& ost = std::cout, 149 bool pros = false) : 150 g(gr), os(ost), 151 151 _coords(dim2::Point<double>(1,1)), _nodeSizes(1), _nodeShapes(0), 152 152 _nodeColors(WHITE), _arcColors(BLACK), … … 159 159 _showNodeText(false), _nodeTexts(false), _nodeTextSize(1), 160 160 _showNodePsText(false), _nodePsTexts(false), _nodePsTextsPreamble(0), 161 _undirected(lemon::UndirectedTagIndicator<G >::value),162 _pleaseRemoveOsStream( _pros), _scaleToA4(false),161 _undirected(lemon::UndirectedTagIndicator<GR>::value), 162 _pleaseRemoveOsStream(pros), _scaleToA4(false), 163 163 _nodeTextColorType(SAME_COL), _nodeTextColors(BLACK), 164 164 _autoNodeScale(false), … … 243 243 244 244 typedef typename T::Graph Graph; 245 typedef typename T::Digraph Digraph; 245 246 typedef typename Graph::Node Node; 246 247 typedef typename Graph::NodeIt NodeIt; … … 270 271 ///\image html nodeshape_1.png 271 272 ///\image latex nodeshape_1.eps "SQUARE shape (1)" width=2cm 272 ///273 273 SQUARE=1, 274 274 /// = 2 275 275 ///\image html nodeshape_2.png 276 276 ///\image latex nodeshape_2.eps "DIAMOND shape (2)" width=2cm 277 ///278 277 DIAMOND=2, 279 278 /// = 3 280 279 ///\image html nodeshape_3.png 281 ///\image latex nodeshape_2.eps "MALE shape (4)" width=2cm 282 /// 280 ///\image latex nodeshape_3.eps "MALE shape (3)" width=2cm 283 281 MALE=3, 284 282 /// = 4 285 283 ///\image html nodeshape_4.png 286 ///\image latex nodeshape_2.eps "FEMALE shape (4)" width=2cm 287 /// 284 ///\image latex nodeshape_4.eps "FEMALE shape (4)" width=2cm 288 285 FEMALE=4 289 286 }; … … 1135 1132 ///to the end of the parameter list. 1136 1133 ///\sa GraphToEps 1137 ///\sa graphToEps(G &g, const char *file_name)1138 template<class G >1139 GraphToEps<DefaultGraphToEpsTraits<G > >1140 graphToEps(G &g, std::ostream& os=std::cout)1134 ///\sa graphToEps(GR &g, const char *file_name) 1135 template<class GR> 1136 GraphToEps<DefaultGraphToEpsTraits<GR> > 1137 graphToEps(GR &g, std::ostream& os=std::cout) 1141 1138 { 1142 1139 return 1143 GraphToEps<DefaultGraphToEpsTraits<G > >(DefaultGraphToEpsTraits<G>(g,os));1140 GraphToEps<DefaultGraphToEpsTraits<GR> >(DefaultGraphToEpsTraits<GR>(g,os)); 1144 1141 } 1145 1142 … … 1148 1145 ///\ingroup eps_io 1149 1146 ///This function does the same as 1150 ///\ref graphToEps(G &g,std::ostream& os)1147 ///\ref graphToEps(GR &g,std::ostream& os) 1151 1148 ///but it writes its output into the file \c file_name 1152 1149 ///instead of a stream. 1153 ///\sa graphToEps(G &g, std::ostream& os)1154 template<class G >1155 GraphToEps<DefaultGraphToEpsTraits<G > >1156 graphToEps(G &g,const char *file_name)1150 ///\sa graphToEps(GR &g, std::ostream& os) 1151 template<class GR> 1152 GraphToEps<DefaultGraphToEpsTraits<GR> > 1153 graphToEps(GR &g,const char *file_name) 1157 1154 { 1158 1155 std::ostream* os = new std::ofstream(file_name); … … 1161 1158 throw IoError("Cannot write file", file_name); 1162 1159 } 1163 return GraphToEps<DefaultGraphToEpsTraits<G > >1164 (DefaultGraphToEpsTraits<G >(g,*os,true));1160 return GraphToEps<DefaultGraphToEpsTraits<GR> > 1161 (DefaultGraphToEpsTraits<GR>(g,*os,true)); 1165 1162 } 1166 1163 … … 1169 1166 ///\ingroup eps_io 1170 1167 ///This function does the same as 1171 ///\ref graphToEps(G &g,std::ostream& os)1168 ///\ref graphToEps(GR &g,std::ostream& os) 1172 1169 ///but it writes its output into the file \c file_name 1173 1170 ///instead of a stream. 1174 ///\sa graphToEps(G &g, std::ostream& os)1175 template<class G >1176 GraphToEps<DefaultGraphToEpsTraits<G > >1177 graphToEps(G &g,const std::string& file_name)1171 ///\sa graphToEps(GR &g, std::ostream& os) 1172 template<class GR> 1173 GraphToEps<DefaultGraphToEpsTraits<GR> > 1174 graphToEps(GR &g,const std::string& file_name) 1178 1175 { 1179 1176 std::ostream* os = new std::ofstream(file_name.c_str()); … … 1182 1179 throw IoError("Cannot write file", file_name); 1183 1180 } 1184 return GraphToEps<DefaultGraphToEpsTraits<G > >1185 (DefaultGraphToEpsTraits<G >(g,*os,true));1181 return GraphToEps<DefaultGraphToEpsTraits<GR> > 1182 (DefaultGraphToEpsTraits<GR>(g,*os,true)); 1186 1183 } 1187 1184 -
lemon/kruskal.h
r220 r631 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 249 249 /// \ingroup spantree 250 250 /// 251 /// \brief Kruskal algorithm to finda minimum cost spanning tree of251 /// \brief Kruskal's algorithm for finding a minimum cost spanning tree of 252 252 /// a graph. 253 253 /// 254 254 /// This function runs Kruskal's algorithm to find a minimum cost 255 /// spanning tree .255 /// spanning tree of a graph. 256 256 /// Due to some C++ hacking, it accepts various input and output types. 257 257 /// … … 265 265 /// It can be one of the following choices. 266 266 /// - An STL compatible 'Forward Container' with 267 /// <tt>std::pair<GR::Arc, X></tt> or268 /// <tt>std::pair<GR::Edge, X></tt> as its <tt>value_type</tt>, where269 /// \c Xis the type of the costs. The pairs indicates the arcs/edges267 /// <tt>std::pair<GR::Arc,C></tt> or 268 /// <tt>std::pair<GR::Edge,C></tt> as its <tt>value_type</tt>, where 269 /// \c C is the type of the costs. The pairs indicates the arcs/edges 270 270 /// along with the assigned cost. <em>They must be in a 271 271 /// cost-ascending order.</em> … … 274 274 /// 275 275 /// \retval out Here we also have a choice. 276 /// - It can be a writable \c bool arc/edge map. After running the277 /// algorithm it will contain the found minimum cost spanning276 /// - It can be a writable arc/edge map with \c bool value type. After 277 /// running the algorithm it will contain the found minimum cost spanning 278 278 /// tree: the value of an arc/edge will be set to \c true if it belongs 279 279 /// to the tree, otherwise it will be set to \c false. The value of … … 302 302 303 303 #ifdef DOXYGEN 304 template < class Graph, class In, classOut>305 Value kruskal( GR const& g, const In& in, Out& out)304 template <typename Graph, typename In, typename Out> 305 Value kruskal(const Graph& g, const In& in, Out& out) 306 306 #else 307 307 template <class Graph, class In, class Out> … … 315 315 316 316 317 318 319 317 template <class Graph, class In, class Out> 320 318 inline typename _kruskal_bits::KruskalValueSelector<In>::Value -
lemon/lgf_reader.h
r517 r646 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 102 102 }; 103 103 104 template <typename _G raph, bool _dir, typename _Map,104 template <typename _GR, bool _dir, typename _Map, 105 105 typename _Converter = DefaultConverter<typename _Map::Value> > 106 class GraphArcMapStorage : public MapStorageBase<typename _G raph::Edge> {106 class GraphArcMapStorage : public MapStorageBase<typename _GR::Edge> { 107 107 public: 108 108 typedef _Map Map; 109 109 typedef _Converter Converter; 110 typedef _G raph Graph;111 typedef typename G raph::Edge Item;110 typedef _GR GR; 111 typedef typename GR::Edge Item; 112 112 static const bool dir = _dir; 113 113 114 114 private: 115 const G raph& _graph;115 const GR& _graph; 116 116 Map& _map; 117 117 Converter _converter; 118 118 119 119 public: 120 GraphArcMapStorage(const G raph& graph, Map& map,120 GraphArcMapStorage(const GR& graph, Map& map, 121 121 const Converter& converter = Converter()) 122 122 : _graph(graph), _map(map), _converter(converter) {} … … 174 174 }; 175 175 176 template <typename G raph>176 template <typename GR> 177 177 struct GraphArcLookUpConverter { 178 const G raph& _graph;179 const std::map<std::string, typename G raph::Edge>& _map;180 181 GraphArcLookUpConverter(const G raph& graph,178 const GR& _graph; 179 const std::map<std::string, typename GR::Edge>& _map; 180 181 GraphArcLookUpConverter(const GR& graph, 182 182 const std::map<std::string, 183 typename G raph::Edge>& map)183 typename GR::Edge>& map) 184 184 : _graph(graph), _map(map) {} 185 185 186 typename G raph::Arc operator()(const std::string& str) {186 typename GR::Arc operator()(const std::string& str) { 187 187 if (str.empty() || (str[0] != '+' && str[0] != '-')) { 188 188 throw FormatError("Item must start with '+' or '-'"); 189 189 } 190 typename std::map<std::string, typename G raph::Edge>190 typename std::map<std::string, typename GR::Edge> 191 191 ::const_iterator it = _map.find(str.substr(1)); 192 192 if (it == _map.end()) { … … 388 388 } 389 389 390 template <typename D igraph>390 template <typename DGR> 391 391 class DigraphReader; 392 392 393 template <typename Digraph> 394 DigraphReader<Digraph> digraphReader(Digraph& digraph, 395 std::istream& is = std::cin); 396 template <typename Digraph> 397 DigraphReader<Digraph> digraphReader(Digraph& digraph, const std::string& fn); 398 template <typename Digraph> 399 DigraphReader<Digraph> digraphReader(Digraph& digraph, const char *fn); 393 template <typename TDGR> 394 DigraphReader<TDGR> digraphReader(TDGR& digraph, std::istream& is = std::cin); 395 template <typename TDGR> 396 DigraphReader<TDGR> digraphReader(TDGR& digraph, const std::string& fn); 397 template <typename TDGR> 398 DigraphReader<TDGR> digraphReader(TDGR& digraph, const char *fn); 400 399 401 400 /// \ingroup lemon_io … … 420 419 /// 421 420 ///\code 422 /// DigraphReader<D igraph>(digraph, std::cin).421 /// DigraphReader<DGR>(digraph, std::cin). 423 422 /// nodeMap("coordinates", coord_map). 424 423 /// arcMap("capacity", cap_map). … … 449 448 /// a single pass, because the arcs are not constructed when the node 450 449 /// maps are read. 451 template <typename _Digraph>450 template <typename DGR> 452 451 class DigraphReader { 453 452 public: 454 453 455 typedef _Digraph Digraph; 456 TEMPLATE_DIGRAPH_TYPEDEFS(Digraph); 454 typedef DGR Digraph; 457 455 458 456 private: 459 457 458 TEMPLATE_DIGRAPH_TYPEDEFS(DGR); 460 459 461 460 std::istream* _is; … … 463 462 std::string _filename; 464 463 465 D igraph& _digraph;464 DGR& _digraph; 466 465 467 466 std::string _nodes_caption; … … 501 500 /// Construct a directed graph reader, which reads from the given 502 501 /// input stream. 503 DigraphReader(D igraph& digraph, std::istream& is = std::cin)502 DigraphReader(DGR& digraph, std::istream& is = std::cin) 504 503 : _is(&is), local_is(false), _digraph(digraph), 505 504 _use_nodes(false), _use_arcs(false), … … 510 509 /// Construct a directed graph reader, which reads from the given 511 510 /// file. 512 DigraphReader(D igraph& digraph, const std::string& fn)511 DigraphReader(DGR& digraph, const std::string& fn) 513 512 : _is(new std::ifstream(fn.c_str())), local_is(true), 514 513 _filename(fn), _digraph(digraph), … … 525 524 /// Construct a directed graph reader, which reads from the given 526 525 /// file. 527 DigraphReader(D igraph& digraph, const char* fn)526 DigraphReader(DGR& digraph, const char* fn) 528 527 : _is(new std::ifstream(fn)), local_is(true), 529 528 _filename(fn), _digraph(digraph), … … 561 560 private: 562 561 563 template <typename DGR>564 friend DigraphReader< DGR> digraphReader(DGR& digraph, std::istream& is);565 template <typename DGR>566 friend DigraphReader< DGR> digraphReader(DGR& digraph,567 const std::string& fn);568 template <typename DGR>569 friend DigraphReader< DGR> digraphReader(DGR& digraph, const char *fn);562 template <typename TDGR> 563 friend DigraphReader<TDGR> digraphReader(TDGR& digraph, std::istream& is); 564 template <typename TDGR> 565 friend DigraphReader<TDGR> digraphReader(TDGR& digraph, 566 const std::string& fn); 567 template <typename TDGR> 568 friend DigraphReader<TDGR> digraphReader(TDGR& digraph, const char *fn); 570 569 571 570 DigraphReader(DigraphReader& other) … … 594 593 public: 595 594 596 /// \name Reading rules595 /// \name Reading Rules 597 596 /// @{ 598 597 … … 699 698 /// @} 700 699 701 /// \name Select section by name700 /// \name Select Section by Name 702 701 /// @{ 703 702 … … 728 727 /// @} 729 728 730 /// \name Using previously constructed node or arc set729 /// \name Using Previously Constructed Node or Arc Set 731 730 /// @{ 732 731 … … 848 847 readLine(); 849 848 } 850 line.putback(c); 849 if (readSuccess()) { 850 line.putback(c); 851 } 851 852 } 852 853 … … 1115 1116 public: 1116 1117 1117 /// \name Execution of the reader1118 /// \name Execution of the Reader 1118 1119 /// @{ 1119 1120 … … 1187 1188 1188 1189 }; 1190 1191 /// \ingroup lemon_io 1192 /// 1193 /// \brief Return a \ref DigraphReader class 1194 /// 1195 /// This function just returns a \ref DigraphReader class. 1196 /// 1197 /// With this function a digraph can be read from an 1198 /// \ref lgf-format "LGF" file or input stream with several maps and 1199 /// attributes. For example, there is network flow problem on a 1200 /// digraph, i.e. a digraph with a \e capacity map on the arcs and 1201 /// \e source and \e target nodes. This digraph can be read with the 1202 /// following code: 1203 /// 1204 ///\code 1205 ///ListDigraph digraph; 1206 ///ListDigraph::ArcMap<int> cm(digraph); 1207 ///ListDigraph::Node src, trg; 1208 ///digraphReader(digraph, std::cin). 1209 /// arcMap("capacity", cap). 1210 /// node("source", src). 1211 /// node("target", trg). 1212 /// run(); 1213 ///\endcode 1214 /// 1215 /// For a complete documentation, please see the \ref DigraphReader 1216 /// class documentation. 1217 /// \warning Don't forget to put the \ref DigraphReader::run() "run()" 1218 /// to the end of the parameter list. 1219 /// \relates DigraphReader 1220 /// \sa digraphReader(TDGR& digraph, const std::string& fn) 1221 /// \sa digraphReader(TDGR& digraph, const char* fn) 1222 template <typename TDGR> 1223 DigraphReader<TDGR> digraphReader(TDGR& digraph, std::istream& is) { 1224 DigraphReader<TDGR> tmp(digraph, is); 1225 return tmp; 1226 } 1189 1227 1190 1228 /// \brief Return a \ref DigraphReader class … … 1192 1230 /// This function just returns a \ref DigraphReader class. 1193 1231 /// \relates DigraphReader 1194 template <typename Digraph> 1195 DigraphReader<Digraph> digraphReader(Digraph& digraph, std::istream& is) { 1196 DigraphReader<Digraph> tmp(digraph, is); 1232 /// \sa digraphReader(TDGR& digraph, std::istream& is) 1233 template <typename TDGR> 1234 DigraphReader<TDGR> digraphReader(TDGR& digraph, const std::string& fn) { 1235 DigraphReader<TDGR> tmp(digraph, fn); 1197 1236 return tmp; 1198 1237 } … … 1202 1241 /// This function just returns a \ref DigraphReader class. 1203 1242 /// \relates DigraphReader 1204 template <typename Digraph>1205 DigraphReader<Digraph> digraphReader(Digraph& digraph,1206 const std::string&fn) {1207 DigraphReader< Digraph> tmp(digraph, fn);1243 /// \sa digraphReader(TDGR& digraph, std::istream& is) 1244 template <typename TDGR> 1245 DigraphReader<TDGR> digraphReader(TDGR& digraph, const char* fn) { 1246 DigraphReader<TDGR> tmp(digraph, fn); 1208 1247 return tmp; 1209 1248 } 1210 1249 1211 /// \brief Return a \ref DigraphReader class 1212 /// 1213 /// This function just returns a \ref DigraphReader class. 1214 /// \relates DigraphReader 1215 template <typename Digraph> 1216 DigraphReader<Digraph> digraphReader(Digraph& digraph, const char* fn) { 1217 DigraphReader<Digraph> tmp(digraph, fn); 1218 return tmp; 1219 } 1220 1221 template <typename Graph> 1250 template <typename GR> 1222 1251 class GraphReader; 1223 1252 1224 template <typename Graph> 1225 GraphReader<Graph> graphReader(Graph& graph, 1226 std::istream& is = std::cin); 1227 template <typename Graph> 1228 GraphReader<Graph> graphReader(Graph& graph, const std::string& fn); 1229 template <typename Graph> 1230 GraphReader<Graph> graphReader(Graph& graph, const char *fn); 1253 template <typename TGR> 1254 GraphReader<TGR> graphReader(TGR& graph, std::istream& is = std::cin); 1255 template <typename TGR> 1256 GraphReader<TGR> graphReader(TGR& graph, const std::string& fn); 1257 template <typename TGR> 1258 GraphReader<TGR> graphReader(TGR& graph, const char *fn); 1231 1259 1232 1260 /// \ingroup lemon_io … … 1245 1273 /// arc map. Similarly, an attribute can be read into an arc, if 1246 1274 /// it's value is an edge label prefixed with \c '+' or \c '-'. 1247 template <typename _Graph>1275 template <typename GR> 1248 1276 class GraphReader { 1249 1277 public: 1250 1278 1251 typedef _Graph Graph; 1252 TEMPLATE_GRAPH_TYPEDEFS(Graph); 1279 typedef GR Graph; 1253 1280 1254 1281 private: 1282 1283 TEMPLATE_GRAPH_TYPEDEFS(GR); 1255 1284 1256 1285 std::istream* _is; … … 1258 1287 std::string _filename; 1259 1288 1260 G raph& _graph;1289 GR& _graph; 1261 1290 1262 1291 std::string _nodes_caption; … … 1296 1325 /// Construct an undirected graph reader, which reads from the given 1297 1326 /// input stream. 1298 GraphReader(G raph& graph, std::istream& is = std::cin)1327 GraphReader(GR& graph, std::istream& is = std::cin) 1299 1328 : _is(&is), local_is(false), _graph(graph), 1300 1329 _use_nodes(false), _use_edges(false), … … 1305 1334 /// Construct an undirected graph reader, which reads from the given 1306 1335 /// file. 1307 GraphReader(G raph& graph, const std::string& fn)1336 GraphReader(GR& graph, const std::string& fn) 1308 1337 : _is(new std::ifstream(fn.c_str())), local_is(true), 1309 1338 _filename(fn), _graph(graph), … … 1320 1349 /// Construct an undirected graph reader, which reads from the given 1321 1350 /// file. 1322 GraphReader(G raph& graph, const char* fn)1351 GraphReader(GR& graph, const char* fn) 1323 1352 : _is(new std::ifstream(fn)), local_is(true), 1324 1353 _filename(fn), _graph(graph), … … 1355 1384 1356 1385 private: 1357 template <typename GR>1358 friend GraphReader< GR> graphReader(GR& graph, std::istream& is);1359 template <typename GR>1360 friend GraphReader< GR> graphReader(GR& graph, const std::string& fn);1361 template <typename GR>1362 friend GraphReader< GR> graphReader(GR& graph, const char *fn);1386 template <typename TGR> 1387 friend GraphReader<TGR> graphReader(TGR& graph, std::istream& is); 1388 template <typename TGR> 1389 friend GraphReader<TGR> graphReader(TGR& graph, const std::string& fn); 1390 template <typename TGR> 1391 friend GraphReader<TGR> graphReader(TGR& graph, const char *fn); 1363 1392 1364 1393 GraphReader(GraphReader& other) … … 1387 1416 public: 1388 1417 1389 /// \name Reading rules1418 /// \name Reading Rules 1390 1419 /// @{ 1391 1420 … … 1452 1481 _edge_maps.push_back(std::make_pair('+' + caption, forward_storage)); 1453 1482 _reader_bits::MapStorageBase<Edge>* backward_storage = 1454 new _reader_bits::GraphArcMapStorage<G raph, false, Map>(_graph, map);1483 new _reader_bits::GraphArcMapStorage<GR, false, Map>(_graph, map); 1455 1484 _edge_maps.push_back(std::make_pair('-' + caption, backward_storage)); 1456 1485 return *this; … … 1466 1495 checkConcept<concepts::WriteMap<Arc, typename Map::Value>, Map>(); 1467 1496 _reader_bits::MapStorageBase<Edge>* forward_storage = 1468 new _reader_bits::GraphArcMapStorage<G raph, true, Map, Converter>1497 new _reader_bits::GraphArcMapStorage<GR, true, Map, Converter> 1469 1498 (_graph, map, converter); 1470 1499 _edge_maps.push_back(std::make_pair('+' + caption, forward_storage)); 1471 1500 _reader_bits::MapStorageBase<Edge>* backward_storage = 1472 new _reader_bits::GraphArcMapStorage<G raph, false, Map, Converter>1501 new _reader_bits::GraphArcMapStorage<GR, false, Map, Converter> 1473 1502 (_graph, map, converter); 1474 1503 _edge_maps.push_back(std::make_pair('-' + caption, backward_storage)); … … 1528 1557 /// Add an arc reading rule to reader. 1529 1558 GraphReader& arc(const std::string& caption, Arc& arc) { 1530 typedef _reader_bits::GraphArcLookUpConverter<G raph> Converter;1559 typedef _reader_bits::GraphArcLookUpConverter<GR> Converter; 1531 1560 Converter converter(_graph, _edge_index); 1532 1561 _reader_bits::ValueStorageBase* storage = … … 1538 1567 /// @} 1539 1568 1540 /// \name Select section by name1569 /// \name Select Section by Name 1541 1570 /// @{ 1542 1571 … … 1567 1596 /// @} 1568 1597 1569 /// \name Using previously constructed node or edge set1598 /// \name Using Previously Constructed Node or Edge Set 1570 1599 /// @{ 1571 1600 … … 1688 1717 readLine(); 1689 1718 } 1690 line.putback(c); 1719 if (readSuccess()) { 1720 line.putback(c); 1721 } 1691 1722 } 1692 1723 … … 1955 1986 public: 1956 1987 1957 /// \name Execution of the reader1988 /// \name Execution of the Reader 1958 1989 /// @{ 1959 1990 … … 2029 2060 }; 2030 2061 2062 /// \ingroup lemon_io 2063 /// 2064 /// \brief Return a \ref GraphReader class 2065 /// 2066 /// This function just returns a \ref GraphReader class. 2067 /// 2068 /// With this function a graph can be read from an 2069 /// \ref lgf-format "LGF" file or input stream with several maps and 2070 /// attributes. For example, there is weighted matching problem on a 2071 /// graph, i.e. a graph with a \e weight map on the edges. This 2072 /// graph can be read with the following code: 2073 /// 2074 ///\code 2075 ///ListGraph graph; 2076 ///ListGraph::EdgeMap<int> weight(graph); 2077 ///graphReader(graph, std::cin). 2078 /// edgeMap("weight", weight). 2079 /// run(); 2080 ///\endcode 2081 /// 2082 /// For a complete documentation, please see the \ref GraphReader 2083 /// class documentation. 2084 /// \warning Don't forget to put the \ref GraphReader::run() "run()" 2085 /// to the end of the parameter list. 2086 /// \relates GraphReader 2087 /// \sa graphReader(TGR& graph, const std::string& fn) 2088 /// \sa graphReader(TGR& graph, const char* fn) 2089 template <typename TGR> 2090 GraphReader<TGR> graphReader(TGR& graph, std::istream& is) { 2091 GraphReader<TGR> tmp(graph, is); 2092 return tmp; 2093 } 2094 2031 2095 /// \brief Return a \ref GraphReader class 2032 2096 /// 2033 2097 /// This function just returns a \ref GraphReader class. 2034 2098 /// \relates GraphReader 2035 template <typename Graph> 2036 GraphReader<Graph> graphReader(Graph& graph, std::istream& is) { 2037 GraphReader<Graph> tmp(graph, is); 2099 /// \sa graphReader(TGR& graph, std::istream& is) 2100 template <typename TGR> 2101 GraphReader<TGR> graphReader(TGR& graph, const std::string& fn) { 2102 GraphReader<TGR> tmp(graph, fn); 2038 2103 return tmp; 2039 2104 } … … 2043 2108 /// This function just returns a \ref GraphReader class. 2044 2109 /// \relates GraphReader 2045 template <typename Graph> 2046 GraphReader<Graph> graphReader(Graph& graph, const std::string& fn) { 2047 GraphReader<Graph> tmp(graph, fn); 2048 return tmp; 2049 } 2050 2051 /// \brief Return a \ref GraphReader class 2052 /// 2053 /// This function just returns a \ref GraphReader class. 2054 /// \relates GraphReader 2055 template <typename Graph> 2056 GraphReader<Graph> graphReader(Graph& graph, const char* fn) { 2057 GraphReader<Graph> tmp(graph, fn); 2110 /// \sa graphReader(TGR& graph, std::istream& is) 2111 template <typename TGR> 2112 GraphReader<TGR> graphReader(TGR& graph, const char* fn) { 2113 GraphReader<TGR> tmp(graph, fn); 2058 2114 return tmp; 2059 2115 } … … 2154 2210 public: 2155 2211 2156 /// \name Section readers2212 /// \name Section Readers 2157 2213 /// @{ 2158 2214 … … 2245 2301 readLine(); 2246 2302 } 2247 line.putback(c); 2303 if (readSuccess()) { 2304 line.putback(c); 2305 } 2248 2306 } 2249 2307 … … 2251 2309 2252 2310 2253 /// \name Execution of the reader2311 /// \name Execution of the Reader 2254 2312 /// @{ 2255 2313 … … 2310 2368 }; 2311 2369 2370 /// \ingroup lemon_io 2371 /// 2312 2372 /// \brief Return a \ref SectionReader class 2313 2373 /// 2314 2374 /// This function just returns a \ref SectionReader class. 2375 /// 2376 /// Please see SectionReader documentation about the custom section 2377 /// input. 2378 /// 2315 2379 /// \relates SectionReader 2380 /// \sa sectionReader(const std::string& fn) 2381 /// \sa sectionReader(const char *fn) 2316 2382 inline SectionReader sectionReader(std::istream& is) { 2317 2383 SectionReader tmp(is); … … 2323 2389 /// This function just returns a \ref SectionReader class. 2324 2390 /// \relates SectionReader 2391 /// \sa sectionReader(std::istream& is) 2325 2392 inline SectionReader sectionReader(const std::string& fn) { 2326 2393 SectionReader tmp(fn); … … 2332 2399 /// This function just returns a \ref SectionReader class. 2333 2400 /// \relates SectionReader 2401 /// \sa sectionReader(std::istream& is) 2334 2402 inline SectionReader sectionReader(const char* fn) { 2335 2403 SectionReader tmp(fn); … … 2433 2501 2434 2502 2435 /// \name Node sections2503 /// \name Node Sections 2436 2504 /// @{ 2437 2505 … … 2459 2527 /// @} 2460 2528 2461 /// \name Arc/Edge sections2529 /// \name Arc/Edge Sections 2462 2530 /// @{ 2463 2531 … … 2517 2585 /// @} 2518 2586 2519 /// \name Attribute sections2587 /// \name Attribute Sections 2520 2588 /// @{ 2521 2589 … … 2543 2611 /// @} 2544 2612 2545 /// \name Extra sections2613 /// \name Extra Sections 2546 2614 /// @{ 2547 2615 … … 2586 2654 readLine(); 2587 2655 } 2588 line.putback(c); 2656 if (readSuccess()) { 2657 line.putback(c); 2658 } 2589 2659 } 2590 2660 … … 2617 2687 public: 2618 2688 2619 /// \name Execution of the contents reader2689 /// \name Execution of the Contents Reader 2620 2690 /// @{ 2621 2691 -
lemon/lgf_writer.h
r517 r646 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 348 348 } 349 349 350 template <typename D igraph>350 template <typename DGR> 351 351 class DigraphWriter; 352 352 353 template <typename Digraph> 354 DigraphWriter<Digraph> digraphWriter(const Digraph& digraph, 355 std::ostream& os = std::cout); 356 template <typename Digraph> 357 DigraphWriter<Digraph> digraphWriter(const Digraph& digraph, 358 const std::string& fn); 359 360 template <typename Digraph> 361 DigraphWriter<Digraph> digraphWriter(const Digraph& digraph, 362 const char* fn); 353 template <typename TDGR> 354 DigraphWriter<TDGR> digraphWriter(const TDGR& digraph, 355 std::ostream& os = std::cout); 356 template <typename TDGR> 357 DigraphWriter<TDGR> digraphWriter(const TDGR& digraph, const std::string& fn); 358 359 template <typename TDGR> 360 DigraphWriter<TDGR> digraphWriter(const TDGR& digraph, const char* fn); 363 361 364 362 … … 382 380 /// 383 381 ///\code 384 /// DigraphWriter<D igraph>(digraph, std::cout).382 /// DigraphWriter<DGR>(digraph, std::cout). 385 383 /// nodeMap("coordinates", coord_map). 386 384 /// nodeMap("size", size). … … 407 405 /// the \c ostream() function, hence the second pass can append its 408 406 /// output to the output of the first pass. 409 template <typename _Digraph>407 template <typename DGR> 410 408 class DigraphWriter { 411 409 public: 412 410 413 typedef _DigraphDigraph;414 TEMPLATE_DIGRAPH_TYPEDEFS(D igraph);411 typedef DGR Digraph; 412 TEMPLATE_DIGRAPH_TYPEDEFS(DGR); 415 413 416 414 private: … … 420 418 bool local_os; 421 419 422 const D igraph& _digraph;420 const DGR& _digraph; 423 421 424 422 std::string _nodes_caption; … … 452 450 /// Construct a directed graph writer, which writes to the given 453 451 /// output stream. 454 DigraphWriter(const D igraph& digraph, std::ostream& os = std::cout)452 DigraphWriter(const DGR& digraph, std::ostream& os = std::cout) 455 453 : _os(&os), local_os(false), _digraph(digraph), 456 454 _skip_nodes(false), _skip_arcs(false) {} … … 460 458 /// Construct a directed graph writer, which writes to the given 461 459 /// output file. 462 DigraphWriter(const D igraph& digraph, const std::string& fn)460 DigraphWriter(const DGR& digraph, const std::string& fn) 463 461 : _os(new std::ofstream(fn.c_str())), local_os(true), _digraph(digraph), 464 462 _skip_nodes(false), _skip_arcs(false) { … … 473 471 /// Construct a directed graph writer, which writes to the given 474 472 /// output file. 475 DigraphWriter(const D igraph& digraph, const char* fn)473 DigraphWriter(const DGR& digraph, const char* fn) 476 474 : _os(new std::ofstream(fn)), local_os(true), _digraph(digraph), 477 475 _skip_nodes(false), _skip_arcs(false) { … … 506 504 private: 507 505 508 template <typename DGR>509 friend DigraphWriter< DGR> digraphWriter(constDGR& digraph,510 std::ostream& os);511 template <typename DGR>512 friend DigraphWriter< DGR> digraphWriter(constDGR& digraph,513 const std::string& fn);514 template <typename DGR>515 friend DigraphWriter< DGR> digraphWriter(constDGR& digraph,516 const char *fn);506 template <typename TDGR> 507 friend DigraphWriter<TDGR> digraphWriter(const TDGR& digraph, 508 std::ostream& os); 509 template <typename TDGR> 510 friend DigraphWriter<TDGR> digraphWriter(const TDGR& digraph, 511 const std::string& fn); 512 template <typename TDGR> 513 friend DigraphWriter<TDGR> digraphWriter(const TDGR& digraph, 514 const char *fn); 517 515 518 516 DigraphWriter(DigraphWriter& other) … … 539 537 public: 540 538 541 /// \name Writing rules539 /// \name Writing Rules 542 540 /// @{ 543 541 … … 642 640 } 643 641 644 /// \name Section captions642 /// \name Section Captions 645 643 /// @{ 646 644 … … 669 667 } 670 668 671 /// \name Skipping section669 /// \name Skipping Section 672 670 /// @{ 673 671 … … 725 723 726 724 if (label == 0) { 727 IdMap<D igraph, Node> id_map(_digraph);728 _writer_bits::MapLess<IdMap<D igraph, Node> > id_less(id_map);725 IdMap<DGR, Node> id_map(_digraph); 726 _writer_bits::MapLess<IdMap<DGR, Node> > id_less(id_map); 729 727 std::sort(nodes.begin(), nodes.end(), id_less); 730 728 } else { … … 810 808 811 809 if (label == 0) { 812 IdMap<D igraph, Arc> id_map(_digraph);813 _writer_bits::MapLess<IdMap<D igraph, Arc> > id_less(id_map);810 IdMap<DGR, Arc> id_map(_digraph); 811 _writer_bits::MapLess<IdMap<DGR, Arc> > id_less(id_map); 814 812 std::sort(arcs.begin(), arcs.end(), id_less); 815 813 } else { … … 886 884 public: 887 885 888 /// \name Execution of the writer886 /// \name Execution of the Writer 889 887 /// @{ 890 888 … … 916 914 }; 917 915 916 /// \ingroup lemon_io 917 /// 918 /// \brief Return a \ref DigraphWriter class 919 /// 920 /// This function just returns a \ref DigraphWriter class. 921 /// 922 /// With this function a digraph can be write to a file or output 923 /// stream in \ref lgf-format "LGF" format with several maps and 924 /// attributes. For example, with the following code a network flow 925 /// problem can be written to the standard output, i.e. a digraph 926 /// with a \e capacity map on the arcs and \e source and \e target 927 /// nodes: 928 /// 929 ///\code 930 ///ListDigraph digraph; 931 ///ListDigraph::ArcMap<int> cap(digraph); 932 ///ListDigraph::Node src, trg; 933 /// // Setting the capacity map and source and target nodes 934 ///digraphWriter(digraph, std::cout). 935 /// arcMap("capacity", cap). 936 /// node("source", src). 937 /// node("target", trg). 938 /// run(); 939 ///\endcode 940 /// 941 /// For a complete documentation, please see the \ref DigraphWriter 942 /// class documentation. 943 /// \warning Don't forget to put the \ref DigraphWriter::run() "run()" 944 /// to the end of the parameter list. 945 /// \relates DigraphWriter 946 /// \sa digraphWriter(const TDGR& digraph, const std::string& fn) 947 /// \sa digraphWriter(const TDGR& digraph, const char* fn) 948 template <typename TDGR> 949 DigraphWriter<TDGR> digraphWriter(const TDGR& digraph, std::ostream& os) { 950 DigraphWriter<TDGR> tmp(digraph, os); 951 return tmp; 952 } 953 918 954 /// \brief Return a \ref DigraphWriter class 919 955 /// 920 956 /// This function just returns a \ref DigraphWriter class. 921 957 /// \relates DigraphWriter 922 template <typename Digraph> 923 DigraphWriter<Digraph> digraphWriter(const Digraph& digraph, 924 std::ostream& os) { 925 DigraphWriter<Digraph> tmp(digraph, os); 958 /// \sa digraphWriter(const TDGR& digraph, std::ostream& os) 959 template <typename TDGR> 960 DigraphWriter<TDGR> digraphWriter(const TDGR& digraph, 961 const std::string& fn) { 962 DigraphWriter<TDGR> tmp(digraph, fn); 926 963 return tmp; 927 964 } … … 931 968 /// This function just returns a \ref DigraphWriter class. 932 969 /// \relates DigraphWriter 933 template <typename Digraph>934 DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,935 const std::string&fn) {936 DigraphWriter< Digraph> tmp(digraph, fn);970 /// \sa digraphWriter(const TDGR& digraph, std::ostream& os) 971 template <typename TDGR> 972 DigraphWriter<TDGR> digraphWriter(const TDGR& digraph, const char* fn) { 973 DigraphWriter<TDGR> tmp(digraph, fn); 937 974 return tmp; 938 975 } 939 976 940 /// \brief Return a \ref DigraphWriter class 941 /// 942 /// This function just returns a \ref DigraphWriter class. 943 /// \relates DigraphWriter 944 template <typename Digraph> 945 DigraphWriter<Digraph> digraphWriter(const Digraph& digraph, 946 const char* fn) { 947 DigraphWriter<Digraph> tmp(digraph, fn); 948 return tmp; 949 } 950 951 template <typename Graph> 977 template <typename GR> 952 978 class GraphWriter; 953 979 954 template <typename Graph> 955 GraphWriter<Graph> graphWriter(const Graph& graph, 956 std::ostream& os = std::cout); 957 template <typename Graph> 958 GraphWriter<Graph> graphWriter(const Graph& graph, const std::string& fn); 959 template <typename Graph> 960 GraphWriter<Graph> graphWriter(const Graph& graph, const char* fn); 980 template <typename TGR> 981 GraphWriter<TGR> graphWriter(const TGR& graph, std::ostream& os = std::cout); 982 template <typename TGR> 983 GraphWriter<TGR> graphWriter(const TGR& graph, const std::string& fn); 984 template <typename TGR> 985 GraphWriter<TGR> graphWriter(const TGR& graph, const char* fn); 961 986 962 987 /// \ingroup lemon_io … … 975 1000 /// section as a \c '+' or a \c '-' prefix (depends on the direction 976 1001 /// of the arc) and the label of corresponding edge. 977 template <typename _Graph>1002 template <typename GR> 978 1003 class GraphWriter { 979 1004 public: 980 1005 981 typedef _GraphGraph;982 TEMPLATE_GRAPH_TYPEDEFS(G raph);1006 typedef GR Graph; 1007 TEMPLATE_GRAPH_TYPEDEFS(GR); 983 1008 984 1009 private: … … 988 1013 bool local_os; 989 1014 990 const G raph& _graph;1015 const GR& _graph; 991 1016 992 1017 std::string _nodes_caption; … … 1020 1045 /// Construct a directed graph writer, which writes to the given 1021 1046 /// output stream. 1022 GraphWriter(const G raph& graph, std::ostream& os = std::cout)1047 GraphWriter(const GR& graph, std::ostream& os = std::cout) 1023 1048 : _os(&os), local_os(false), _graph(graph), 1024 1049 _skip_nodes(false), _skip_edges(false) {} … … 1028 1053 /// Construct a directed graph writer, which writes to the given 1029 1054 /// output file. 1030 GraphWriter(const G raph& graph, const std::string& fn)1055 GraphWriter(const GR& graph, const std::string& fn) 1031 1056 : _os(new std::ofstream(fn.c_str())), local_os(true), _graph(graph), 1032 1057 _skip_nodes(false), _skip_edges(false) { … … 1041 1066 /// Construct a directed graph writer, which writes to the given 1042 1067 /// output file. 1043 GraphWriter(const G raph& graph, const char* fn)1068 GraphWriter(const GR& graph, const char* fn) 1044 1069 : _os(new std::ofstream(fn)), local_os(true), _graph(graph), 1045 1070 _skip_nodes(false), _skip_edges(false) { … … 1074 1099 private: 1075 1100 1076 template <typename GR> 1077 friend GraphWriter<GR> graphWriter(const GR& graph, 1078 std::ostream& os); 1079 template <typename GR> 1080 friend GraphWriter<GR> graphWriter(const GR& graph, 1081 const std::string& fn); 1082 template <typename GR> 1083 friend GraphWriter<GR> graphWriter(const GR& graph, 1084 const char *fn); 1101 template <typename TGR> 1102 friend GraphWriter<TGR> graphWriter(const TGR& graph, std::ostream& os); 1103 template <typename TGR> 1104 friend GraphWriter<TGR> graphWriter(const TGR& graph, 1105 const std::string& fn); 1106 template <typename TGR> 1107 friend GraphWriter<TGR> graphWriter(const TGR& graph, const char *fn); 1085 1108 1086 1109 GraphWriter(GraphWriter& other) … … 1107 1130 public: 1108 1131 1109 /// \name Writing rules1132 /// \name Writing Rules 1110 1133 /// @{ 1111 1134 … … 1169 1192 checkConcept<concepts::ReadMap<Arc, typename Map::Value>, Map>(); 1170 1193 _writer_bits::MapStorageBase<Edge>* forward_storage = 1171 new _writer_bits::GraphArcMapStorage<G raph, true, Map>(_graph, map);1194 new _writer_bits::GraphArcMapStorage<GR, true, Map>(_graph, map); 1172 1195 _edge_maps.push_back(std::make_pair('+' + caption, forward_storage)); 1173 1196 _writer_bits::MapStorageBase<Edge>* backward_storage = 1174 new _writer_bits::GraphArcMapStorage<G raph, false, Map>(_graph, map);1197 new _writer_bits::GraphArcMapStorage<GR, false, Map>(_graph, map); 1175 1198 _edge_maps.push_back(std::make_pair('-' + caption, backward_storage)); 1176 1199 return *this; … … 1186 1209 checkConcept<concepts::ReadMap<Arc, typename Map::Value>, Map>(); 1187 1210 _writer_bits::MapStorageBase<Edge>* forward_storage = 1188 new _writer_bits::GraphArcMapStorage<G raph, true, Map, Converter>1211 new _writer_bits::GraphArcMapStorage<GR, true, Map, Converter> 1189 1212 (_graph, map, converter); 1190 1213 _edge_maps.push_back(std::make_pair('+' + caption, forward_storage)); 1191 1214 _writer_bits::MapStorageBase<Edge>* backward_storage = 1192 new _writer_bits::GraphArcMapStorage<G raph, false, Map, Converter>1215 new _writer_bits::GraphArcMapStorage<GR, false, Map, Converter> 1193 1216 (_graph, map, converter); 1194 1217 _edge_maps.push_back(std::make_pair('-' + caption, backward_storage)); … … 1248 1271 /// Add an arc writing rule to writer. 1249 1272 GraphWriter& arc(const std::string& caption, const Arc& arc) { 1250 typedef _writer_bits::GraphArcLookUpConverter<G raph> Converter;1273 typedef _writer_bits::GraphArcLookUpConverter<GR> Converter; 1251 1274 Converter converter(_graph, _edge_index); 1252 1275 _writer_bits::ValueStorageBase* storage = … … 1256 1279 } 1257 1280 1258 /// \name Section captions1281 /// \name Section Captions 1259 1282 /// @{ 1260 1283 … … 1283 1306 } 1284 1307 1285 /// \name Skipping section1308 /// \name Skipping Section 1286 1309 /// @{ 1287 1310 … … 1339 1362 1340 1363 if (label == 0) { 1341 IdMap<G raph, Node> id_map(_graph);1342 _writer_bits::MapLess<IdMap<G raph, Node> > id_less(id_map);1364 IdMap<GR, Node> id_map(_graph); 1365 _writer_bits::MapLess<IdMap<GR, Node> > id_less(id_map); 1343 1366 std::sort(nodes.begin(), nodes.end(), id_less); 1344 1367 } else { … … 1424 1447 1425 1448 if (label == 0) { 1426 IdMap<G raph, Edge> id_map(_graph);1427 _writer_bits::MapLess<IdMap<G raph, Edge> > id_less(id_map);1449 IdMap<GR, Edge> id_map(_graph); 1450 _writer_bits::MapLess<IdMap<GR, Edge> > id_less(id_map); 1428 1451 std::sort(edges.begin(), edges.end(), id_less); 1429 1452 } else { … … 1500 1523 public: 1501 1524 1502 /// \name Execution of the writer1525 /// \name Execution of the Writer 1503 1526 /// @{ 1504 1527 … … 1530 1553 }; 1531 1554 1555 /// \ingroup lemon_io 1556 /// 1557 /// \brief Return a \ref GraphWriter class 1558 /// 1559 /// This function just returns a \ref GraphWriter class. 1560 /// 1561 /// With this function a graph can be write to a file or output 1562 /// stream in \ref lgf-format "LGF" format with several maps and 1563 /// attributes. For example, with the following code a weighted 1564 /// matching problem can be written to the standard output, i.e. a 1565 /// graph with a \e weight map on the edges: 1566 /// 1567 ///\code 1568 ///ListGraph graph; 1569 ///ListGraph::EdgeMap<int> weight(graph); 1570 /// // Setting the weight map 1571 ///graphWriter(graph, std::cout). 1572 /// edgeMap("weight", weight). 1573 /// run(); 1574 ///\endcode 1575 /// 1576 /// For a complete documentation, please see the \ref GraphWriter 1577 /// class documentation. 1578 /// \warning Don't forget to put the \ref GraphWriter::run() "run()" 1579 /// to the end of the parameter list. 1580 /// \relates GraphWriter 1581 /// \sa graphWriter(const TGR& graph, const std::string& fn) 1582 /// \sa graphWriter(const TGR& graph, const char* fn) 1583 template <typename TGR> 1584 GraphWriter<TGR> graphWriter(const TGR& graph, std::ostream& os) { 1585 GraphWriter<TGR> tmp(graph, os); 1586 return tmp; 1587 } 1588 1532 1589 /// \brief Return a \ref GraphWriter class 1533 1590 /// 1534 1591 /// This function just returns a \ref GraphWriter class. 1535 1592 /// \relates GraphWriter 1536 template <typename Graph>1537 GraphWriter<Graph> graphWriter(const Graph& graph,1538 std::ostream& os) {1539 GraphWriter< Graph> tmp(graph, os);1593 /// \sa graphWriter(const TGR& graph, std::ostream& os) 1594 template <typename TGR> 1595 GraphWriter<TGR> graphWriter(const TGR& graph, const std::string& fn) { 1596 GraphWriter<TGR> tmp(graph, fn); 1540 1597 return tmp; 1541 1598 } … … 1545 1602 /// This function just returns a \ref GraphWriter class. 1546 1603 /// \relates GraphWriter 1547 template <typename Graph> 1548 GraphWriter<Graph> graphWriter(const Graph& graph, const std::string& fn) { 1549 GraphWriter<Graph> tmp(graph, fn); 1550 return tmp; 1551 } 1552 1553 /// \brief Return a \ref GraphWriter class 1554 /// 1555 /// This function just returns a \ref GraphWriter class. 1556 /// \relates GraphWriter 1557 template <typename Graph> 1558 GraphWriter<Graph> graphWriter(const Graph& graph, const char* fn) { 1559 GraphWriter<Graph> tmp(graph, fn); 1604 /// \sa graphWriter(const TGR& graph, std::ostream& os) 1605 template <typename TGR> 1606 GraphWriter<TGR> graphWriter(const TGR& graph, const char* fn) { 1607 GraphWriter<TGR> tmp(graph, fn); 1560 1608 return tmp; 1561 1609 } … … 1652 1700 public: 1653 1701 1654 /// \name Section writers1702 /// \name Section Writers 1655 1703 /// @{ 1656 1704 … … 1719 1767 1720 1768 1721 /// \name Execution of the writer1769 /// \name Execution of the Writer 1722 1770 /// @{ 1723 1771 … … 1747 1795 }; 1748 1796 1797 /// \ingroup lemon_io 1798 /// 1749 1799 /// \brief Return a \ref SectionWriter class 1750 1800 /// 1751 1801 /// This function just returns a \ref SectionWriter class. 1802 /// 1803 /// Please see SectionWriter documentation about the custom section 1804 /// output. 1805 /// 1752 1806 /// \relates SectionWriter 1807 /// \sa sectionWriter(const std::string& fn) 1808 /// \sa sectionWriter(const char *fn) 1753 1809 inline SectionWriter sectionWriter(std::ostream& os) { 1754 1810 SectionWriter tmp(os); … … 1760 1816 /// This function just returns a \ref SectionWriter class. 1761 1817 /// \relates SectionWriter 1818 /// \sa sectionWriter(std::ostream& os) 1762 1819 inline SectionWriter sectionWriter(const std::string& fn) { 1763 1820 SectionWriter tmp(fn); … … 1769 1826 /// This function just returns a \ref SectionWriter class. 1770 1827 /// \relates SectionWriter 1828 /// \sa sectionWriter(std::ostream& os) 1771 1829 inline SectionWriter sectionWriter(const char* fn) { 1772 1830 SectionWriter tmp(fn); -
lemon/list_graph.h
r313 r664 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 321 321 ///only in the concept class. 322 322 /// 323 ///An important extra feature of this digraph implementation is that324 ///its maps are real \ref concepts::ReferenceMap "reference map"s.325 ///326 323 ///\sa concepts::Digraph 327 324 328 325 class ListDigraph : public ExtendedListDigraphBase { 326 typedef ExtendedListDigraphBase Parent; 327 329 328 private: 330 329 ///ListDigraph is \e not copy constructible. Use copyDigraph() instead. … … 341 340 public: 342 341 343 typedef ExtendedListDigraphBase Parent;344 345 342 /// Constructor 346 343 … … 352 349 353 350 ///Add a new node to the digraph. 354 ///\return the new node.351 ///\return The new node. 355 352 Node addNode() { return Parent::addNode(); } 356 353 … … 359 356 ///Add a new arc to the digraph with source node \c s 360 357 ///and target node \c t. 361 ///\return the new arc.358 ///\return The new arc. 362 359 Arc addArc(const Node& s, const Node& t) { 363 360 return Parent::addArc(s, t); … … 797 794 public: 798 795 799 typedef ListGraphBase Digraph;796 typedef ListGraphBase Graph; 800 797 801 798 class Node; … … 841 838 842 839 public: 843 operator Edge() const { 844 return id != -1 ? edgeFromId(id / 2) : INVALID; 840 operator Edge() const { 841 return id != -1 ? edgeFromId(id / 2) : INVALID; 845 842 } 846 843 … … 1177 1174 ///only in the concept class. 1178 1175 /// 1179 ///An important extra feature of this graph implementation is that1180 ///its maps are real \ref concepts::ReferenceMap "reference map"s.1181 ///1182 1176 ///\sa concepts::Graph 1183 1177 1184 1178 class ListGraph : public ExtendedListGraphBase { 1179 typedef ExtendedListGraphBase Parent; 1180 1185 1181 private: 1186 1182 ///ListGraph is \e not copy constructible. Use copyGraph() instead. … … 1202 1198 ListGraph() {} 1203 1199 1204 typedef ExtendedListGraphBase Parent;1205 1206 1200 typedef Parent::OutArcIt IncEdgeIt; 1207 1201 … … 1209 1203 /// 1210 1204 /// Add a new node to the graph. 1211 /// \return the new node.1205 /// \return The new node. 1212 1206 Node addNode() { return Parent::addNode(); } 1213 1207 … … 1216 1210 /// Add a new edge to the graph with source node \c s 1217 1211 /// and target node \c t. 1218 /// \return the new edge.1212 /// \return The new edge. 1219 1213 Edge addEdge(const Node& s, const Node& t) { 1220 1214 return Parent::addEdge(s, t); -
lemon/maps.h
r314 r664 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 64 64 class NullMap : public MapBase<K, V> { 65 65 public: 66 typedef MapBase<K, V> Parent; 67 typedef typename Parent::Key Key; 68 typedef typename Parent::Value Value; 66 ///\e 67 typedef K Key; 68 ///\e 69 typedef V Value; 69 70 70 71 /// Gives back a default constructed element. … … 103 104 V _value; 104 105 public: 105 typedef MapBase<K, V> Parent; 106 typedef typename Parent::Key Key; 107 typedef typename Parent::Value Value; 106 ///\e 107 typedef K Key; 108 ///\e 109 typedef V Value; 108 110 109 111 /// Default constructor … … 169 171 class ConstMap<K, Const<V, v> > : public MapBase<K, V> { 170 172 public: 171 typedef MapBase<K, V> Parent; 172 typedef typename Parent::Key Key; 173 typedef typename Parent::Value Value; 173 ///\e 174 typedef K Key; 175 ///\e 176 typedef V Value; 174 177 175 178 /// Constructor. … … 203 206 class IdentityMap : public MapBase<T, T> { 204 207 public: 205 typedef MapBase<T, T> Parent; 206 typedef typename Parent::Key Key; 207 typedef typename Parent::Value Value; 208 ///\e 209 typedef T Key; 210 ///\e 211 typedef T Value; 208 212 209 213 /// Gives back the given value without any modification. … … 246 250 public: 247 251 248 typedef MapBase<int, V> Parent;249 252 /// Key type 250 typedef typename Parent::KeyKey;253 typedef int Key; 251 254 /// Value type 252 typedef typename Parent::ValueValue;255 typedef V Value; 253 256 /// Reference type 254 257 typedef typename Vector::reference Reference; … … 354 357 /// The simplest way of using this map is through the sparseMap() 355 358 /// function. 356 template <typename K, typename V, typename Comp are= std::less<K> >359 template <typename K, typename V, typename Comp = std::less<K> > 357 360 class SparseMap : public MapBase<K, V> { 358 361 template <typename K1, typename V1, typename C1> … … 360 363 public: 361 364 362 typedef MapBase<K, V> Parent;363 365 /// Key type 364 typedef typename Parent::KeyKey;366 typedef K Key; 365 367 /// Value type 366 typedef typename Parent::ValueValue;368 typedef V Value; 367 369 /// Reference type 368 370 typedef Value& Reference; … … 374 376 private: 375 377 376 typedef std::map<K, V, Comp are> Map;378 typedef std::map<K, V, Comp> Map; 377 379 Map _map; 378 380 Value _value; … … 490 492 const M2 &_m2; 491 493 public: 492 typedef MapBase<typename M2::Key, typename M1::Value> Parent; 493 typedef typename Parent::Key Key; 494 typedef typename Parent::Value Value; 494 ///\e 495 typedef typename M2::Key Key; 496 ///\e 497 typedef typename M1::Value Value; 495 498 496 499 /// Constructor 497 500 ComposeMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {} 498 501 499 /// 502 ///\e 500 503 typename MapTraits<M1>::ConstReturnValue 501 504 operator[](const Key &k) const { return _m1[_m2[k]]; } … … 546 549 F _f; 547 550 public: 548 typedef MapBase<typename M1::Key, V> Parent; 549 typedef typename Parent::Key Key; 550 typedef typename Parent::Value Value; 551 ///\e 552 typedef typename M1::Key Key; 553 ///\e 554 typedef V Value; 551 555 552 556 /// Constructor 553 557 CombineMap(const M1 &m1, const M2 &m2, const F &f = F()) 554 558 : _m1(m1), _m2(m2), _f(f) {} 555 /// 559 ///\e 556 560 Value operator[](const Key &k) const { return _f(_m1[k],_m2[k]); } 557 561 }; … … 616 620 F _f; 617 621 public: 618 typedef MapBase<K, V> Parent; 619 typedef typename Parent::Key Key; 620 typedef typename Parent::Value Value; 622 ///\e 623 typedef K Key; 624 ///\e 625 typedef V Value; 621 626 622 627 /// Constructor 623 628 FunctorToMap(const F &f = F()) : _f(f) {} 624 /// 629 ///\e 625 630 Value operator[](const Key &k) const { return _f(k); } 626 631 }; … … 670 675 const M &_m; 671 676 public: 672 typedef MapBase<typename M::Key, typename M::Value> Parent; 673 typedef typename Parent::Key Key; 674 typedef typename Parent::Value Value; 675 676 typedef typename Parent::Key argument_type; 677 typedef typename Parent::Value result_type; 677 ///\e 678 typedef typename M::Key Key; 679 ///\e 680 typedef typename M::Value Value; 681 682 typedef typename M::Key argument_type; 683 typedef typename M::Value result_type; 678 684 679 685 /// Constructor 680 686 MapToFunctor(const M &m) : _m(m) {} 681 /// 687 ///\e 682 688 Value operator()(const Key &k) const { return _m[k]; } 683 /// 689 ///\e 684 690 Value operator[](const Key &k) const { return _m[k]; } 685 691 }; … … 710 716 const M &_m; 711 717 public: 712 typedef MapBase<typename M::Key, V> Parent; 713 typedef typename Parent::Key Key; 714 typedef typename Parent::Value Value; 718 ///\e 719 typedef typename M::Key Key; 720 ///\e 721 typedef V Value; 715 722 716 723 /// Constructor … … 720 727 ConvertMap(const M &m) : _m(m) {} 721 728 722 /// 729 ///\e 723 730 Value operator[](const Key &k) const { return _m[k]; } 724 731 }; … … 752 759 M2 &_m2; 753 760 public: 754 typedef MapBase<typename M1::Key, typename M1::Value> Parent; 755 typedef typename Parent::Key Key; 756 typedef typename Parent::Value Value; 761 ///\e 762 typedef typename M1::Key Key; 763 ///\e 764 typedef typename M1::Value Value; 757 765 758 766 /// Constructor … … 798 806 const M2 &_m2; 799 807 public: 800 typedef MapBase<typename M1::Key, typename M1::Value> Parent; 801 typedef typename Parent::Key Key; 802 typedef typename Parent::Value Value; 808 ///\e 809 typedef typename M1::Key Key; 810 ///\e 811 typedef typename M1::Value Value; 803 812 804 813 /// Constructor 805 814 AddMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {} 806 /// 815 ///\e 807 816 Value operator[](const Key &k) const { return _m1[k]+_m2[k]; } 808 817 }; … … 846 855 const M2 &_m2; 847 856 public: 848 typedef MapBase<typename M1::Key, typename M1::Value> Parent; 849 typedef typename Parent::Key Key; 850 typedef typename Parent::Value Value; 857 ///\e 858 typedef typename M1::Key Key; 859 ///\e 860 typedef typename M1::Value Value; 851 861 852 862 /// Constructor 853 863 SubMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {} 854 /// 864 ///\e 855 865 Value operator[](const Key &k) const { return _m1[k]-_m2[k]; } 856 866 }; … … 895 905 const M2 &_m2; 896 906 public: 897 typedef MapBase<typename M1::Key, typename M1::Value> Parent; 898 typedef typename Parent::Key Key; 899 typedef typename Parent::Value Value; 907 ///\e 908 typedef typename M1::Key Key; 909 ///\e 910 typedef typename M1::Value Value; 900 911 901 912 /// Constructor 902 913 MulMap(const M1 &m1,const M2 &m2) : _m1(m1), _m2(m2) {} 903 /// 914 ///\e 904 915 Value operator[](const Key &k) const { return _m1[k]*_m2[k]; } 905 916 }; … … 943 954 const M2 &_m2; 944 955 public: 945 typedef MapBase<typename M1::Key, typename M1::Value> Parent; 946 typedef typename Parent::Key Key; 947 typedef typename Parent::Value Value; 956 ///\e 957 typedef typename M1::Key Key; 958 ///\e 959 typedef typename M1::Value Value; 948 960 949 961 /// Constructor 950 962 DivMap(const M1 &m1,const M2 &m2) : _m1(m1), _m2(m2) {} 951 /// 963 ///\e 952 964 Value operator[](const Key &k) const { return _m1[k]/_m2[k]; } 953 965 }; … … 993 1005 C _v; 994 1006 public: 995 typedef MapBase<typename M::Key, typename M::Value> Parent; 996 typedef typename Parent::Key Key; 997 typedef typename Parent::Value Value; 1007 ///\e 1008 typedef typename M::Key Key; 1009 ///\e 1010 typedef typename M::Value Value; 998 1011 999 1012 /// Constructor … … 1003 1016 /// \param v The constant value. 1004 1017 ShiftMap(const M &m, const C &v) : _m(m), _v(v) {} 1005 /// 1018 ///\e 1006 1019 Value operator[](const Key &k) const { return _m[k]+_v; } 1007 1020 }; … … 1023 1036 C _v; 1024 1037 public: 1025 typedef MapBase<typename M::Key, typename M::Value> Parent; 1026 typedef typename Parent::Key Key; 1027 typedef typename Parent::Value Value; 1038 ///\e 1039 typedef typename M::Key Key; 1040 ///\e 1041 typedef typename M::Value Value; 1028 1042 1029 1043 /// Constructor … … 1033 1047 /// \param v The constant value. 1034 1048 ShiftWriteMap(M &m, const C &v) : _m(m), _v(v) {} 1035 /// 1049 ///\e 1036 1050 Value operator[](const Key &k) const { return _m[k]+_v; } 1037 /// 1051 ///\e 1038 1052 void set(const Key &k, const Value &v) { _m.set(k, v-_v); } 1039 1053 }; … … 1094 1108 C _v; 1095 1109 public: 1096 typedef MapBase<typename M::Key, typename M::Value> Parent; 1097 typedef typename Parent::Key Key; 1098 typedef typename Parent::Value Value; 1110 ///\e 1111 typedef typename M::Key Key; 1112 ///\e 1113 typedef typename M::Value Value; 1099 1114 1100 1115 /// Constructor … … 1104 1119 /// \param v The constant value. 1105 1120 ScaleMap(const M &m, const C &v) : _m(m), _v(v) {} 1106 /// 1121 ///\e 1107 1122 Value operator[](const Key &k) const { return _v*_m[k]; } 1108 1123 }; … … 1125 1140 C _v; 1126 1141 public: 1127 typedef MapBase<typename M::Key, typename M::Value> Parent; 1128 typedef typename Parent::Key Key; 1129 typedef typename Parent::Value Value; 1142 ///\e 1143 typedef typename M::Key Key; 1144 ///\e 1145 typedef typename M::Value Value; 1130 1146 1131 1147 /// Constructor … … 1135 1151 /// \param v The constant value. 1136 1152 ScaleWriteMap(M &m, const C &v) : _m(m), _v(v) {} 1137 /// 1153 ///\e 1138 1154 Value operator[](const Key &k) const { return _v*_m[k]; } 1139 /// 1155 ///\e 1140 1156 void set(const Key &k, const Value &v) { _m.set(k, v/_v); } 1141 1157 }; … … 1194 1210 const M& _m; 1195 1211 public: 1196 typedef MapBase<typename M::Key, typename M::Value> Parent; 1197 typedef typename Parent::Key Key; 1198 typedef typename Parent::Value Value; 1212 ///\e 1213 typedef typename M::Key Key; 1214 ///\e 1215 typedef typename M::Value Value; 1199 1216 1200 1217 /// Constructor 1201 1218 NegMap(const M &m) : _m(m) {} 1202 /// 1219 ///\e 1203 1220 Value operator[](const Key &k) const { return -_m[k]; } 1204 1221 }; … … 1229 1246 M &_m; 1230 1247 public: 1231 typedef MapBase<typename M::Key, typename M::Value> Parent; 1232 typedef typename Parent::Key Key; 1233 typedef typename Parent::Value Value; 1248 ///\e 1249 typedef typename M::Key Key; 1250 ///\e 1251 typedef typename M::Value Value; 1234 1252 1235 1253 /// Constructor 1236 1254 NegWriteMap(M &m) : _m(m) {} 1237 /// 1255 ///\e 1238 1256 Value operator[](const Key &k) const { return -_m[k]; } 1239 /// 1257 ///\e 1240 1258 void set(const Key &k, const Value &v) { _m.set(k, -v); } 1241 1259 }; … … 1283 1301 const M &_m; 1284 1302 public: 1285 typedef MapBase<typename M::Key, typename M::Value> Parent; 1286 typedef typename Parent::Key Key; 1287 typedef typename Parent::Value Value; 1303 ///\e 1304 typedef typename M::Key Key; 1305 ///\e 1306 typedef typename M::Value Value; 1288 1307 1289 1308 /// Constructor 1290 1309 AbsMap(const M &m) : _m(m) {} 1291 /// 1310 ///\e 1292 1311 Value operator[](const Key &k) const { 1293 1312 Value tmp = _m[k]; … … 1338 1357 class TrueMap : public MapBase<K, bool> { 1339 1358 public: 1340 typedef MapBase<K, bool> Parent; 1341 typedef typename Parent::Key Key; 1342 typedef typename Parent::Value Value; 1359 ///\e 1360 typedef K Key; 1361 ///\e 1362 typedef bool Value; 1343 1363 1344 1364 /// Gives back \c true. … … 1375 1395 class FalseMap : public MapBase<K, bool> { 1376 1396 public: 1377 typedef MapBase<K, bool> Parent; 1378 typedef typename Parent::Key Key; 1379 typedef typename Parent::Value Value; 1397 ///\e 1398 typedef K Key; 1399 ///\e 1400 typedef bool Value; 1380 1401 1381 1402 /// Gives back \c false. … … 1420 1441 const M2 &_m2; 1421 1442 public: 1422 typedef MapBase<typename M1::Key, bool> Parent; 1423 typedef typename Parent::Key Key; 1424 typedef typename Parent::Value Value; 1443 ///\e 1444 typedef typename M1::Key Key; 1445 ///\e 1446 typedef bool Value; 1425 1447 1426 1448 /// Constructor 1427 1449 AndMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {} 1428 /// 1450 ///\e 1429 1451 Value operator[](const Key &k) const { return _m1[k]&&_m2[k]; } 1430 1452 }; … … 1468 1490 const M2 &_m2; 1469 1491 public: 1470 typedef MapBase<typename M1::Key, bool> Parent; 1471 typedef typename Parent::Key Key; 1472 typedef typename Parent::Value Value; 1492 ///\e 1493 typedef typename M1::Key Key; 1494 ///\e 1495 typedef bool Value; 1473 1496 1474 1497 /// Constructor 1475 1498 OrMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {} 1476 /// 1499 ///\e 1477 1500 Value operator[](const Key &k) const { return _m1[k]||_m2[k]; } 1478 1501 }; … … 1507 1530 const M &_m; 1508 1531 public: 1509 typedef MapBase<typename M::Key, bool> Parent; 1510 typedef typename Parent::Key Key; 1511 typedef typename Parent::Value Value; 1532 ///\e 1533 typedef typename M::Key Key; 1534 ///\e 1535 typedef bool Value; 1512 1536 1513 1537 /// Constructor 1514 1538 NotMap(const M &m) : _m(m) {} 1515 /// 1539 ///\e 1516 1540 Value operator[](const Key &k) const { return !_m[k]; } 1517 1541 }; … … 1533 1557 M &_m; 1534 1558 public: 1535 typedef MapBase<typename M::Key, bool> Parent; 1536 typedef typename Parent::Key Key; 1537 typedef typename Parent::Value Value; 1559 ///\e 1560 typedef typename M::Key Key; 1561 ///\e 1562 typedef bool Value; 1538 1563 1539 1564 /// Constructor 1540 1565 NotWriteMap(M &m) : _m(m) {} 1541 /// 1566 ///\e 1542 1567 Value operator[](const Key &k) const { return !_m[k]; } 1543 /// 1568 ///\e 1544 1569 void set(const Key &k, bool v) { _m.set(k, !v); } 1545 1570 }; … … 1596 1621 const M2 &_m2; 1597 1622 public: 1598 typedef MapBase<typename M1::Key, bool> Parent; 1599 typedef typename Parent::Key Key; 1600 typedef typename Parent::Value Value; 1623 ///\e 1624 typedef typename M1::Key Key; 1625 ///\e 1626 typedef bool Value; 1601 1627 1602 1628 /// Constructor 1603 1629 EqualMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {} 1604 /// 1630 ///\e 1605 1631 Value operator[](const Key &k) const { return _m1[k]==_m2[k]; } 1606 1632 }; … … 1644 1670 const M2 &_m2; 1645 1671 public: 1646 typedef MapBase<typename M1::Key, bool> Parent; 1647 typedef typename Parent::Key Key; 1648 typedef typename Parent::Value Value; 1672 ///\e 1673 typedef typename M1::Key Key; 1674 ///\e 1675 typedef bool Value; 1649 1676 1650 1677 /// Constructor 1651 1678 LessMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {} 1652 /// 1679 ///\e 1653 1680 Value operator[](const Key &k) const { return _m1[k]<_m2[k]; } 1654 1681 }; … … 1706 1733 /// function. 1707 1734 /// 1708 /// \tparam I tThe type of the iterator.1709 /// \tparam K eThe key type of the map. The default value set1735 /// \tparam IT The type of the iterator. 1736 /// \tparam KEY The key type of the map. The default value set 1710 1737 /// according to the iterator type should work in most cases. 1711 1738 /// … … 1713 1740 /// for the elements or the iterator should be an inserter iterator. 1714 1741 #ifdef DOXYGEN 1715 template <typename I t, typename Ke>1742 template <typename IT, typename KEY> 1716 1743 #else 1717 template <typename I t,1718 typename K e=typename _maps_bits::IteratorTraits<It>::Value>1744 template <typename IT, 1745 typename KEY = typename _maps_bits::IteratorTraits<IT>::Value> 1719 1746 #endif 1720 class LoggerBoolMap { 1721 public: 1722 typedef It Iterator; 1723 1724 typedef Ke Key; 1747 class LoggerBoolMap : public MapBase<KEY, bool> { 1748 public: 1749 1750 ///\e 1751 typedef KEY Key; 1752 ///\e 1725 1753 typedef bool Value; 1754 ///\e 1755 typedef IT Iterator; 1726 1756 1727 1757 /// Constructor … … 1786 1816 /// @{ 1787 1817 1788 /// Provides an immutable and unique id for each item in the graph. 1789 1790 /// The IdMap class provides a unique and immutable id for each item of the 1791 /// same type (e.g. node) in the graph. This id is <ul><li>\b unique: 1792 /// different items (nodes) get different ids <li>\b immutable: the id of an 1793 /// item (node) does not change (even if you delete other nodes). </ul> 1794 /// Through this map you get access (i.e. can read) the inner id values of 1795 /// the items stored in the graph. This map can be inverted with its member 1818 /// \brief Provides an immutable and unique id for each item in a graph. 1819 /// 1820 /// IdMap provides a unique and immutable id for each item of the 1821 /// same type (\c Node, \c Arc or \c Edge) in a graph. This id is 1822 /// - \b unique: different items get different ids, 1823 /// - \b immutable: the id of an item does not change (even if you 1824 /// delete other nodes). 1825 /// 1826 /// Using this map you get access (i.e. can read) the inner id values of 1827 /// the items stored in the graph, which is returned by the \c id() 1828 /// function of the graph. This map can be inverted with its member 1796 1829 /// class \c InverseMap or with the \c operator() member. 1797 1830 /// 1798 template <typename _Graph, typename _Item> 1799 class IdMap { 1800 public: 1801 typedef _Graph Graph; 1831 /// \tparam GR The graph type. 1832 /// \tparam K The key type of the map (\c GR::Node, \c GR::Arc or 1833 /// \c GR::Edge). 1834 /// 1835 /// \see RangeIdMap 1836 template <typename GR, typename K> 1837 class IdMap : public MapBase<K, int> { 1838 public: 1839 /// The graph type of IdMap. 1840 typedef GR Graph; 1841 typedef GR Digraph; 1842 /// The key type of IdMap (\c Node, \c Arc or \c Edge). 1843 typedef K Item; 1844 /// The key type of IdMap (\c Node, \c Arc or \c Edge). 1845 typedef K Key; 1846 /// The value type of IdMap. 1802 1847 typedef int Value; 1803 typedef _Item Item;1804 typedef _Item Key;1805 1848 1806 1849 /// \brief Constructor. … … 1814 1857 int operator[](const Item& item) const { return _graph->id(item);} 1815 1858 1816 /// \brief Gives back the item by its id.1817 /// 1818 /// Gives back the item by its id.1859 /// \brief Gives back the \e item by its id. 1860 /// 1861 /// Gives back the \e item by its id. 1819 1862 Item operator()(int id) { return _graph->fromId(id, Item()); } 1820 1863 … … 1824 1867 public: 1825 1868 1826 /// \brief Th eclass represents the inverse of its owner (IdMap).1827 /// 1828 /// Th eclass represents the inverse of its owner (IdMap).1869 /// \brief This class represents the inverse of its owner (IdMap). 1870 /// 1871 /// This class represents the inverse of its owner (IdMap). 1829 1872 /// \see inverse() 1830 1873 class InverseMap { … … 1844 1887 /// 1845 1888 /// Gives back the given item from its id. 1846 ///1847 1889 Item operator[](int id) const { return _graph->fromId(id, Item());} 1848 1890 … … 1855 1897 /// Gives back the inverse of the IdMap. 1856 1898 InverseMap inverse() const { return InverseMap(*_graph);} 1857 1858 }; 1859 1860 1861 /// \brief General invertable graph-map type. 1862 1863 /// This type provides simple invertable graph-maps. 1864 /// The InvertableMap wraps an arbitrary ReadWriteMap 1899 }; 1900 1901 1902 /// \brief General cross reference graph map type. 1903 1904 /// This class provides simple invertable graph maps. 1905 /// It wraps an arbitrary \ref concepts::ReadWriteMap "ReadWriteMap" 1865 1906 /// and if a key is set to a new value then store it 1866 1907 /// in the inverse map. … … 1869 1910 /// with stl compatible forward iterator. 1870 1911 /// 1871 /// \tparam _Graph The graph type. 1872 /// \tparam _Item The item type of the graph. 1873 /// \tparam _Value The value type of the map. 1912 /// \tparam GR The graph type. 1913 /// \tparam K The key type of the map (\c GR::Node, \c GR::Arc or 1914 /// \c GR::Edge). 1915 /// \tparam V The value type of the map. 1874 1916 /// 1875 1917 /// \see IterableValueMap 1876 template <typename _Graph, typename _Item, typename _Value>1877 class InvertableMap1878 : protected ItemSetTraits< _Graph, _Item>::template Map<_Value>::Type {1918 template <typename GR, typename K, typename V> 1919 class CrossRefMap 1920 : protected ItemSetTraits<GR, K>::template Map<V>::Type { 1879 1921 private: 1880 1922 1881 typedef typename ItemSetTraits<_Graph, _Item>:: 1882 template Map<_Value>::Type Map; 1883 typedef _Graph Graph; 1884 1885 typedef std::map<_Value, _Item> Container; 1923 typedef typename ItemSetTraits<GR, K>:: 1924 template Map<V>::Type Map; 1925 1926 typedef std::map<V, K> Container; 1886 1927 Container _inv_map; 1887 1928 1888 1929 public: 1889 1930 1890 /// The key type of InvertableMap (Node, Arc, Edge). 1891 typedef typename Map::Key Key; 1892 /// The value type of the InvertableMap. 1893 typedef typename Map::Value Value; 1931 /// The graph type of CrossRefMap. 1932 typedef GR Graph; 1933 typedef GR Digraph; 1934 /// The key type of CrossRefMap (\c Node, \c Arc or \c Edge). 1935 typedef K Item; 1936 /// The key type of CrossRefMap (\c Node, \c Arc or \c Edge). 1937 typedef K Key; 1938 /// The value type of CrossRefMap. 1939 typedef V Value; 1894 1940 1895 1941 /// \brief Constructor. 1896 1942 /// 1897 /// Construct a new InvertableMap for the graph. 1898 /// 1899 explicit InvertableMap(const Graph& graph) : Map(graph) {} 1943 /// Construct a new CrossRefMap for the given graph. 1944 explicit CrossRefMap(const Graph& graph) : Map(graph) {} 1900 1945 1901 1946 /// \brief Forward iterator for values. … … 1903 1948 /// This iterator is an stl compatible forward 1904 1949 /// iterator on the values of the map. The values can 1905 /// be accessed in the [beginValue, endValue) range. 1906 /// 1950 /// be accessed in the <tt>[beginValue, endValue)</tt> range. 1907 1951 class ValueIterator 1908 1952 : public std::iterator<std::forward_iterator_tag, Value> { 1909 friend class InvertableMap;1953 friend class CrossRefMap; 1910 1954 private: 1911 1955 ValueIterator(typename Container::const_iterator _it) … … 1936 1980 /// Returns an stl compatible iterator to the 1937 1981 /// first value of the map. The values of the 1938 /// map can be accessed in the [beginValue, endValue)1982 /// map can be accessed in the <tt>[beginValue, endValue)</tt> 1939 1983 /// range. 1940 1984 ValueIterator beginValue() const { … … 1946 1990 /// Returns an stl compatible iterator after the 1947 1991 /// last value of the map. The values of the 1948 /// map can be accessed in the [beginValue, endValue)1992 /// map can be accessed in the <tt>[beginValue, endValue)</tt> 1949 1993 /// range. 1950 1994 ValueIterator endValue() const { … … 1952 1996 } 1953 1997 1954 /// \brief The setter function of the map.1955 /// 1956 /// Sets the mapped value.1998 /// \brief Sets the value associated with the given key. 1999 /// 2000 /// Sets the value associated with the given key. 1957 2001 void set(const Key& key, const Value& val) { 1958 2002 Value oldval = Map::operator[](key); … … 1965 2009 } 1966 2010 1967 /// \brief The getter function of the map.1968 /// 1969 /// It gives back the value associated with thekey.2011 /// \brief Returns the value associated with the given key. 2012 /// 2013 /// Returns the value associated with the given key. 1970 2014 typename MapTraits<Map>::ConstReturnValue 1971 2015 operator[](const Key& key) const { … … 1983 2027 protected: 1984 2028 1985 /// \brief Erase the key from the map .1986 /// 1987 /// Erase the key to the map. It is called by the2029 /// \brief Erase the key from the map and the inverse map. 2030 /// 2031 /// Erase the key from the map and the inverse map. It is called by the 1988 2032 /// \c AlterationNotifier. 1989 2033 virtual void erase(const Key& key) { … … 1996 2040 } 1997 2041 1998 /// \brief Erase more keys from the map .1999 /// 2000 /// Erase more keys from the map . It is called by the2042 /// \brief Erase more keys from the map and the inverse map. 2043 /// 2044 /// Erase more keys from the map and the inverse map. It is called by the 2001 2045 /// \c AlterationNotifier. 2002 2046 virtual void erase(const std::vector<Key>& keys) { … … 2011 2055 } 2012 2056 2013 /// \brief Clear the keys from the map and inverse map.2014 /// 2015 /// Clear the keys from the map and inverse map. It is called by the2057 /// \brief Clear the keys from the map and the inverse map. 2058 /// 2059 /// Clear the keys from the map and the inverse map. It is called by the 2016 2060 /// \c AlterationNotifier. 2017 2061 virtual void clear() { … … 2025 2069 /// 2026 2070 /// The inverse of this map. The subscript operator of the map 2027 /// gives back always the item what was last assigned to the value.2071 /// gives back the item that was last assigned to the value. 2028 2072 class InverseMap { 2029 2073 public: 2030 /// \brief Constructor of the InverseMap.2074 /// \brief Constructor 2031 2075 /// 2032 2076 /// Constructor of the InverseMap. 2033 explicit InverseMap(const InvertableMap& inverted)2077 explicit InverseMap(const CrossRefMap& inverted) 2034 2078 : _inverted(inverted) {} 2035 2079 2036 2080 /// The value type of the InverseMap. 2037 typedef typename InvertableMap::Key Value;2081 typedef typename CrossRefMap::Key Value; 2038 2082 /// The key type of the InverseMap. 2039 typedef typename InvertableMap::Value Key;2083 typedef typename CrossRefMap::Value Key; 2040 2084 2041 2085 /// \brief Subscript operator. 2042 2086 /// 2043 /// Subscript operator. It gives back alwaysthe item2044 /// what was last assigned to thevalue.2087 /// Subscript operator. It gives back the item 2088 /// that was last assigned to the given value. 2045 2089 Value operator[](const Key& key) const { 2046 2090 return _inverted(key); … … 2048 2092 2049 2093 private: 2050 const InvertableMap& _inverted;2094 const CrossRefMap& _inverted; 2051 2095 }; 2052 2096 2053 /// \brief It gives back the just readableinverse map.2054 /// 2055 /// It gives back the just readableinverse map.2097 /// \brief It gives back the read-only inverse map. 2098 /// 2099 /// It gives back the read-only inverse map. 2056 2100 InverseMap inverse() const { 2057 2101 return InverseMap(*this); … … 2060 2104 }; 2061 2105 2062 /// \brief Provides a mutable, continuous and unique descriptor for each 2063 /// item in the graph. 2064 /// 2065 /// The DescriptorMap class provides a unique and continuous (but mutable) 2066 /// descriptor (id) for each item of the same type (e.g. node) in the 2067 /// graph. This id is <ul><li>\b unique: different items (nodes) get 2068 /// different ids <li>\b continuous: the range of the ids is the set of 2069 /// integers between 0 and \c n-1, where \c n is the number of the items of 2070 /// this type (e.g. nodes) (so the id of a node can change if you delete an 2071 /// other node, i.e. this id is mutable). </ul> This map can be inverted 2072 /// with its member class \c InverseMap, or with the \c operator() member. 2073 /// 2074 /// \tparam _Graph The graph class the \c DescriptorMap belongs to. 2075 /// \tparam _Item The Item is the Key of the Map. It may be Node, Arc or 2076 /// Edge. 2077 template <typename _Graph, typename _Item> 2078 class DescriptorMap 2079 : protected ItemSetTraits<_Graph, _Item>::template Map<int>::Type { 2080 2081 typedef _Item Item; 2082 typedef typename ItemSetTraits<_Graph, _Item>::template Map<int>::Type Map; 2083 2084 public: 2085 /// The graph class of DescriptorMap. 2086 typedef _Graph Graph; 2087 2088 /// The key type of DescriptorMap (Node, Arc, Edge). 2089 typedef typename Map::Key Key; 2090 /// The value type of DescriptorMap. 2091 typedef typename Map::Value Value; 2106 /// \brief Provides continuous and unique ID for the 2107 /// items of a graph. 2108 /// 2109 /// RangeIdMap provides a unique and continuous 2110 /// ID for each item of a given type (\c Node, \c Arc or 2111 /// \c Edge) in a graph. This id is 2112 /// - \b unique: different items get different ids, 2113 /// - \b continuous: the range of the ids is the set of integers 2114 /// between 0 and \c n-1, where \c n is the number of the items of 2115 /// this type (\c Node, \c Arc or \c Edge). 2116 /// - So, the ids can change when deleting an item of the same type. 2117 /// 2118 /// Thus this id is not (necessarily) the same as what can get using 2119 /// the \c id() function of the graph or \ref IdMap. 2120 /// This map can be inverted with its member class \c InverseMap, 2121 /// or with the \c operator() member. 2122 /// 2123 /// \tparam GR The graph type. 2124 /// \tparam K The key type of the map (\c GR::Node, \c GR::Arc or 2125 /// \c GR::Edge). 2126 /// 2127 /// \see IdMap 2128 template <typename GR, typename K> 2129 class RangeIdMap 2130 : protected ItemSetTraits<GR, K>::template Map<int>::Type { 2131 2132 typedef typename ItemSetTraits<GR, K>::template Map<int>::Type Map; 2133 2134 public: 2135 /// The graph type of RangeIdMap. 2136 typedef GR Graph; 2137 typedef GR Digraph; 2138 /// The key type of RangeIdMap (\c Node, \c Arc or \c Edge). 2139 typedef K Item; 2140 /// The key type of RangeIdMap (\c Node, \c Arc or \c Edge). 2141 typedef K Key; 2142 /// The value type of RangeIdMap. 2143 typedef int Value; 2092 2144 2093 2145 /// \brief Constructor. 2094 2146 /// 2095 /// Constructor for descriptor map.2096 explicit DescriptorMap(const Graph& _graph) : Map(_graph) {2147 /// Constructor. 2148 explicit RangeIdMap(const Graph& gr) : Map(gr) { 2097 2149 Item it; 2098 2150 const typename Map::Notifier* nf = Map::notifier(); … … 2105 2157 protected: 2106 2158 2107 /// \brief Add a new key to the map.2159 /// \brief Adds a new key to the map. 2108 2160 /// 2109 2161 /// Add a new key to the map. It is called by the … … 2195 2247 } 2196 2248 2197 /// \brief Gives back the \e descriptor of the item.2198 /// 2199 /// Gives back the mutable and unique \e descriptor of the map.2249 /// \brief Gives back the \e RangeId of the item 2250 /// 2251 /// Gives back the \e RangeId of the item. 2200 2252 int operator[](const Item& item) const { 2201 2253 return Map::operator[](item); 2202 2254 } 2203 2255 2204 /// \brief Gives back the item b y its descriptor.2205 /// 2206 /// Gives back th item by its descriptor.2256 /// \brief Gives back the item belonging to a \e RangeId 2257 /// 2258 /// Gives back the item belonging to a \e RangeId. 2207 2259 Item operator()(int id) const { 2208 2260 return _inv_map[id]; … … 2215 2267 2216 2268 public: 2217 /// \brief The inverse map type of DescriptorMap. 2218 /// 2219 /// The inverse map type of DescriptorMap. 2269 2270 /// \brief The inverse map type of RangeIdMap. 2271 /// 2272 /// The inverse map type of RangeIdMap. 2220 2273 class InverseMap { 2221 2274 public: 2222 /// \brief Constructor of the InverseMap.2275 /// \brief Constructor 2223 2276 /// 2224 2277 /// Constructor of the InverseMap. 2225 explicit InverseMap(const DescriptorMap& inverted)2278 explicit InverseMap(const RangeIdMap& inverted) 2226 2279 : _inverted(inverted) {} 2227 2280 2228 2281 2229 2282 /// The value type of the InverseMap. 2230 typedef typename DescriptorMap::Key Value;2283 typedef typename RangeIdMap::Key Value; 2231 2284 /// The key type of the InverseMap. 2232 typedef typename DescriptorMap::Value Key;2285 typedef typename RangeIdMap::Value Key; 2233 2286 2234 2287 /// \brief Subscript operator. 2235 2288 /// 2236 2289 /// Subscript operator. It gives back the item 2237 /// that the descriptor belongs to currently.2290 /// that the descriptor currently belongs to. 2238 2291 Value operator[](const Key& key) const { 2239 2292 return _inverted(key); … … 2248 2301 2249 2302 private: 2250 const DescriptorMap& _inverted;2303 const RangeIdMap& _inverted; 2251 2304 }; 2252 2305 … … 2259 2312 }; 2260 2313 2261 /// \brief Returns the source of the given arc. 2262 /// 2263 /// The SourceMap gives back the source Node of the given arc. 2314 /// \brief Map of the source nodes of arcs in a digraph. 2315 /// 2316 /// SourceMap provides access for the source node of each arc in a digraph, 2317 /// which is returned by the \c source() function of the digraph. 2318 /// \tparam GR The digraph type. 2264 2319 /// \see TargetMap 2265 template <typename Digraph>2320 template <typename GR> 2266 2321 class SourceMap { 2267 2322 public: 2268 2323 2269 typedef typename Digraph::Node Value; 2270 typedef typename Digraph::Arc Key; 2324 ///\e 2325 typedef typename GR::Arc Key; 2326 ///\e 2327 typedef typename GR::Node Value; 2271 2328 2272 2329 /// \brief Constructor 2273 2330 /// 2274 /// Constructor 2331 /// Constructor. 2275 2332 /// \param digraph The digraph that the map belongs to. 2276 explicit SourceMap(const Digraph& digraph) : _digraph(digraph) {} 2277 2278 /// \brief The subscript operator. 2279 /// 2280 /// The subscript operator. 2281 /// \param arc The arc 2282 /// \return The source of the arc 2333 explicit SourceMap(const GR& digraph) : _graph(digraph) {} 2334 2335 /// \brief Returns the source node of the given arc. 2336 /// 2337 /// Returns the source node of the given arc. 2283 2338 Value operator[](const Key& arc) const { 2284 return _ digraph.source(arc);2339 return _graph.source(arc); 2285 2340 } 2286 2341 2287 2342 private: 2288 const Digraph& _digraph;2343 const GR& _graph; 2289 2344 }; 2290 2345 … … 2293 2348 /// This function just returns an \c SourceMap class. 2294 2349 /// \relates SourceMap 2295 template <typename Digraph> 2296 inline SourceMap<Digraph> sourceMap(const Digraph& digraph) { 2297 return SourceMap<Digraph>(digraph); 2298 } 2299 2300 /// \brief Returns the target of the given arc. 2301 /// 2302 /// The TargetMap gives back the target Node of the given arc. 2350 template <typename GR> 2351 inline SourceMap<GR> sourceMap(const GR& graph) { 2352 return SourceMap<GR>(graph); 2353 } 2354 2355 /// \brief Map of the target nodes of arcs in a digraph. 2356 /// 2357 /// TargetMap provides access for the target node of each arc in a digraph, 2358 /// which is returned by the \c target() function of the digraph. 2359 /// \tparam GR The digraph type. 2303 2360 /// \see SourceMap 2304 template <typename Digraph>2361 template <typename GR> 2305 2362 class TargetMap { 2306 2363 public: 2307 2364 2308 typedef typename Digraph::Node Value; 2309 typedef typename Digraph::Arc Key; 2365 ///\e 2366 typedef typename GR::Arc Key; 2367 ///\e 2368 typedef typename GR::Node Value; 2310 2369 2311 2370 /// \brief Constructor 2312 2371 /// 2313 /// Constructor 2372 /// Constructor. 2314 2373 /// \param digraph The digraph that the map belongs to. 2315 explicit TargetMap(const Digraph& digraph) : _digraph(digraph) {} 2316 2317 /// \brief The subscript operator. 2318 /// 2319 /// The subscript operator. 2320 /// \param e The arc 2321 /// \return The target of the arc 2374 explicit TargetMap(const GR& digraph) : _graph(digraph) {} 2375 2376 /// \brief Returns the target node of the given arc. 2377 /// 2378 /// Returns the target node of the given arc. 2322 2379 Value operator[](const Key& e) const { 2323 return _ digraph.target(e);2380 return _graph.target(e); 2324 2381 } 2325 2382 2326 2383 private: 2327 const Digraph& _digraph;2384 const GR& _graph; 2328 2385 }; 2329 2386 … … 2332 2389 /// This function just returns a \c TargetMap class. 2333 2390 /// \relates TargetMap 2334 template <typename Digraph> 2335 inline TargetMap<Digraph> targetMap(const Digraph& digraph) { 2336 return TargetMap<Digraph>(digraph); 2337 } 2338 2339 /// \brief Returns the "forward" directed arc view of an edge. 2340 /// 2341 /// Returns the "forward" directed arc view of an edge. 2391 template <typename GR> 2392 inline TargetMap<GR> targetMap(const GR& graph) { 2393 return TargetMap<GR>(graph); 2394 } 2395 2396 /// \brief Map of the "forward" directed arc view of edges in a graph. 2397 /// 2398 /// ForwardMap provides access for the "forward" directed arc view of 2399 /// each edge in a graph, which is returned by the \c direct() function 2400 /// of the graph with \c true parameter. 2401 /// \tparam GR The graph type. 2342 2402 /// \see BackwardMap 2343 template <typename G raph>2403 template <typename GR> 2344 2404 class ForwardMap { 2345 2405 public: 2346 2406 2347 typedef typename G raph::Arc Value;2348 typedef typename G raph::Edge Key;2407 typedef typename GR::Arc Value; 2408 typedef typename GR::Edge Key; 2349 2409 2350 2410 /// \brief Constructor 2351 2411 /// 2352 /// Constructor 2412 /// Constructor. 2353 2413 /// \param graph The graph that the map belongs to. 2354 explicit ForwardMap(const Graph& graph) : _graph(graph) {} 2355 2356 /// \brief The subscript operator. 2357 /// 2358 /// The subscript operator. 2359 /// \param key An edge 2360 /// \return The "forward" directed arc view of edge 2414 explicit ForwardMap(const GR& graph) : _graph(graph) {} 2415 2416 /// \brief Returns the "forward" directed arc view of the given edge. 2417 /// 2418 /// Returns the "forward" directed arc view of the given edge. 2361 2419 Value operator[](const Key& key) const { 2362 2420 return _graph.direct(key, true); … … 2364 2422 2365 2423 private: 2366 const G raph& _graph;2424 const GR& _graph; 2367 2425 }; 2368 2426 … … 2371 2429 /// This function just returns an \c ForwardMap class. 2372 2430 /// \relates ForwardMap 2373 template <typename Graph> 2374 inline ForwardMap<Graph> forwardMap(const Graph& graph) { 2375 return ForwardMap<Graph>(graph); 2376 } 2377 2378 /// \brief Returns the "backward" directed arc view of an edge. 2379 /// 2380 /// Returns the "backward" directed arc view of an edge. 2431 template <typename GR> 2432 inline ForwardMap<GR> forwardMap(const GR& graph) { 2433 return ForwardMap<GR>(graph); 2434 } 2435 2436 /// \brief Map of the "backward" directed arc view of edges in a graph. 2437 /// 2438 /// BackwardMap provides access for the "backward" directed arc view of 2439 /// each edge in a graph, which is returned by the \c direct() function 2440 /// of the graph with \c false parameter. 2441 /// \tparam GR The graph type. 2381 2442 /// \see ForwardMap 2382 template <typename G raph>2443 template <typename GR> 2383 2444 class BackwardMap { 2384 2445 public: 2385 2446 2386 typedef typename G raph::Arc Value;2387 typedef typename G raph::Edge Key;2447 typedef typename GR::Arc Value; 2448 typedef typename GR::Edge Key; 2388 2449 2389 2450 /// \brief Constructor 2390 2451 /// 2391 /// Constructor 2452 /// Constructor. 2392 2453 /// \param graph The graph that the map belongs to. 2393 explicit BackwardMap(const Graph& graph) : _graph(graph) {} 2394 2395 /// \brief The subscript operator. 2396 /// 2397 /// The subscript operator. 2398 /// \param key An edge 2399 /// \return The "backward" directed arc view of edge 2454 explicit BackwardMap(const GR& graph) : _graph(graph) {} 2455 2456 /// \brief Returns the "backward" directed arc view of the given edge. 2457 /// 2458 /// Returns the "backward" directed arc view of the given edge. 2400 2459 Value operator[](const Key& key) const { 2401 2460 return _graph.direct(key, false); … … 2403 2462 2404 2463 private: 2405 const G raph& _graph;2464 const GR& _graph; 2406 2465 }; 2407 2466 … … 2410 2469 /// This function just returns a \c BackwardMap class. 2411 2470 /// \relates BackwardMap 2412 template <typename Graph> 2413 inline BackwardMap<Graph> backwardMap(const Graph& graph) { 2414 return BackwardMap<Graph>(graph); 2415 } 2416 2417 /// \brief Potential difference map 2418 /// 2419 /// If there is an potential map on the nodes then we 2420 /// can get an arc map as we get the substraction of the 2421 /// values of the target and source. 2422 template <typename Digraph, typename NodeMap> 2423 class PotentialDifferenceMap { 2424 public: 2425 typedef typename Digraph::Arc Key; 2426 typedef typename NodeMap::Value Value; 2427 2428 /// \brief Constructor 2429 /// 2430 /// Contructor of the map 2431 explicit PotentialDifferenceMap(const Digraph& digraph, 2432 const NodeMap& potential) 2433 : _digraph(digraph), _potential(potential) {} 2434 2435 /// \brief Const subscription operator 2436 /// 2437 /// Const subscription operator 2438 Value operator[](const Key& arc) const { 2439 return _potential[_digraph.target(arc)] - 2440 _potential[_digraph.source(arc)]; 2441 } 2442 2443 private: 2444 const Digraph& _digraph; 2445 const NodeMap& _potential; 2446 }; 2447 2448 /// \brief Returns a PotentialDifferenceMap. 2449 /// 2450 /// This function just returns a PotentialDifferenceMap. 2451 /// \relates PotentialDifferenceMap 2452 template <typename Digraph, typename NodeMap> 2453 PotentialDifferenceMap<Digraph, NodeMap> 2454 potentialDifferenceMap(const Digraph& digraph, const NodeMap& potential) { 2455 return PotentialDifferenceMap<Digraph, NodeMap>(digraph, potential); 2456 } 2457 2458 /// \brief Map of the node in-degrees. 2471 template <typename GR> 2472 inline BackwardMap<GR> backwardMap(const GR& graph) { 2473 return BackwardMap<GR>(graph); 2474 } 2475 2476 /// \brief Map of the in-degrees of nodes in a digraph. 2459 2477 /// 2460 2478 /// This map returns the in-degree of a node. Once it is constructed, 2461 /// the degrees are stored in a standard NodeMap, so each query is done2479 /// the degrees are stored in a standard \c NodeMap, so each query is done 2462 2480 /// in constant time. On the other hand, the values are updated automatically 2463 2481 /// whenever the digraph changes. 2464 2482 /// 2465 /// \warning Besides addNode() and addArc(), a digraph structure may provide 2466 /// alternative ways to modify the digraph. The correct behavior of InDegMap 2467 /// is not guarantied if these additional features are used. For example 2468 /// the functions \ref ListDigraph::changeSource() "changeSource()", 2483 /// \warning Besides \c addNode() and \c addArc(), a digraph structure 2484 /// may provide alternative ways to modify the digraph. 2485 /// The correct behavior of InDegMap is not guarantied if these additional 2486 /// features are used. For example the functions 2487 /// \ref ListDigraph::changeSource() "changeSource()", 2469 2488 /// \ref ListDigraph::changeTarget() "changeTarget()" and 2470 2489 /// \ref ListDigraph::reverseArc() "reverseArc()" … … 2472 2491 /// 2473 2492 /// \sa OutDegMap 2474 2475 template <typename _Digraph> 2493 template <typename GR> 2476 2494 class InDegMap 2477 : protected ItemSetTraits< _Digraph, typename _Digraph::Arc>2495 : protected ItemSetTraits<GR, typename GR::Arc> 2478 2496 ::ItemNotifier::ObserverBase { 2479 2497 2480 2498 public: 2481 2482 typedef _Digraph Digraph; 2499 2500 /// The graph type of InDegMap 2501 typedef GR Graph; 2502 typedef GR Digraph; 2503 /// The key type 2504 typedef typename Digraph::Node Key; 2505 /// The value type 2483 2506 typedef int Value; 2484 typedef typename Digraph::Node Key;2485 2507 2486 2508 typedef typename ItemSetTraits<Digraph, typename Digraph::Arc> … … 2524 2546 /// \brief Constructor. 2525 2547 /// 2526 /// Constructor for creating in-degree map.2527 explicit InDegMap(const Digraph& digraph)2528 : _digraph( digraph), _deg(digraph) {2548 /// Constructor for creating an in-degree map. 2549 explicit InDegMap(const Digraph& graph) 2550 : _digraph(graph), _deg(graph) { 2529 2551 Parent::attach(_digraph.notifier(typename Digraph::Arc())); 2530 2552 … … 2534 2556 } 2535 2557 2558 /// \brief Gives back the in-degree of a Node. 2559 /// 2536 2560 /// Gives back the in-degree of a Node. 2537 2561 int operator[](const Key& key) const { … … 2580 2604 }; 2581 2605 2582 /// \brief Map of the node out-degrees.2606 /// \brief Map of the out-degrees of nodes in a digraph. 2583 2607 /// 2584 2608 /// This map returns the out-degree of a node. Once it is constructed, 2585 /// the degrees are stored in a standard NodeMap, so each query is done2609 /// the degrees are stored in a standard \c NodeMap, so each query is done 2586 2610 /// in constant time. On the other hand, the values are updated automatically 2587 2611 /// whenever the digraph changes. 2588 2612 /// 2589 /// \warning Besides addNode() and addArc(), a digraph structure may provide 2590 /// alternative ways to modify the digraph. The correct behavior of OutDegMap 2591 /// is not guarantied if these additional features are used. For example 2592 /// the functions \ref ListDigraph::changeSource() "changeSource()", 2613 /// \warning Besides \c addNode() and \c addArc(), a digraph structure 2614 /// may provide alternative ways to modify the digraph. 2615 /// The correct behavior of OutDegMap is not guarantied if these additional 2616 /// features are used. For example the functions 2617 /// \ref ListDigraph::changeSource() "changeSource()", 2593 2618 /// \ref ListDigraph::changeTarget() "changeTarget()" and 2594 2619 /// \ref ListDigraph::reverseArc() "reverseArc()" … … 2596 2621 /// 2597 2622 /// \sa InDegMap 2598 2599 template <typename _Digraph> 2623 template <typename GR> 2600 2624 class OutDegMap 2601 : protected ItemSetTraits< _Digraph, typename _Digraph::Arc>2625 : protected ItemSetTraits<GR, typename GR::Arc> 2602 2626 ::ItemNotifier::ObserverBase { 2603 2627 2604 2628 public: 2605 2629 2606 typedef _Digraph Digraph; 2630 /// The graph type of OutDegMap 2631 typedef GR Graph; 2632 typedef GR Digraph; 2633 /// The key type 2634 typedef typename Digraph::Node Key; 2635 /// The value type 2607 2636 typedef int Value; 2608 typedef typename Digraph::Node Key;2609 2637 2610 2638 typedef typename ItemSetTraits<Digraph, typename Digraph::Arc> … … 2646 2674 /// \brief Constructor. 2647 2675 /// 2648 /// Constructor for creating out-degree map.2649 explicit OutDegMap(const Digraph& digraph)2650 : _digraph( digraph), _deg(digraph) {2676 /// Constructor for creating an out-degree map. 2677 explicit OutDegMap(const Digraph& graph) 2678 : _digraph(graph), _deg(graph) { 2651 2679 Parent::attach(_digraph.notifier(typename Digraph::Arc())); 2652 2680 … … 2656 2684 } 2657 2685 2686 /// \brief Gives back the out-degree of a Node. 2687 /// 2658 2688 /// Gives back the out-degree of a Node. 2659 2689 int operator[](const Key& key) const { … … 2702 2732 }; 2703 2733 2734 /// \brief Potential difference map 2735 /// 2736 /// PotentialDifferenceMap returns the difference between the potentials of 2737 /// the source and target nodes of each arc in a digraph, i.e. it returns 2738 /// \code 2739 /// potential[gr.target(arc)] - potential[gr.source(arc)]. 2740 /// \endcode 2741 /// \tparam GR The digraph type. 2742 /// \tparam POT A node map storing the potentials. 2743 template <typename GR, typename POT> 2744 class PotentialDifferenceMap { 2745 public: 2746 /// Key type 2747 typedef typename GR::Arc Key; 2748 /// Value type 2749 typedef typename POT::Value Value; 2750 2751 /// \brief Constructor 2752 /// 2753 /// Contructor of the map. 2754 explicit PotentialDifferenceMap(const GR& gr, 2755 const POT& potential) 2756 : _digraph(gr), _potential(potential) {} 2757 2758 /// \brief Returns the potential difference for the given arc. 2759 /// 2760 /// Returns the potential difference for the given arc, i.e. 2761 /// \code 2762 /// potential[gr.target(arc)] - potential[gr.source(arc)]. 2763 /// \endcode 2764 Value operator[](const Key& arc) const { 2765 return _potential[_digraph.target(arc)] - 2766 _potential[_digraph.source(arc)]; 2767 } 2768 2769 private: 2770 const GR& _digraph; 2771 const POT& _potential; 2772 }; 2773 2774 /// \brief Returns a PotentialDifferenceMap. 2775 /// 2776 /// This function just returns a PotentialDifferenceMap. 2777 /// \relates PotentialDifferenceMap 2778 template <typename GR, typename POT> 2779 PotentialDifferenceMap<GR, POT> 2780 potentialDifferenceMap(const GR& gr, const POT& potential) { 2781 return PotentialDifferenceMap<GR, POT>(gr, potential); 2782 } 2783 2704 2784 /// @} 2705 2785 } -
lemon/math.h
r209 r558 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 56 56 const long double SQRT1_2 = 0.7071067811865475244008443621048490L; 57 57 58 ///Check whether the parameter is NaN or not 59 60 ///This function checks whether the parameter is NaN or not. 61 ///Is should be equivalent with std::isnan(), but it is not 62 ///provided by all compilers. 63 inline bool isNaN(double v) 64 { 65 return v!=v; 66 } 58 67 59 68 /// @} -
lemon/path.h
r517 r606 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 41 41 /// 42 42 /// A structure for representing directed path in a digraph. 43 /// \tparam _DigraphThe digraph type in which the path is.43 /// \tparam GR The digraph type in which the path is. 44 44 /// 45 45 /// In a sense, the path can be treated as a list of arcs. The … … 53 53 /// implementation uses two vectors for storing the front and back 54 54 /// insertions. 55 template <typename _Digraph>55 template <typename GR> 56 56 class Path { 57 57 public: 58 58 59 typedef _DigraphDigraph;59 typedef GR Digraph; 60 60 typedef typename Digraph::Arc Arc; 61 61 … … 138 138 /// \brief The nth arc. 139 139 /// 140 /// \pre n is in the [0..length() - 1] range140 /// \pre \c n is in the <tt>[0..length() - 1]</tt> range. 141 141 const Arc& nth(int n) const { 142 142 return n < int(head.size()) ? *(head.rbegin() + n) : … … 146 146 /// \brief Initialize arc iterator to point to the nth arc 147 147 /// 148 /// \pre n is in the [0..length() - 1] range148 /// \pre \c n is in the <tt>[0..length() - 1]</tt> range. 149 149 ArcIt nthIt(int n) const { 150 150 return ArcIt(*this, n); … … 229 229 /// 230 230 /// A structure for representing directed path in a digraph. 231 /// \tparam _DigraphThe digraph type in which the path is.231 /// \tparam GR The digraph type in which the path is. 232 232 /// 233 233 /// In a sense, the path can be treated as a list of arcs. The … … 241 241 /// then the \c Path type because it use just one vector for the 242 242 /// arcs. 243 template <typename _Digraph>243 template <typename GR> 244 244 class SimplePath { 245 245 public: 246 246 247 typedef _DigraphDigraph;247 typedef GR Digraph; 248 248 typedef typename Digraph::Arc Arc; 249 249 … … 330 330 /// \brief The nth arc. 331 331 /// 332 /// \pre n is in the [0..length() - 1] range332 /// \pre \c n is in the <tt>[0..length() - 1]</tt> range. 333 333 const Arc& nth(int n) const { 334 334 return data[n]; … … 393 393 /// 394 394 /// A structure for representing directed path in a digraph. 395 /// \tparam _DigraphThe digraph type in which the path is.395 /// \tparam GR The digraph type in which the path is. 396 396 /// 397 397 /// In a sense, the path can be treated as a list of arcs. The … … 405 405 /// time. The front and back insertion and erasure is O(1) time 406 406 /// and it can be splited and spliced in O(1) time. 407 template <typename _Digraph>407 template <typename GR> 408 408 class ListPath { 409 409 public: 410 410 411 typedef _DigraphDigraph;411 typedef GR Digraph; 412 412 typedef typename Digraph::Arc Arc; 413 413 … … 508 508 /// 509 509 /// This function looks for the nth arc in O(n) time. 510 /// \pre n is in the [0..length() - 1] range510 /// \pre \c n is in the <tt>[0..length() - 1]</tt> range. 511 511 const Arc& nth(int n) const { 512 512 Node *node = first; … … 733 733 /// 734 734 /// A structure for representing directed path in a digraph. 735 /// \tparam _DigraphThe digraph type in which the path is.735 /// \tparam GR The digraph type in which the path is. 736 736 /// 737 737 /// In a sense, the path can be treated as a list of arcs. The … … 747 747 /// it is intented to be 748 748 /// used when you want to store a large number of paths. 749 template <typename _Digraph>749 template <typename GR> 750 750 class StaticPath { 751 751 public: 752 752 753 typedef _DigraphDigraph;753 typedef GR Digraph; 754 754 typedef typename Digraph::Arc Arc; 755 755 … … 834 834 /// \brief The nth arc. 835 835 /// 836 /// \pre n is in the [0..length() - 1] range836 /// \pre \c n is in the <tt>[0..length() - 1]</tt> range. 837 837 const Arc& nth(int n) const { 838 838 return arcs[n]; -
lemon/random.cc
r209 r463 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). -
lemon/random.h
r517 r631 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 531 531 /// @{ 532 532 533 ///\name Initialization534 ///535 /// @{536 537 533 /// \brief Default constructor 538 534 /// … … 608 604 /// function with the <tt>/dev/urandom</tt> file. If it does not success, 609 605 /// it uses the \c seedFromTime(). 610 /// \return Currently always true.606 /// \return Currently always \c true. 611 607 bool seed() { 612 608 #ifndef WIN32 … … 629 625 /// \param file The source file 630 626 /// \param offset The offset, from the file read. 631 /// \return True when the seeding successes.627 /// \return \c true when the seeding successes. 632 628 #ifndef WIN32 633 629 bool seedFromFile(const std::string& file = "/dev/urandom", int offset = 0) … … 650 646 /// current process id and the current time for initialize the 651 647 /// random sequence. 652 /// \return Currently always true.648 /// \return Currently always \c true. 653 649 bool seedFromTime() { 654 650 #ifndef WIN32 … … 664 660 /// @} 665 661 666 ///\name Uniform distributions662 ///\name Uniform Distributions 667 663 /// 668 664 /// @{ … … 680 676 return real<double>(); 681 677 } 682 683 /// @}684 685 ///\name Uniform distributions686 ///687 /// @{688 678 689 679 /// \brief Returns a random real number from the range [0, 1) … … 741 731 return _random_bits::IntConversion<Number, Word>::convert(core); 742 732 } 743 744 /// @}745 733 746 734 unsigned int uinteger() { … … 775 763 /// @} 776 764 777 ///\name Non-uniform distributions 778 /// 779 765 ///\name Non-uniform Distributions 766 /// 780 767 ///@{ 781 768 782 /// \brief Returns a random bool 769 /// \brief Returns a random bool with given probability of true result. 783 770 /// 784 771 /// It returns a random bool with given probability of true result. … … 787 774 } 788 775 789 /// Standard Gaussdistribution790 791 /// Standard Gaussdistribution.776 /// Standard normal (Gauss) distribution 777 778 /// Standard normal (Gauss) distribution. 792 779 /// \note The Cartesian form of the Box-Muller 793 780 /// transformation is used to generate a random normal distribution. … … 802 789 return std::sqrt(-2*std::log(S)/S)*V1; 803 790 } 804 /// Gaussdistribution with given mean and standard deviation805 806 /// Gaussdistribution with given mean and standard deviation.791 /// Normal (Gauss) distribution with given mean and standard deviation 792 793 /// Normal (Gauss) distribution with given mean and standard deviation. 807 794 /// \sa gauss() 808 795 double gauss(double mean,double std_dev) 809 796 { 810 797 return gauss()*std_dev+mean; 798 } 799 800 /// Lognormal distribution 801 802 /// Lognormal distribution. The parameters are the mean and the standard 803 /// deviation of <tt>exp(X)</tt>. 804 /// 805 double lognormal(double n_mean,double n_std_dev) 806 { 807 return std::exp(gauss(n_mean,n_std_dev)); 808 } 809 /// Lognormal distribution 810 811 /// Lognormal distribution. The parameter is an <tt>std::pair</tt> of 812 /// the mean and the standard deviation of <tt>exp(X)</tt>. 813 /// 814 double lognormal(const std::pair<double,double> ¶ms) 815 { 816 return std::exp(gauss(params.first,params.second)); 817 } 818 /// Compute the lognormal parameters from mean and standard deviation 819 820 /// This function computes the lognormal parameters from mean and 821 /// standard deviation. The return value can direcly be passed to 822 /// lognormal(). 823 std::pair<double,double> lognormalParamsFromMD(double mean, 824 double std_dev) 825 { 826 double fr=std_dev/mean; 827 fr*=fr; 828 double lg=std::log(1+fr); 829 return std::pair<double,double>(std::log(mean)-lg/2.0,std::sqrt(lg)); 830 } 831 /// Lognormal distribution with given mean and standard deviation 832 833 /// Lognormal distribution with given mean and standard deviation. 834 /// 835 double lognormalMD(double mean,double std_dev) 836 { 837 return lognormal(lognormalParamsFromMD(mean,std_dev)); 811 838 } 812 839 … … 912 939 ///@} 913 940 914 ///\name Two dimensional distributions 915 /// 916 941 ///\name Two Dimensional Distributions 942 /// 917 943 ///@{ 918 944 … … 931 957 return dim2::Point<double>(V1,V2); 932 958 } 933 /// A kind of two dimensional Gaussdistribution959 /// A kind of two dimensional normal (Gauss) distribution 934 960 935 961 /// This function provides a turning symmetric two-dimensional distribution. -
lemon/smart_graph.h
r313 r664 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 56 56 public: 57 57 58 typedef SmartDigraphBase Graph;58 typedef SmartDigraphBase Digraph; 59 59 60 60 class Node; … … 68 68 69 69 typedef True NodeNumTag; 70 typedef True EdgeNumTag;70 typedef True ArcNumTag; 71 71 72 72 int nodeNum() const { return nodes.size(); } … … 192 192 ///that <b> it does support only limited (only stack-like) 193 193 ///node and arc deletions</b>. 194 ///It conforms to the \ref concepts::Digraph "Digraph concept" with 195 ///an important extra feature that its maps are real \ref 196 ///concepts::ReferenceMap "reference map"s. 194 ///It fully conforms to the \ref concepts::Digraph "Digraph concept". 197 195 /// 198 196 ///\sa concepts::Digraph. 199 197 class SmartDigraph : public ExtendedSmartDigraphBase { 200 public:201 202 198 typedef ExtendedSmartDigraphBase Parent; 203 199 … … 226 222 ///Add a new node to the digraph. 227 223 228 /// \return the new node.229 /// 224 /// Add a new node to the digraph. 225 /// \return The new node. 230 226 Node addNode() { return Parent::addNode(); } 231 227 … … 234 230 ///Add a new arc to the digraph with source node \c s 235 231 ///and target node \c t. 236 ///\return the new arc.232 ///\return The new arc. 237 233 Arc addArc(const Node& s, const Node& t) { 238 234 return Parent::addArc(s, t); … … 306 302 nodes[b._id].first_out=nodes[n._id].first_out; 307 303 nodes[n._id].first_out=-1; 308 for(int i=nodes[b._id].first_out;i!=-1;i++) arcs[i].source=b._id; 304 for(int i=nodes[b._id].first_out; i!=-1; i=arcs[i].next_out) { 305 arcs[i].source=b._id; 306 } 309 307 if(connect) addArc(n,b); 310 308 return b; … … 421 419 public: 422 420 423 typedef SmartGraphBase Digraph;421 typedef SmartGraphBase Graph; 424 422 425 423 class Node; … … 465 463 466 464 public: 467 operator Edge() const { 468 return _id != -1 ? edgeFromId(_id / 2) : INVALID; 465 operator Edge() const { 466 return _id != -1 ? edgeFromId(_id / 2) : INVALID; 469 467 } 470 468 … … 481 479 : nodes(), arcs() {} 482 480 481 typedef True NodeNumTag; 482 typedef True EdgeNumTag; 483 typedef True ArcNumTag; 484 485 int nodeNum() const { return nodes.size(); } 486 int edgeNum() const { return arcs.size() / 2; } 487 int arcNum() const { return arcs.size(); } 483 488 484 489 int maxNodeId() const { return nodes.size()-1; } … … 621 626 /// that <b> it does support only limited (only stack-like) 622 627 /// node and arc deletions</b>. 623 /// Except from this it conforms to 624 /// the \ref concepts::Graph "Graph concept". 625 /// 626 /// It also has an 627 /// important extra feature that 628 /// its maps are real \ref concepts::ReferenceMap "reference map"s. 628 /// It fully conforms to the \ref concepts::Graph "Graph concept". 629 629 /// 630 630 /// \sa concepts::Graph. 631 ///632 631 class SmartGraph : public ExtendedSmartGraphBase { 632 typedef ExtendedSmartGraphBase Parent; 633 633 634 private: 634 635 … … 648 649 public: 649 650 650 typedef ExtendedSmartGraphBase Parent;651 652 651 /// Constructor 653 652 … … 658 657 ///Add a new node to the graph. 659 658 660 /// \return the new node.661 /// 659 /// Add a new node to the graph. 660 /// \return The new node. 662 661 Node addNode() { return Parent::addNode(); } 663 662 … … 666 665 ///Add a new edge to the graph with node \c s 667 666 ///and \c t. 668 ///\return the new edge.667 ///\return The new edge. 669 668 Edge addEdge(const Node& s, const Node& t) { 670 669 return Parent::addEdge(s, t); … … 729 728 dir.push_back(arcFromId(n-1)); 730 729 Parent::notifier(Arc()).erase(dir); 731 nodes[arcs[n ].target].first_out=arcs[n].next_out;732 nodes[arcs[n -1].target].first_out=arcs[n-1].next_out;730 nodes[arcs[n-1].target].first_out=arcs[n].next_out; 731 nodes[arcs[n].target].first_out=arcs[n-1].next_out; 733 732 arcs.pop_back(); 734 733 arcs.pop_back(); -
lemon/time_measure.h
r528 r631 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 288 288 Timer(bool run=true) :_running(run) {_reset();} 289 289 290 ///\name Control the state of the timer290 ///\name Control the State of the Timer 291 291 ///Basically a Timer can be either running or stopped, 292 292 ///but it provides a bit finer control on the execution. … … 396 396 ///@} 397 397 398 ///\name Query Functions for the ellapsed time398 ///\name Query Functions for the Ellapsed Time 399 399 400 400 ///@{ -
lemon/tolerance.h
r516 r564 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). -
lemon/unionfind.h
r460 r606 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 52 52 /// \pre You need to add all the elements by the \ref insert() 53 53 /// method. 54 template <typename _ItemIntMap>54 template <typename IM> 55 55 class UnionFind { 56 56 public: 57 57 58 typedef _ItemIntMap ItemIntMap; 58 ///\e 59 typedef IM ItemIntMap; 60 ///\e 59 61 typedef typename ItemIntMap::Key Item; 60 62 … … 171 173 /// method. 172 174 /// 173 template <typename _ItemIntMap>175 template <typename IM> 174 176 class UnionFindEnum { 175 177 public: 176 178 177 typedef _ItemIntMap ItemIntMap; 179 ///\e 180 typedef IM ItemIntMap; 181 ///\e 178 182 typedef typename ItemIntMap::Key Item; 179 183 … … 628 632 /// \pre You need to add all the elements by the \ref insert() 629 633 /// method. 630 template <typename _ItemIntMap>634 template <typename IM> 631 635 class ExtendFindEnum { 632 636 public: 633 637 634 typedef _ItemIntMap ItemIntMap; 638 ///\e 639 typedef IM ItemIntMap; 640 ///\e 635 641 typedef typename ItemIntMap::Key Item; 636 642 … … 949 955 /// \pre You need to add all the elements by the \ref insert() 950 956 /// method. 951 /// 952 template <typename _Value, typename _ItemIntMap, 953 typename _Comp = std::less<_Value> > 957 template <typename V, typename IM, typename Comp = std::less<V> > 954 958 class HeapUnionFind { 955 959 public: 956 960 957 typedef _Value Value; 958 typedef typename _ItemIntMap::Key Item; 959 960 typedef _ItemIntMap ItemIntMap; 961 962 typedef _Comp Comp; 961 ///\e 962 typedef V Value; 963 ///\e 964 typedef typename IM::Key Item; 965 ///\e 966 typedef IM ItemIntMap; 967 ///\e 968 typedef Comp Compare; 963 969 964 970 private: … … 1190 1196 popLeft(nodes[jd].next); 1191 1197 pushRight(jd, ld); 1192 if (less(ld, nodes[jd].left) || 1198 if (less(ld, nodes[jd].left) || 1193 1199 nodes[ld].item == nodes[pd].item) { 1194 1200 nodes[jd].item = nodes[ld].item; … … 1602 1608 /// \brief Gives back the priority of the current item. 1603 1609 /// 1604 /// \returnGives back the priority of the current item.1610 /// Gives back the priority of the current item. 1605 1611 const Value& operator[](const Item& item) const { 1606 1612 return nodes[index[item]].prio; … … 1647 1653 /// \brief Gives back the minimum priority of the class. 1648 1654 /// 1649 /// \returnGives back the minimum priority of the class.1655 /// Gives back the minimum priority of the class. 1650 1656 const Value& classPrio(int cls) const { 1651 1657 return nodes[~(classes[cls].parent)].prio; … … 1661 1667 /// \brief Gives back a representant item of the class. 1662 1668 /// 1669 /// Gives back a representant item of the class. 1663 1670 /// The representant is indpendent from the priorities of the 1664 1671 /// items. 1665 /// \return Gives back a representant item of the class.1666 1672 const Item& classRep(int id) const { 1667 1673 int parent = classes[id].parent; -
m4/lx_check_cplex.m4
r187 r674 62 62 63 63 if test x"$lx_cplex_found" = x"yes"; then 64 AC_DEFINE([HAVE_CPLEX], [1], [Define to 1 if you have CPLEX.]) 64 AC_DEFINE([LEMON_HAVE_CPLEX], [1], [Define to 1 if you have CPLEX.]) 65 lx_lp_found=yes 66 AC_DEFINE([LEMON_HAVE_LP], [1], [Define to 1 if you have any LP solver.]) 67 lx_mip_found=yes 68 AC_DEFINE([LEMON_HAVE_MIP], [1], [Define to 1 if you have any MIP solver.]) 65 69 AC_MSG_RESULT([yes]) 66 70 else -
m4/lx_check_glpk.m4
r187 r674 43 43 } 44 44 45 #if (GLP_MAJOR_VERSION < 4) \ 46 || (GLP_MAJOR_VERSION == 4 && GLP_MINOR_VERSION < 33) 47 #error Supported GLPK versions: 4.33 or above 48 #endif 49 45 50 int main(int argc, char** argv) 46 51 { … … 60 65 61 66 if test x"$lx_glpk_found" = x"yes"; then 62 AC_DEFINE([HAVE_GLPK], [1], [Define to 1 if you have GLPK.]) 67 AC_DEFINE([LEMON_HAVE_GLPK], [1], [Define to 1 if you have GLPK.]) 68 lx_lp_found=yes 69 AC_DEFINE([LEMON_HAVE_LP], [1], [Define to 1 if you have any LP solver.]) 70 lx_mip_found=yes 71 AC_DEFINE([LEMON_HAVE_MIP], [1], [Define to 1 if you have any MIP solver.]) 63 72 AC_MSG_RESULT([yes]) 64 73 else -
m4/lx_check_soplex.m4
r187 r674 21 21 SOPLEX_CXXFLAGS="-I$with_soplex_includedir" 22 22 elif test x"$with_soplex" != x"yes"; then 23 SOPLEX_CXXFLAGS="-I$with_soplex/ include"23 SOPLEX_CXXFLAGS="-I$with_soplex/src" 24 24 fi 25 25 … … 39 39 40 40 lx_soplex_test_prog=' 41 #include <soplex /soplex.h>41 #include <soplex.h> 42 42 43 43 int main(int argc, char** argv) … … 56 56 57 57 if test x"$lx_soplex_found" = x"yes"; then 58 AC_DEFINE([HAVE_SOPLEX], [1], [Define to 1 if you have SOPLEX.]) 58 AC_DEFINE([LEMON_HAVE_SOPLEX], [1], [Define to 1 if you have SOPLEX.]) 59 lx_lp_found=yes 60 AC_DEFINE([LEMON_HAVE_LP], [1], [Define to 1 if you have any LP solver.]) 59 61 AC_MSG_RESULT([yes]) 60 62 else -
scripts/chg-len.py
r284 r439 2 2 3 3 import sys 4 import os 4 5 from mercurial import ui, hg 6 from mercurial import util 7 8 util.rcpath = lambda : [] 5 9 6 10 if len(sys.argv)>1 and sys.argv[1] in ["-h","--help"]: … … 10 14 """ 11 15 exit(0) 12 plist = os.popen("HGRCPATH='' hg parents --template='{rev}\n'").readlines()13 if len(plist)>1:14 print "You are in the process of merging"15 exit(1)16 PAR = int(plist[0])17 16 18 f = os.popen("HGRCPATH='' hg log -r 0:tip --template='{rev} {parents}\n'").\ 19 readlines() 20 REV = -1 21 lengths=[] 22 for l in f: 23 REV+=1 24 s = l.split() 25 rev = int(s[0]) 26 if REV != rev: 27 print "Something is seriously wrong" 28 exit(1) 29 if len(s) == 1: 30 par1 = par2 = rev - 1 31 elif len(s) == 2: 32 par1 = par2 = int(s[1].split(":")[0]) 17 u = ui.ui() 18 r = hg.repository(u, ".") 19 N = r.changectx(".").rev() 20 lengths=[0]*(N+1) 21 for i in range(N+1): 22 p=r.changectx(i).parents() 23 if p[0]: 24 p0=lengths[p[0].rev()] 33 25 else: 34 par1 = int(s[1].split(":")[0]) 35 par2 = int(s[2].split(":")[0]) 36 if rev == 0: 37 lengths.append(0) 26 p0=-1 27 if len(p)>1 and p[1]: 28 p1=lengths[p[1].rev()] 38 29 else: 39 lengths.append(max(lengths[par1],lengths[par2])+1) 40 print lengths[PAR] 30 p1=-1 31 lengths[i]=max(p0,p1)+1 32 print lengths[N] -
scripts/mk-release.sh
r536 r611 15 15 16 16 autoreconf -vif 17 ./configure --enable-demo17 ./configure 18 18 19 19 make -
scripts/unify-sources.sh
r538 r675 7 7 if [ -n "$(hg st $1)" ]; then 8 8 echo $YEAR 9 else 10 hg log -l 1 --template='{date|isodate}\n' $1 | 11 cut -d '-' -f 1 12 fi 13 } 14 15 function update_header() { 9 } 10 11 # file enumaration modes 12 13 function all_files() { 14 hg status -a -m -c | 15 cut -d ' ' -f 2 | grep -E '(\.(cc|h|dox)$|Makefile\.am$)' | 16 while read file; do echo $HGROOT/$file; done 17 } 18 19 function modified_files() { 20 hg status -a -m | 21 cut -d ' ' -f 2 | grep -E '(\.(cc|h|dox)$|Makefile\.am$)' | 22 while read file; do echo $HGROOT/$file; done 23 } 24 25 function changed_files() { 26 { 27 if [ -n "$HG_PARENT1" ] 28 then 29 hg status --rev $HG_PARENT1:$HG_NODE -a -m 30 fi 31 if [ -n "$HG_PARENT2" ] 32 then 33 hg status --rev $HG_PARENT2:$HG_NODE -a -m 34 fi 35 } | cut -d ' ' -f 2 | grep -E '(\.(cc|h|dox)$|Makefile\.am$)' | 36 sort | uniq | 37 while read file; do echo $HGROOT/$file; done 38 } 39 40 function given_files() { 41 for file in $GIVEN_FILES 42 do 43 echo $file 44 done 45 } 46 47 # actions 48 49 function update_action() { 50 if ! diff -q $1 $2 >/dev/null 51 then 52 echo -n " [$3 updated]" 53 rm $2 54 mv $1 $2 55 CHANGED=YES 56 fi 57 } 58 59 function update_warning() { 60 echo -n " [$2 warning]" 61 WARNED=YES 62 } 63 64 function update_init() { 65 echo Update source files... 66 TOTAL_FILES=0 67 CHANGED_FILES=0 68 WARNED_FILES=0 69 } 70 71 function update_done() { 72 echo $CHANGED_FILES out of $TOTAL_FILES files has been changed. 73 echo $WARNED_FILES out of $TOTAL_FILES files triggered warnings. 74 } 75 76 function update_begin() { 77 ((TOTAL_FILES++)) 78 CHANGED=NO 79 WARNED=NO 80 } 81 82 function update_end() { 83 if [ $CHANGED == YES ] 84 then 85 ((++CHANGED_FILES)) 86 fi 87 if [ $WARNED == YES ] 88 then 89 ((++WARNED_FILES)) 90 fi 91 } 92 93 function check_action() { 94 if [ "$3" == 'tabs' ] 95 then 96 if echo $2 | grep -q -v -E 'Makefile\.am$' 97 then 98 PATTERN=$(echo -e '\t') 99 else 100 PATTERN=' ' 101 fi 102 elif [ "$3" == 'trailing spaces' ] 103 then 104 PATTERN='\ +$' 105 else 106 PATTERN='*' 107 fi 108 109 if ! diff -q $1 $2 >/dev/null 110 then 111 if [ "$PATTERN" == '*' ] 112 then 113 diff $1 $2 | grep '^[0-9]' | sed "s|^\(.*\)c.*$|$2:\1: check failed: $3|g" | 114 sed "s/:\([0-9]*\),\([0-9]*\):\(.*\)$/:\1:\3 (until line \2)/g" 115 else 116 grep -n -E "$PATTERN" $2 | sed "s|^\([0-9]*\):.*$|$2:\1: check failed: $3|g" 117 fi 118 FAILED=YES 119 fi 120 } 121 122 function check_warning() { 123 if [ "$2" == 'long lines' ] 124 then 125 grep -n -E '.{81,}' $1 | sed "s|^\([0-9]*\):.*$|$1:\1: warning: $2|g" 126 else 127 echo "$1: warning: $2" 128 fi 129 WARNED=YES 130 } 131 132 function check_init() { 133 echo Check source files... 134 FAILED_FILES=0 135 WARNED_FILES=0 136 TOTAL_FILES=0 137 } 138 139 function check_done() { 140 echo $FAILED_FILES out of $TOTAL_FILES files has been failed. 141 echo $WARNED_FILES out of $TOTAL_FILES files triggered warnings. 142 143 if [ $WARNED_FILES -gt 0 -o $FAILED_FILES -gt 0 ] 144 then 145 if [ "$WARNING" == 'INTERACTIVE' ] 146 then 147 echo -n "Are the files with errors/warnings acceptable? (yes/no) " 148 while read answer 149 do 150 if [ "$answer" == 'yes' ] 151 then 152 return 0 153 elif [ "$answer" == 'no' ] 154 then 155 return 1 156 fi 157 echo -n "Are the files with errors/warnings acceptable? (yes/no) " 158 done 159 elif [ "$WARNING" == 'WERROR' ] 160 then 161 return 1 162 fi 163 fi 164 } 165 166 function check_begin() { 167 ((TOTAL_FILES++)) 168 FAILED=NO 169 WARNED=NO 170 } 171 172 function check_end() { 173 if [ $FAILED == YES ] 174 then 175 ((++FAILED_FILES)) 176 fi 177 if [ $WARNED == YES ] 178 then 179 ((++WARNED_FILES)) 180 fi 181 } 182 183 184 185 # checks 186 187 function header_check() { 188 if echo $1 | grep -q -E 'Makefile\.am$' 189 then 190 return 191 fi 192 16 193 TMP_FILE=`mktemp` 17 FILE_NAME=$118 194 19 195 (echo "/* -*- mode: C++; indent-tabs-mode: nil; -*- … … 35 211 */ 36 212 " 37 213 awk 'BEGIN { pm=0; } 38 214 pm==3 { print } 39 215 /\/\* / && pm==0 { pm=1;} … … 41 217 /\*\// && pm==1 { pm=2;} 42 218 ' $1 43 ) >$TMP_FILE 44 45 HEADER_CH=`diff -q $TMP_FILE $FILE_NAME >/dev/null&&echo NO||echo YES` 46 47 rm $FILE_NAME 48 mv $TMP_FILE $FILE_NAME 49 } 50 51 function update_tabs() { 219 ) >$TMP_FILE 220 221 "$ACTION"_action "$TMP_FILE" "$1" header 222 } 223 224 function tabs_check() { 225 if echo $1 | grep -q -v -E 'Makefile\.am$' 226 then 227 OLD_PATTERN=$(echo -e '\t') 228 NEW_PATTERN=' ' 229 else 230 OLD_PATTERN=' ' 231 NEW_PATTERN=$(echo -e '\t') 232 fi 52 233 TMP_FILE=`mktemp` 53 FILE_NAME=$1 54 55 cat $1 | 56 sed -e 's/\t/ /g' >$TMP_FILE 57 58 TABS_CH=`diff -q $TMP_FILE $FILE_NAME >/dev/null&&echo NO||echo YES` 59 60 rm $FILE_NAME 61 mv $TMP_FILE $FILE_NAME 62 } 63 64 function remove_trailing_space() { 234 cat $1 | sed -e "s/$OLD_PATTERN/$NEW_PATTERN/g" >$TMP_FILE 235 236 "$ACTION"_action "$TMP_FILE" "$1" 'tabs' 237 } 238 239 function spaces_check() { 65 240 TMP_FILE=`mktemp` 66 FILE_NAME=$1 67 68 cat $1 | 69 sed -e 's/ \+$//g' >$TMP_FILE 70 71 SPACES_CH=`diff -q $TMP_FILE $FILE_NAME >/dev/null&&echo NO||echo YES` 72 73 rm $FILE_NAME 74 mv $TMP_FILE $FILE_NAME 75 } 76 77 function long_line_test() { 78 cat $1 |grep -q -E '.{81,}' 79 } 80 81 function update_file() { 82 echo -n ' update' $i ... 83 84 update_header $1 85 update_tabs $1 86 remove_trailing_space $1 87 88 CHANGED=NO; 89 if [[ $HEADER_CH = YES ]]; 90 then 91 echo -n ' [header updated]' 92 CHANGED=YES; 93 fi 94 if [[ $TABS_CH = YES ]]; 95 then 96 echo -n ' [tabs removed]' 97 CHANGED=YES; 98 fi 99 if [[ $SPACES_CH = YES ]]; 100 then 101 echo -n ' [trailing spaces removed]' 102 CHANGED=YES; 103 fi 104 if long_line_test $1 ; 105 then 106 echo -n ' [LONG LINES]' 107 ((LONG_LINE_FILES++)) 108 fi 109 echo 110 if [[ $CHANGED = YES ]]; 111 then 112 ((CHANGED_FILES++)) 113 fi 114 } 115 116 CHANGED_FILES=0 117 TOTAL_FILES=0 118 LONG_LINE_FILES=0 119 if [ $# == 0 ]; then 120 echo Update all source files... 121 for i in `hg manifest|grep -E '\.(cc|h|dox)$'` 241 cat $1 | sed -e 's/ \+$//g' >$TMP_FILE 242 243 "$ACTION"_action "$TMP_FILE" "$1" 'trailing spaces' 244 } 245 246 function long_lines_check() { 247 if cat $1 | grep -q -E '.{81,}' 248 then 249 "$ACTION"_warning $1 'long lines' 250 fi 251 } 252 253 # process the file 254 255 function process_file() { 256 if [ "$ACTION" == 'update' ] 257 then 258 echo -n " $ACTION $1..." 259 else 260 echo " $ACTION $1..." 261 fi 262 263 CHECKING="header tabs spaces long_lines" 264 265 "$ACTION"_begin $1 266 for check in $CHECKING 122 267 do 123 update_file $HGROOT/$i 124 ((TOTAL_FILES++)) 268 "$check"_check $1 125 269 done 126 echo ' done.' 127 else 128 for i in $* 270 "$ACTION"_end $1 271 if [ "$ACTION" == 'update' ] 272 then 273 echo 274 fi 275 } 276 277 function process_all { 278 "$ACTION"_init 279 while read file 129 280 do 130 update_file $i 131 ((TOTAL_FILES++)) 132 done 281 process_file $file 282 done < <($FILES) 283 "$ACTION"_done 284 } 285 286 while [ $# -gt 0 ] 287 do 288 289 if [ "$1" == '--help' ] || [ "$1" == '-h' ] 290 then 291 echo -n \ 292 "Usage: 293 $0 [OPTIONS] [files] 294 Options: 295 --dry-run|-n 296 Check the files, but do not modify them. 297 --interactive|-i 298 If --dry-run is specified and the checker emits warnings, 299 then the user is asked if the warnings should be considered 300 errors. 301 --werror|-w 302 Make all warnings into errors. 303 --all|-a 304 Check all source files in the repository. 305 --modified|-m 306 Check only the modified (and new) source files. This option is 307 useful to check the modification before making a commit. 308 --changed|-c 309 Check only the changed source files compared to the parent(s) of 310 the current hg node. This option is useful as hg hook script. 311 To automatically check all your changes before making a commit, 312 add the following section to the appropriate .hg/hgrc file. 313 314 [hooks] 315 pretxncommit.checksources = scripts/unify-sources.sh -c -n -i 316 317 --help|-h 318 Print this help message. 319 files 320 The files to check/unify. If no file names are given, the modified 321 source files will be checked/unified (just like using the 322 --modified|-m option). 323 " 324 exit 0 325 elif [ "$1" == '--dry-run' ] || [ "$1" == '-n' ] 326 then 327 [ -n "$ACTION" ] && echo "Conflicting action options" >&2 && exit 1 328 ACTION=check 329 elif [ "$1" == "--all" ] || [ "$1" == '-a' ] 330 then 331 [ -n "$FILES" ] && echo "Conflicting target options" >&2 && exit 1 332 FILES=all_files 333 elif [ "$1" == "--changed" ] || [ "$1" == '-c' ] 334 then 335 [ -n "$FILES" ] && echo "Conflicting target options" >&2 && exit 1 336 FILES=changed_files 337 elif [ "$1" == "--modified" ] || [ "$1" == '-m' ] 338 then 339 [ -n "$FILES" ] && echo "Conflicting target options" >&2 && exit 1 340 FILES=modified_files 341 elif [ "$1" == "--interactive" ] || [ "$1" == "-i" ] 342 then 343 [ -n "$WARNING" ] && echo "Conflicting warning options" >&2 && exit 1 344 WARNING='INTERACTIVE' 345 elif [ "$1" == "--werror" ] || [ "$1" == "-w" ] 346 then 347 [ -n "$WARNING" ] && echo "Conflicting warning options" >&2 && exit 1 348 WARNING='WERROR' 349 elif [ $(echo x$1 | cut -c 2) == '-' ] 350 then 351 echo "Invalid option $1" >&2 && exit 1 352 else 353 [ -n "$FILES" ] && echo "Invalid option $1" >&2 && exit 1 354 GIVEN_FILES=$@ 355 FILES=given_files 356 break 357 fi 358 359 shift 360 done 361 362 if [ -z $FILES ] 363 then 364 FILES=modified_files 133 365 fi 134 echo $CHANGED_FILES out of $TOTAL_FILES files has been changed. 135 if [[ $LONG_LINE_FILES -gt 1 ]]; then 136 echo 137 echo WARNING: $LONG_LINE_FILES files contains long lines! 138 echo 139 elif [[ $LONG_LINE_FILES -gt 0 ]]; then 140 echo 141 echo WARNING: a file contains long lines! 142 echo 366 367 if [ -z $ACTION ] 368 then 369 ACTION=update 143 370 fi 371 372 process_all -
test/CMakeLists.txt
r225 r674 1 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}) 1 INCLUDE_DIRECTORIES( 2 ${PROJECT_SOURCE_DIR} 3 ${PROJECT_BINARY_DIR} 4 ) 2 5 3 LINK_DIRECTORIES(${ CMAKE_BINARY_DIR}/lemon)6 LINK_DIRECTORIES(${PROJECT_BINARY_DIR}/lemon) 4 7 5 8 SET(TESTS 9 adaptors_test 6 10 bfs_test 11 circulation_test 7 12 counter_test 8 13 dfs_test … … 10 15 dijkstra_test 11 16 dim_test 17 edge_set_test 12 18 error_test 19 euler_test 20 gomory_hu_test 13 21 graph_copy_test 14 22 graph_test 15 23 graph_utils_test 24 hao_orlin_test 16 25 heap_test 17 26 kruskal_test 18 27 maps_test 28 matching_test 29 min_cost_arborescence_test 30 min_cost_flow_test 31 path_test 32 preflow_test 33 radix_sort_test 19 34 random_test 20 path_test35 suurballe_test 21 36 time_measure_test 22 37 unionfind_test) 38 39 IF(LEMON_HAVE_LP) 40 ADD_EXECUTABLE(lp_test lp_test.cc) 41 SET(LP_TEST_LIBS lemon) 42 IF(LEMON_HAVE_GLPK) 43 SET(LP_TEST_LIBS ${LP_TEST_LIBS} ${GLPK_LIBRARIES}) 44 ENDIF(LEMON_HAVE_GLPK) 45 IF(LEMON_HAVE_CPLEX) 46 SET(LP_TEST_LIBS ${LP_TEST_LIBS} ${CPLEX_LIBRARIES}) 47 ENDIF(LEMON_HAVE_CPLEX) 48 IF(LEMON_HAVE_CLP) 49 SET(LP_TEST_LIBS ${LP_TEST_LIBS} ${COIN_CLP_LIBRARIES}) 50 ENDIF(LEMON_HAVE_CLP) 51 TARGET_LINK_LIBRARIES(lp_test ${LP_TEST_LIBS}) 52 ADD_TEST(lp_test lp_test) 53 54 IF(WIN32 AND LEMON_HAVE_GLPK) 55 GET_TARGET_PROPERTY(TARGET_LOC lp_test LOCATION) 56 GET_FILENAME_COMPONENT(TARGET_PATH ${TARGET_LOC} PATH) 57 ADD_CUSTOM_COMMAND(TARGET lp_test POST_BUILD 58 COMMAND cmake -E copy ${GLPK_BIN_DIR}/glpk.dll ${TARGET_PATH} 59 COMMAND cmake -E copy ${GLPK_BIN_DIR}/libltdl3.dll ${TARGET_PATH} 60 COMMAND cmake -E copy ${GLPK_BIN_DIR}/zlib1.dll ${TARGET_PATH} 61 ) 62 ENDIF(WIN32 AND LEMON_HAVE_GLPK) 63 IF(WIN32 AND LEMON_HAVE_CPLEX) 64 GET_TARGET_PROPERTY(TARGET_LOC lp_test LOCATION) 65 GET_FILENAME_COMPONENT(TARGET_PATH ${TARGET_LOC} PATH) 66 ADD_CUSTOM_COMMAND(TARGET lp_test POST_BUILD 67 COMMAND cmake -E copy ${CPLEX_BIN_DIR}/cplex91.dll ${TARGET_PATH} 68 ) 69 ENDIF(WIN32 AND LEMON_HAVE_CPLEX) 70 ENDIF(LEMON_HAVE_LP) 71 72 IF(LEMON_HAVE_MIP) 73 ADD_EXECUTABLE(mip_test mip_test.cc) 74 SET(MIP_TEST_LIBS lemon) 75 IF(LEMON_HAVE_GLPK) 76 SET(MIP_TEST_LIBS ${MIP_TEST_LIBS} ${GLPK_LIBRARIES}) 77 ENDIF(LEMON_HAVE_GLPK) 78 IF(LEMON_HAVE_CPLEX) 79 SET(MIP_TEST_LIBS ${MIP_TEST_LIBS} ${CPLEX_LIBRARIES}) 80 ENDIF(LEMON_HAVE_CPLEX) 81 IF(LEMON_HAVE_CBC) 82 SET(MIP_TEST_LIBS ${MIP_TEST_LIBS} ${COIN_CBC_LIBRARIES}) 83 ENDIF(LEMON_HAVE_CBC) 84 TARGET_LINK_LIBRARIES(mip_test ${MIP_TEST_LIBS}) 85 ADD_TEST(mip_test mip_test) 86 87 IF(WIN32 AND LEMON_HAVE_GLPK) 88 GET_TARGET_PROPERTY(TARGET_LOC mip_test LOCATION) 89 GET_FILENAME_COMPONENT(TARGET_PATH ${TARGET_LOC} PATH) 90 ADD_CUSTOM_COMMAND(TARGET mip_test POST_BUILD 91 COMMAND cmake -E copy ${GLPK_BIN_DIR}/glpk.dll ${TARGET_PATH} 92 COMMAND cmake -E copy ${GLPK_BIN_DIR}/libltdl3.dll ${TARGET_PATH} 93 COMMAND cmake -E copy ${GLPK_BIN_DIR}/zlib1.dll ${TARGET_PATH} 94 ) 95 ENDIF(WIN32 AND LEMON_HAVE_GLPK) 96 IF(WIN32 AND LEMON_HAVE_CPLEX) 97 GET_TARGET_PROPERTY(TARGET_LOC mip_test LOCATION) 98 GET_FILENAME_COMPONENT(TARGET_PATH ${TARGET_LOC} PATH) 99 ADD_CUSTOM_COMMAND(TARGET mip_test POST_BUILD 100 COMMAND cmake -E copy ${CPLEX_BIN_DIR}/cplex91.dll ${TARGET_PATH} 101 ) 102 ENDIF(WIN32 AND LEMON_HAVE_CPLEX) 103 ENDIF(LEMON_HAVE_MIP) 23 104 24 105 FOREACH(TEST_NAME ${TESTS}) -
test/Makefile.am
r228 r658 4 4 noinst_HEADERS += \ 5 5 test/graph_test.h \ 6 6 test/test_tools.h 7 7 8 8 check_PROGRAMS += \ 9 test/adaptors_test \ 9 10 test/bfs_test \ 10 test/counter_test \ 11 test/circulation_test \ 12 test/counter_test \ 11 13 test/dfs_test \ 12 14 test/digraph_test \ 13 15 test/dijkstra_test \ 14 test/dim_test \ 16 test/dim_test \ 17 test/edge_set_test \ 15 18 test/error_test \ 19 test/euler_test \ 20 test/gomory_hu_test \ 16 21 test/graph_copy_test \ 17 22 test/graph_test \ 18 23 test/graph_utils_test \ 24 test/hao_orlin_test \ 19 25 test/heap_test \ 20 26 test/kruskal_test \ 21 test/maps_test \ 22 test/random_test \ 23 test/path_test \ 24 test/test_tools_fail \ 25 test/test_tools_pass \ 26 test/time_measure_test \ 27 test/maps_test \ 28 test/matching_test \ 29 test/min_cost_arborescence_test \ 30 test/min_cost_flow_test \ 31 test/path_test \ 32 test/preflow_test \ 33 test/radix_sort_test \ 34 test/random_test \ 35 test/suurballe_test \ 36 test/test_tools_fail \ 37 test/test_tools_pass \ 38 test/time_measure_test \ 27 39 test/unionfind_test 40 41 test_test_tools_pass_DEPENDENCIES = demo 42 43 if HAVE_LP 44 check_PROGRAMS += test/lp_test 45 endif HAVE_LP 46 if HAVE_MIP 47 check_PROGRAMS += test/mip_test 48 endif HAVE_MIP 28 49 29 50 TESTS += $(check_PROGRAMS) 30 51 XFAIL_TESTS += test/test_tools_fail$(EXEEXT) 31 52 53 test_adaptors_test_SOURCES = test/adaptors_test.cc 32 54 test_bfs_test_SOURCES = test/bfs_test.cc 55 test_circulation_test_SOURCES = test/circulation_test.cc 33 56 test_counter_test_SOURCES = test/counter_test.cc 34 57 test_dfs_test_SOURCES = test/dfs_test.cc … … 36 59 test_dijkstra_test_SOURCES = test/dijkstra_test.cc 37 60 test_dim_test_SOURCES = test/dim_test.cc 61 test_edge_set_test_SOURCES = test/edge_set_test.cc 38 62 test_error_test_SOURCES = test/error_test.cc 63 test_euler_test_SOURCES = test/euler_test.cc 64 test_gomory_hu_test_SOURCES = test/gomory_hu_test.cc 39 65 test_graph_copy_test_SOURCES = test/graph_copy_test.cc 40 66 test_graph_test_SOURCES = test/graph_test.cc … … 42 68 test_heap_test_SOURCES = test/heap_test.cc 43 69 test_kruskal_test_SOURCES = test/kruskal_test.cc 70 test_hao_orlin_test_SOURCES = test/hao_orlin_test.cc 71 test_lp_test_SOURCES = test/lp_test.cc 44 72 test_maps_test_SOURCES = test/maps_test.cc 73 test_mip_test_SOURCES = test/mip_test.cc 74 test_matching_test_SOURCES = test/matching_test.cc 75 test_min_cost_arborescence_test_SOURCES = test/min_cost_arborescence_test.cc 76 test_min_cost_flow_test_SOURCES = test/min_cost_flow_test.cc 45 77 test_path_test_SOURCES = test/path_test.cc 78 test_preflow_test_SOURCES = test/preflow_test.cc 79 test_radix_sort_test_SOURCES = test/radix_sort_test.cc 80 test_suurballe_test_SOURCES = test/suurballe_test.cc 46 81 test_random_test_SOURCES = test/random_test.cc 47 82 test_test_tools_fail_SOURCES = test/test_tools_fail.cc -
test/bfs_test.cc
r293 r632 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 59 59 60 60 Digraph G; 61 Node s, t ;61 Node s, t, n; 62 62 Arc e; 63 int l ;63 int l, i; 64 64 bool b; 65 65 BType::DistMap d(G); 66 66 BType::PredMap p(G); 67 67 Path<Digraph> pp; 68 concepts::ReadMap<Node,bool> nm; 68 69 69 70 { 70 71 BType bfs_test(G); 72 const BType& const_bfs_test = bfs_test; 71 73 72 74 bfs_test.run(s); … … 74 76 bfs_test.run(); 75 77 76 l = bfs_test.dist(t); 77 e = bfs_test.predArc(t); 78 s = bfs_test.predNode(t); 79 b = bfs_test.reached(t); 80 d = bfs_test.distMap(); 81 p = bfs_test.predMap(); 82 pp = bfs_test.path(t); 78 bfs_test.init(); 79 bfs_test.addSource(s); 80 n = bfs_test.processNextNode(); 81 n = bfs_test.processNextNode(t, b); 82 n = bfs_test.processNextNode(nm, n); 83 n = const_bfs_test.nextNode(); 84 b = const_bfs_test.emptyQueue(); 85 i = const_bfs_test.queueSize(); 86 87 bfs_test.start(); 88 bfs_test.start(t); 89 bfs_test.start(nm); 90 91 l = const_bfs_test.dist(t); 92 e = const_bfs_test.predArc(t); 93 s = const_bfs_test.predNode(t); 94 b = const_bfs_test.reached(t); 95 d = const_bfs_test.distMap(); 96 p = const_bfs_test.predMap(); 97 pp = const_bfs_test.path(t); 83 98 } 84 99 { … … 87 102 ::SetDistMap<concepts::ReadWriteMap<Node,int> > 88 103 ::SetReachedMap<concepts::ReadWriteMap<Node,bool> > 104 ::SetStandardProcessedMap 89 105 ::SetProcessedMap<concepts::WriteMap<Node,bool> > 90 ::SetStandardProcessedMap91 106 ::Create bfs_test(G); 107 108 concepts::ReadWriteMap<Node,Arc> pred_map; 109 concepts::ReadWriteMap<Node,int> dist_map; 110 concepts::ReadWriteMap<Node,bool> reached_map; 111 concepts::WriteMap<Node,bool> processed_map; 112 113 bfs_test 114 .predMap(pred_map) 115 .distMap(dist_map) 116 .reachedMap(reached_map) 117 .processedMap(processed_map); 92 118 93 119 bfs_test.run(s); 94 120 bfs_test.run(s,t); 95 121 bfs_test.run(); 122 123 bfs_test.init(); 124 bfs_test.addSource(s); 125 n = bfs_test.processNextNode(); 126 n = bfs_test.processNextNode(t, b); 127 n = bfs_test.processNextNode(nm, n); 128 n = bfs_test.nextNode(); 129 b = bfs_test.emptyQueue(); 130 i = bfs_test.queueSize(); 131 132 bfs_test.start(); 133 bfs_test.start(t); 134 bfs_test.start(nm); 96 135 97 136 l = bfs_test.dist(t); -
test/counter_test.cc
r209 r605 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 19 19 #include <lemon/counter.h> 20 20 #include <vector> 21 #include <sstream> 22 23 #include "test/test_tools.h" 21 24 22 25 using namespace lemon; … … 24 27 template <typename T> 25 28 void bubbleSort(std::vector<T>& v) { 26 Counter op("Bubble Sort - Operations: "); 27 Counter::NoSubCounter as(op, "Assignments: "); 28 Counter::NoSubCounter co(op, "Comparisons: "); 29 for (int i = v.size()-1; i > 0; --i) { 30 for (int j = 0; j < i; ++j) { 31 if (v[j] > v[j+1]) { 32 T tmp = v[j]; 33 v[j] = v[j+1]; 34 v[j+1] = tmp; 35 as += 3; 29 std::stringstream s1, s2, s3; 30 { 31 Counter op("Bubble Sort - Operations: ", s1); 32 Counter::SubCounter as(op, "Assignments: ", s2); 33 Counter::SubCounter co(op, "Comparisons: ", s3); 34 for (int i = v.size()-1; i > 0; --i) { 35 for (int j = 0; j < i; ++j) { 36 if (v[j] > v[j+1]) { 37 T tmp = v[j]; 38 v[j] = v[j+1]; 39 v[j+1] = tmp; 40 as += 3; 41 } 42 ++co; 36 43 } 37 ++co;38 44 } 39 45 } 46 check(s1.str() == "Bubble Sort - Operations: 102\n", "Wrong counter"); 47 check(s2.str() == "Assignments: 57\n", "Wrong subcounter"); 48 check(s3.str() == "Comparisons: 45\n", "Wrong subcounter"); 40 49 } 41 50 42 51 template <typename T> 43 52 void insertionSort(std::vector<T>& v) { 44 Counter op("Insertion Sort - Operations: "); 45 Counter::NoSubCounter as(op, "Assignments: "); 46 Counter::NoSubCounter co(op, "Comparisons: "); 47 for (int i = 1; i < int(v.size()); ++i) { 48 T value = v[i]; 49 ++as; 50 int j = i; 51 while (j > 0 && v[j-1] > value) { 52 v[j] = v[j-1]; 53 --j; 54 ++co; ++as; 53 std::stringstream s1, s2, s3; 54 { 55 Counter op("Insertion Sort - Operations: ", s1); 56 Counter::SubCounter as(op, "Assignments: ", s2); 57 Counter::SubCounter co(op, "Comparisons: ", s3); 58 for (int i = 1; i < int(v.size()); ++i) { 59 T value = v[i]; 60 ++as; 61 int j = i; 62 while (j > 0 && v[j-1] > value) { 63 v[j] = v[j-1]; 64 --j; 65 ++co; ++as; 66 } 67 v[j] = value; 68 ++as; 55 69 } 56 v[j] = value;57 ++as;58 70 } 71 check(s1.str() == "Insertion Sort - Operations: 56\n", "Wrong counter"); 72 check(s2.str() == "Assignments: 37\n", "Wrong subcounter"); 73 check(s3.str() == "Comparisons: 19\n", "Wrong subcounter"); 59 74 } 60 75 61 76 template <typename MyCounter> 62 void counterTest() { 63 MyCounter c("Main Counter: "); 64 c++; 65 typename MyCounter::SubCounter d(c, "SubCounter: "); 66 d++; 67 typename MyCounter::SubCounter::NoSubCounter e(d, "SubSubCounter: "); 68 e++; 69 d+=3; 70 c-=4; 71 e-=2; 72 c.reset(2); 73 c.reset(); 77 void counterTest(bool output) { 78 std::stringstream s1, s2, s3; 79 { 80 MyCounter c("Main Counter: ", s1); 81 c++; 82 typename MyCounter::SubCounter d(c, "SubCounter: ", s2); 83 d++; 84 typename MyCounter::SubCounter::NoSubCounter e(d, "SubSubCounter: ", s3); 85 e++; 86 d+=3; 87 c-=4; 88 e-=2; 89 c.reset(2); 90 c.reset(); 91 } 92 if (output) { 93 check(s1.str() == "Main Counter: 3\n", "Wrong Counter"); 94 check(s2.str() == "SubCounter: 3\n", "Wrong SubCounter"); 95 check(s3.str() == "", "Wrong NoSubCounter"); 96 } else { 97 check(s1.str() == "", "Wrong NoCounter"); 98 check(s2.str() == "", "Wrong SubCounter"); 99 check(s3.str() == "", "Wrong NoSubCounter"); 100 } 74 101 } 75 102 … … 81 108 int main() 82 109 { 83 counterTest<Counter>( );84 counterTest<NoCounter>( );110 counterTest<Counter>(true); 111 counterTest<NoCounter>(false); 85 112 86 113 std::vector<int> x(10); -
test/dfs_test.cc
r293 r632 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 63 63 Node s, t; 64 64 Arc e; 65 int l ;65 int l, i; 66 66 bool b; 67 67 DType::DistMap d(G); 68 68 DType::PredMap p(G); 69 69 Path<Digraph> pp; 70 concepts::ReadMap<Arc,bool> am; 70 71 71 72 { 72 73 DType dfs_test(G); 74 const DType& const_dfs_test = dfs_test; 73 75 74 76 dfs_test.run(s); … … 76 78 dfs_test.run(); 77 79 78 l = dfs_test.dist(t); 79 e = dfs_test.predArc(t); 80 s = dfs_test.predNode(t); 81 b = dfs_test.reached(t); 82 d = dfs_test.distMap(); 83 p = dfs_test.predMap(); 84 pp = dfs_test.path(t); 80 dfs_test.init(); 81 dfs_test.addSource(s); 82 e = dfs_test.processNextArc(); 83 e = const_dfs_test.nextArc(); 84 b = const_dfs_test.emptyQueue(); 85 i = const_dfs_test.queueSize(); 86 87 dfs_test.start(); 88 dfs_test.start(t); 89 dfs_test.start(am); 90 91 l = const_dfs_test.dist(t); 92 e = const_dfs_test.predArc(t); 93 s = const_dfs_test.predNode(t); 94 b = const_dfs_test.reached(t); 95 d = const_dfs_test.distMap(); 96 p = const_dfs_test.predMap(); 97 pp = const_dfs_test.path(t); 85 98 } 86 99 { … … 89 102 ::SetDistMap<concepts::ReadWriteMap<Node,int> > 90 103 ::SetReachedMap<concepts::ReadWriteMap<Node,bool> > 104 ::SetStandardProcessedMap 91 105 ::SetProcessedMap<concepts::WriteMap<Node,bool> > 92 ::SetStandardProcessedMap93 106 ::Create dfs_test(G); 107 108 concepts::ReadWriteMap<Node,Arc> pred_map; 109 concepts::ReadWriteMap<Node,int> dist_map; 110 concepts::ReadWriteMap<Node,bool> reached_map; 111 concepts::WriteMap<Node,bool> processed_map; 112 113 dfs_test 114 .predMap(pred_map) 115 .distMap(dist_map) 116 .reachedMap(reached_map) 117 .processedMap(processed_map); 94 118 95 119 dfs_test.run(s); 96 120 dfs_test.run(s,t); 97 121 dfs_test.run(); 122 dfs_test.init(); 123 124 dfs_test.addSource(s); 125 e = dfs_test.processNextArc(); 126 e = dfs_test.nextArc(); 127 b = dfs_test.emptyQueue(); 128 i = dfs_test.queueSize(); 129 130 dfs_test.start(); 131 dfs_test.start(t); 132 dfs_test.start(am); 98 133 99 134 l = dfs_test.dist(t); -
test/digraph_test.cc
r228 r463 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 20 20 #include <lemon/list_graph.h> 21 21 #include <lemon/smart_graph.h> 22 //#include <lemon/full_graph.h> 23 //#include <lemon/hypercube_graph.h> 22 #include <lemon/full_graph.h> 24 23 25 24 #include "test_tools.h" … … 30 29 31 30 template <class Digraph> 32 void checkDigraph () {31 void checkDigraphBuild() { 33 32 TEMPLATE_DIGRAPH_TYPEDEFS(Digraph); 34 33 Digraph G; … … 59 58 checkGraphConArcList(G, 1); 60 59 61 Arc a2 = G.addArc(n2, n1), a3 = G.addArc(n2, n3), a4 = G.addArc(n2, n3); 60 Arc a2 = G.addArc(n2, n1), 61 a3 = G.addArc(n2, n3), 62 a4 = G.addArc(n2, n3); 63 62 64 checkGraphNodeList(G, 3); 63 65 checkGraphArcList(G, 4); … … 77 79 checkGraphNodeMap(G); 78 80 checkGraphArcMap(G); 79 80 } 81 81 } 82 83 template <class Digraph> 84 void checkDigraphSplit() { 85 TEMPLATE_DIGRAPH_TYPEDEFS(Digraph); 86 87 Digraph G; 88 Node n1 = G.addNode(), n2 = G.addNode(), n3 = G.addNode(); 89 Arc a1 = G.addArc(n1, n2), a2 = G.addArc(n2, n1), 90 a3 = G.addArc(n2, n3), a4 = G.addArc(n2, n3); 91 92 Node n4 = G.split(n2); 93 94 check(G.target(OutArcIt(G, n2)) == n4 && 95 G.source(InArcIt(G, n4)) == n2, 96 "Wrong split."); 97 98 checkGraphNodeList(G, 4); 99 checkGraphArcList(G, 5); 100 101 checkGraphOutArcList(G, n1, 1); 102 checkGraphOutArcList(G, n2, 1); 103 checkGraphOutArcList(G, n3, 0); 104 checkGraphOutArcList(G, n4, 3); 105 106 checkGraphInArcList(G, n1, 1); 107 checkGraphInArcList(G, n2, 1); 108 checkGraphInArcList(G, n3, 2); 109 checkGraphInArcList(G, n4, 1); 110 111 checkGraphConArcList(G, 5); 112 } 113 114 template <class Digraph> 115 void checkDigraphAlter() { 116 TEMPLATE_DIGRAPH_TYPEDEFS(Digraph); 117 118 Digraph G; 119 Node n1 = G.addNode(), n2 = G.addNode(), 120 n3 = G.addNode(), n4 = G.addNode(); 121 Arc a1 = G.addArc(n1, n2), a2 = G.addArc(n4, n1), 122 a3 = G.addArc(n4, n3), a4 = G.addArc(n4, n3), 123 a5 = G.addArc(n2, n4); 124 125 checkGraphNodeList(G, 4); 126 checkGraphArcList(G, 5); 127 128 // Check changeSource() and changeTarget() 129 G.changeTarget(a4, n1); 130 131 checkGraphNodeList(G, 4); 132 checkGraphArcList(G, 5); 133 134 checkGraphOutArcList(G, n1, 1); 135 checkGraphOutArcList(G, n2, 1); 136 checkGraphOutArcList(G, n3, 0); 137 checkGraphOutArcList(G, n4, 3); 138 139 checkGraphInArcList(G, n1, 2); 140 checkGraphInArcList(G, n2, 1); 141 checkGraphInArcList(G, n3, 1); 142 checkGraphInArcList(G, n4, 1); 143 144 checkGraphConArcList(G, 5); 145 146 G.changeSource(a4, n3); 147 148 checkGraphNodeList(G, 4); 149 checkGraphArcList(G, 5); 150 151 checkGraphOutArcList(G, n1, 1); 152 checkGraphOutArcList(G, n2, 1); 153 checkGraphOutArcList(G, n3, 1); 154 checkGraphOutArcList(G, n4, 2); 155 156 checkGraphInArcList(G, n1, 2); 157 checkGraphInArcList(G, n2, 1); 158 checkGraphInArcList(G, n3, 1); 159 checkGraphInArcList(G, n4, 1); 160 161 checkGraphConArcList(G, 5); 162 163 // Check contract() 164 G.contract(n2, n4, false); 165 166 checkGraphNodeList(G, 3); 167 checkGraphArcList(G, 5); 168 169 checkGraphOutArcList(G, n1, 1); 170 checkGraphOutArcList(G, n2, 3); 171 checkGraphOutArcList(G, n3, 1); 172 173 checkGraphInArcList(G, n1, 2); 174 checkGraphInArcList(G, n2, 2); 175 checkGraphInArcList(G, n3, 1); 176 177 checkGraphConArcList(G, 5); 178 179 G.contract(n2, n1); 180 181 checkGraphNodeList(G, 2); 182 checkGraphArcList(G, 3); 183 184 checkGraphOutArcList(G, n2, 2); 185 checkGraphOutArcList(G, n3, 1); 186 187 checkGraphInArcList(G, n2, 2); 188 checkGraphInArcList(G, n3, 1); 189 190 checkGraphConArcList(G, 3); 191 } 192 193 template <class Digraph> 194 void checkDigraphErase() { 195 TEMPLATE_DIGRAPH_TYPEDEFS(Digraph); 196 197 Digraph G; 198 Node n1 = G.addNode(), n2 = G.addNode(), 199 n3 = G.addNode(), n4 = G.addNode(); 200 Arc a1 = G.addArc(n1, n2), a2 = G.addArc(n4, n1), 201 a3 = G.addArc(n4, n3), a4 = G.addArc(n3, n1), 202 a5 = G.addArc(n2, n4); 203 204 // Check arc deletion 205 G.erase(a1); 206 207 checkGraphNodeList(G, 4); 208 checkGraphArcList(G, 4); 209 210 checkGraphOutArcList(G, n1, 0); 211 checkGraphOutArcList(G, n2, 1); 212 checkGraphOutArcList(G, n3, 1); 213 checkGraphOutArcList(G, n4, 2); 214 215 checkGraphInArcList(G, n1, 2); 216 checkGraphInArcList(G, n2, 0); 217 checkGraphInArcList(G, n3, 1); 218 checkGraphInArcList(G, n4, 1); 219 220 checkGraphConArcList(G, 4); 221 222 // Check node deletion 223 G.erase(n4); 224 225 checkGraphNodeList(G, 3); 226 checkGraphArcList(G, 1); 227 228 checkGraphOutArcList(G, n1, 0); 229 checkGraphOutArcList(G, n2, 0); 230 checkGraphOutArcList(G, n3, 1); 231 checkGraphOutArcList(G, n4, 0); 232 233 checkGraphInArcList(G, n1, 1); 234 checkGraphInArcList(G, n2, 0); 235 checkGraphInArcList(G, n3, 0); 236 checkGraphInArcList(G, n4, 0); 237 238 checkGraphConArcList(G, 1); 239 } 240 241 242 template <class Digraph> 243 void checkDigraphSnapshot() { 244 TEMPLATE_DIGRAPH_TYPEDEFS(Digraph); 245 246 Digraph G; 247 Node n1 = G.addNode(), n2 = G.addNode(), n3 = G.addNode(); 248 Arc a1 = G.addArc(n1, n2), a2 = G.addArc(n2, n1), 249 a3 = G.addArc(n2, n3), a4 = G.addArc(n2, n3); 250 251 typename Digraph::Snapshot snapshot(G); 252 253 Node n = G.addNode(); 254 G.addArc(n3, n); 255 G.addArc(n, n3); 256 257 checkGraphNodeList(G, 4); 258 checkGraphArcList(G, 6); 259 260 snapshot.restore(); 261 262 checkGraphNodeList(G, 3); 263 checkGraphArcList(G, 4); 264 265 checkGraphOutArcList(G, n1, 1); 266 checkGraphOutArcList(G, n2, 3); 267 checkGraphOutArcList(G, n3, 0); 268 269 checkGraphInArcList(G, n1, 1); 270 checkGraphInArcList(G, n2, 1); 271 checkGraphInArcList(G, n3, 2); 272 273 checkGraphConArcList(G, 4); 274 275 checkNodeIds(G); 276 checkArcIds(G); 277 checkGraphNodeMap(G); 278 checkGraphArcMap(G); 279 280 G.addNode(); 281 snapshot.save(G); 282 283 G.addArc(G.addNode(), G.addNode()); 284 285 snapshot.restore(); 286 287 checkGraphNodeList(G, 4); 288 checkGraphArcList(G, 4); 289 } 82 290 83 291 void checkConcepts() { … … 110 318 checkConcept<ClearableDigraphComponent<>, SmartDigraph>(); 111 319 } 112 // { // Checking FullDigraph 113 // checkConcept<Digraph, FullDigraph>(); 114 // } 115 // { // Checking HyperCubeDigraph 116 // checkConcept<Digraph, HyperCubeDigraph>(); 117 // } 320 { // Checking FullDigraph 321 checkConcept<Digraph, FullDigraph>(); 322 } 118 323 } 119 324 … … 168 373 } 169 374 375 void checkFullDigraph(int num) { 376 typedef FullDigraph Digraph; 377 DIGRAPH_TYPEDEFS(Digraph); 378 Digraph G(num); 379 380 checkGraphNodeList(G, num); 381 checkGraphArcList(G, num * num); 382 383 for (NodeIt n(G); n != INVALID; ++n) { 384 checkGraphOutArcList(G, n, num); 385 checkGraphInArcList(G, n, num); 386 } 387 388 checkGraphConArcList(G, num * num); 389 390 checkNodeIds(G); 391 checkArcIds(G); 392 checkGraphNodeMap(G); 393 checkGraphArcMap(G); 394 395 for (int i = 0; i < G.nodeNum(); ++i) { 396 check(G.index(G(i)) == i, "Wrong index"); 397 } 398 399 for (NodeIt s(G); s != INVALID; ++s) { 400 for (NodeIt t(G); t != INVALID; ++t) { 401 Arc a = G.arc(s, t); 402 check(G.source(a) == s && G.target(a) == t, "Wrong arc lookup"); 403 } 404 } 405 } 406 170 407 void checkDigraphs() { 171 408 { // Checking ListDigraph 172 checkDigraph<ListDigraph>(); 409 checkDigraphBuild<ListDigraph>(); 410 checkDigraphSplit<ListDigraph>(); 411 checkDigraphAlter<ListDigraph>(); 412 checkDigraphErase<ListDigraph>(); 413 checkDigraphSnapshot<ListDigraph>(); 173 414 checkDigraphValidityErase<ListDigraph>(); 174 415 } 175 416 { // Checking SmartDigraph 176 checkDigraph<SmartDigraph>(); 417 checkDigraphBuild<SmartDigraph>(); 418 checkDigraphSplit<SmartDigraph>(); 419 checkDigraphSnapshot<SmartDigraph>(); 177 420 checkDigraphValidity<SmartDigraph>(); 421 } 422 { // Checking FullDigraph 423 checkFullDigraph(8); 178 424 } 179 425 } -
test/dijkstra_test.cc
r412 r632 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 61 61 62 62 Digraph G; 63 Node s, t ;63 Node s, t, n; 64 64 Arc e; 65 65 VType l; 66 int i; 66 67 bool b; 67 68 DType::DistMap d(G); … … 69 70 LengthMap length; 70 71 Path<Digraph> pp; 72 concepts::ReadMap<Node,bool> nm; 71 73 72 74 { 73 75 DType dijkstra_test(G,length); 76 const DType& const_dijkstra_test = dijkstra_test; 74 77 75 78 dijkstra_test.run(s); 76 79 dijkstra_test.run(s,t); 80 81 dijkstra_test.init(); 82 dijkstra_test.addSource(s); 83 dijkstra_test.addSource(s, 1); 84 n = dijkstra_test.processNextNode(); 85 n = const_dijkstra_test.nextNode(); 86 b = const_dijkstra_test.emptyQueue(); 87 i = const_dijkstra_test.queueSize(); 88 89 dijkstra_test.start(); 90 dijkstra_test.start(t); 91 dijkstra_test.start(nm); 92 93 l = const_dijkstra_test.dist(t); 94 e = const_dijkstra_test.predArc(t); 95 s = const_dijkstra_test.predNode(t); 96 b = const_dijkstra_test.reached(t); 97 b = const_dijkstra_test.processed(t); 98 d = const_dijkstra_test.distMap(); 99 p = const_dijkstra_test.predMap(); 100 pp = const_dijkstra_test.path(t); 101 l = const_dijkstra_test.currentDist(t); 102 } 103 { 104 DType 105 ::SetPredMap<concepts::ReadWriteMap<Node,Arc> > 106 ::SetDistMap<concepts::ReadWriteMap<Node,VType> > 107 ::SetStandardProcessedMap 108 ::SetProcessedMap<concepts::WriteMap<Node,bool> > 109 ::SetOperationTraits<DijkstraDefaultOperationTraits<VType> > 110 ::SetHeap<BinHeap<VType, concepts::ReadWriteMap<Node,int> > > 111 ::SetStandardHeap<BinHeap<VType, concepts::ReadWriteMap<Node,int> > > 112 ::SetHeap<BinHeap<VType, concepts::ReadWriteMap<Node,int> >, 113 concepts::ReadWriteMap<Node,int> > 114 ::Create dijkstra_test(G,length); 115 116 LengthMap length_map; 117 concepts::ReadWriteMap<Node,Arc> pred_map; 118 concepts::ReadWriteMap<Node,VType> dist_map; 119 concepts::WriteMap<Node,bool> processed_map; 120 concepts::ReadWriteMap<Node,int> heap_cross_ref; 121 BinHeap<VType, concepts::ReadWriteMap<Node,int> > heap(heap_cross_ref); 122 123 dijkstra_test 124 .lengthMap(length_map) 125 .predMap(pred_map) 126 .distMap(dist_map) 127 .processedMap(processed_map) 128 .heap(heap, heap_cross_ref); 129 130 dijkstra_test.run(s); 131 dijkstra_test.run(s,t); 132 133 dijkstra_test.addSource(s); 134 dijkstra_test.addSource(s, 1); 135 n = dijkstra_test.processNextNode(); 136 n = dijkstra_test.nextNode(); 137 b = dijkstra_test.emptyQueue(); 138 i = dijkstra_test.queueSize(); 139 140 dijkstra_test.start(); 141 dijkstra_test.start(t); 142 dijkstra_test.start(nm); 77 143 78 144 l = dijkstra_test.dist(t); … … 80 146 s = dijkstra_test.predNode(t); 81 147 b = dijkstra_test.reached(t); 82 d = dijkstra_test.distMap(); 83 p = dijkstra_test.predMap(); 148 b = dijkstra_test.processed(t); 84 149 pp = dijkstra_test.path(t); 85 } 86 { 87 DType 88 ::SetPredMap<concepts::ReadWriteMap<Node,Arc> > 89 ::SetDistMap<concepts::ReadWriteMap<Node,VType> > 90 ::SetProcessedMap<concepts::WriteMap<Node,bool> > 91 ::SetStandardProcessedMap 92 ::SetOperationTraits<DijkstraDefaultOperationTraits<VType> > 93 ::SetHeap<BinHeap<VType, concepts::ReadWriteMap<Node,int> > > 94 ::SetStandardHeap<BinHeap<VType, concepts::ReadWriteMap<Node,int> > > 95 ::Create dijkstra_test(G,length); 96 97 dijkstra_test.run(s); 98 dijkstra_test.run(s,t); 99 100 l = dijkstra_test.dist(t); 101 e = dijkstra_test.predArc(t); 102 s = dijkstra_test.predNode(t); 103 b = dijkstra_test.reached(t); 104 pp = dijkstra_test.path(t); 150 l = dijkstra_test.currentDist(t); 105 151 } 106 152 -
test/dim_test.cc
r253 r463 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). -
test/error_test.cc
r277 r463 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). -
test/graph_copy_test.cc
r282 r463 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). -
test/graph_test.cc
r228 r463 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 20 20 #include <lemon/list_graph.h> 21 21 #include <lemon/smart_graph.h> 22 // #include <lemon/full_graph.h> 23 // #include <lemon/grid_graph.h> 22 #include <lemon/full_graph.h> 23 #include <lemon/grid_graph.h> 24 #include <lemon/hypercube_graph.h> 24 25 25 26 #include "test_tools.h" … … 30 31 31 32 template <class Graph> 32 void checkGraph () {33 void checkGraphBuild() { 33 34 TEMPLATE_GRAPH_TYPEDEFS(Graph); 34 35 … … 36 37 checkGraphNodeList(G, 0); 37 38 checkGraphEdgeList(G, 0); 39 checkGraphArcList(G, 0); 38 40 39 41 Node … … 43 45 checkGraphNodeList(G, 3); 44 46 checkGraphEdgeList(G, 0); 47 checkGraphArcList(G, 0); 45 48 46 49 Edge e1 = G.addEdge(n1, n2); 47 50 check((G.u(e1) == n1 && G.v(e1) == n2) || (G.u(e1) == n2 && G.v(e1) == n1), 48 51 "Wrong edge"); 49 checkGraphNodeList(G, 3); 52 53 checkGraphNodeList(G, 3); 54 checkGraphEdgeList(G, 1); 50 55 checkGraphArcList(G, 2); 51 checkGraphEdgeList(G, 1); 52 53 checkGraphOutArcList(G, n1, 1); 54 checkGraphOutArcList(G, n2, 1); 55 checkGraphOutArcList(G, n3, 0); 56 57 checkGraphInArcList(G, n1, 1); 58 checkGraphInArcList(G, n2, 1); 59 checkGraphInArcList(G, n3, 0); 60 61 checkGraphIncEdgeList(G, n1, 1); 62 checkGraphIncEdgeList(G, n2, 1); 63 checkGraphIncEdgeList(G, n3, 0); 64 56 57 checkGraphIncEdgeArcLists(G, n1, 1); 58 checkGraphIncEdgeArcLists(G, n2, 1); 59 checkGraphIncEdgeArcLists(G, n3, 0); 60 61 checkGraphConEdgeList(G, 1); 65 62 checkGraphConArcList(G, 2); 66 checkGraphConEdgeList(G, 1); 67 68 Edge e2 = G.addEdge(n2, n1), e3 = G.addEdge(n2, n3); 69 checkGraphNodeList(G, 3); 63 64 Edge e2 = G.addEdge(n2, n1), 65 e3 = G.addEdge(n2, n3); 66 67 checkGraphNodeList(G, 3); 68 checkGraphEdgeList(G, 3); 70 69 checkGraphArcList(G, 6); 71 checkGraphEdgeList(G, 3); 72 73 checkGraphOutArcList(G, n1, 2); 74 checkGraphOutArcList(G, n2, 3); 75 checkGraphOutArcList(G, n3, 1); 76 77 checkGraphInArcList(G, n1, 2); 78 checkGraphInArcList(G, n2, 3); 79 checkGraphInArcList(G, n3, 1); 80 81 checkGraphIncEdgeList(G, n1, 2); 82 checkGraphIncEdgeList(G, n2, 3); 83 checkGraphIncEdgeList(G, n3, 1); 84 70 71 checkGraphIncEdgeArcLists(G, n1, 2); 72 checkGraphIncEdgeArcLists(G, n2, 3); 73 checkGraphIncEdgeArcLists(G, n3, 1); 74 75 checkGraphConEdgeList(G, 3); 85 76 checkGraphConArcList(G, 6); 86 checkGraphConEdgeList(G, 3);87 77 88 78 checkArcDirections(G); … … 96 86 } 97 87 88 template <class Graph> 89 void checkGraphAlter() { 90 TEMPLATE_GRAPH_TYPEDEFS(Graph); 91 92 Graph G; 93 Node n1 = G.addNode(), n2 = G.addNode(), 94 n3 = G.addNode(), n4 = G.addNode(); 95 Edge e1 = G.addEdge(n1, n2), e2 = G.addEdge(n2, n1), 96 e3 = G.addEdge(n2, n3), e4 = G.addEdge(n1, n4), 97 e5 = G.addEdge(n4, n3); 98 99 checkGraphNodeList(G, 4); 100 checkGraphEdgeList(G, 5); 101 checkGraphArcList(G, 10); 102 103 // Check changeU() and changeV() 104 if (G.u(e2) == n2) { 105 G.changeU(e2, n3); 106 } else { 107 G.changeV(e2, n3); 108 } 109 110 checkGraphNodeList(G, 4); 111 checkGraphEdgeList(G, 5); 112 checkGraphArcList(G, 10); 113 114 checkGraphIncEdgeArcLists(G, n1, 3); 115 checkGraphIncEdgeArcLists(G, n2, 2); 116 checkGraphIncEdgeArcLists(G, n3, 3); 117 checkGraphIncEdgeArcLists(G, n4, 2); 118 119 checkGraphConEdgeList(G, 5); 120 checkGraphConArcList(G, 10); 121 122 if (G.u(e2) == n1) { 123 G.changeU(e2, n2); 124 } else { 125 G.changeV(e2, n2); 126 } 127 128 checkGraphNodeList(G, 4); 129 checkGraphEdgeList(G, 5); 130 checkGraphArcList(G, 10); 131 132 checkGraphIncEdgeArcLists(G, n1, 2); 133 checkGraphIncEdgeArcLists(G, n2, 3); 134 checkGraphIncEdgeArcLists(G, n3, 3); 135 checkGraphIncEdgeArcLists(G, n4, 2); 136 137 checkGraphConEdgeList(G, 5); 138 checkGraphConArcList(G, 10); 139 140 // Check contract() 141 G.contract(n1, n4, false); 142 143 checkGraphNodeList(G, 3); 144 checkGraphEdgeList(G, 5); 145 checkGraphArcList(G, 10); 146 147 checkGraphIncEdgeArcLists(G, n1, 4); 148 checkGraphIncEdgeArcLists(G, n2, 3); 149 checkGraphIncEdgeArcLists(G, n3, 3); 150 151 checkGraphConEdgeList(G, 5); 152 checkGraphConArcList(G, 10); 153 154 G.contract(n2, n3); 155 156 checkGraphNodeList(G, 2); 157 checkGraphEdgeList(G, 3); 158 checkGraphArcList(G, 6); 159 160 checkGraphIncEdgeArcLists(G, n1, 4); 161 checkGraphIncEdgeArcLists(G, n2, 2); 162 163 checkGraphConEdgeList(G, 3); 164 checkGraphConArcList(G, 6); 165 } 166 167 template <class Graph> 168 void checkGraphErase() { 169 TEMPLATE_GRAPH_TYPEDEFS(Graph); 170 171 Graph G; 172 Node n1 = G.addNode(), n2 = G.addNode(), 173 n3 = G.addNode(), n4 = G.addNode(); 174 Edge e1 = G.addEdge(n1, n2), e2 = G.addEdge(n2, n1), 175 e3 = G.addEdge(n2, n3), e4 = G.addEdge(n1, n4), 176 e5 = G.addEdge(n4, n3); 177 178 // Check edge deletion 179 G.erase(e2); 180 181 checkGraphNodeList(G, 4); 182 checkGraphEdgeList(G, 4); 183 checkGraphArcList(G, 8); 184 185 checkGraphIncEdgeArcLists(G, n1, 2); 186 checkGraphIncEdgeArcLists(G, n2, 2); 187 checkGraphIncEdgeArcLists(G, n3, 2); 188 checkGraphIncEdgeArcLists(G, n4, 2); 189 190 checkGraphConEdgeList(G, 4); 191 checkGraphConArcList(G, 8); 192 193 // Check node deletion 194 G.erase(n3); 195 196 checkGraphNodeList(G, 3); 197 checkGraphEdgeList(G, 2); 198 checkGraphArcList(G, 4); 199 200 checkGraphIncEdgeArcLists(G, n1, 2); 201 checkGraphIncEdgeArcLists(G, n2, 1); 202 checkGraphIncEdgeArcLists(G, n4, 1); 203 204 checkGraphConEdgeList(G, 2); 205 checkGraphConArcList(G, 4); 206 } 207 208 209 template <class Graph> 210 void checkGraphSnapshot() { 211 TEMPLATE_GRAPH_TYPEDEFS(Graph); 212 213 Graph G; 214 Node n1 = G.addNode(), n2 = G.addNode(), n3 = G.addNode(); 215 Edge e1 = G.addEdge(n1, n2), e2 = G.addEdge(n2, n1), 216 e3 = G.addEdge(n2, n3); 217 218 checkGraphNodeList(G, 3); 219 checkGraphEdgeList(G, 3); 220 checkGraphArcList(G, 6); 221 222 typename Graph::Snapshot snapshot(G); 223 224 Node n = G.addNode(); 225 G.addEdge(n3, n); 226 G.addEdge(n, n3); 227 G.addEdge(n3, n2); 228 229 checkGraphNodeList(G, 4); 230 checkGraphEdgeList(G, 6); 231 checkGraphArcList(G, 12); 232 233 snapshot.restore(); 234 235 checkGraphNodeList(G, 3); 236 checkGraphEdgeList(G, 3); 237 checkGraphArcList(G, 6); 238 239 checkGraphIncEdgeArcLists(G, n1, 2); 240 checkGraphIncEdgeArcLists(G, n2, 3); 241 checkGraphIncEdgeArcLists(G, n3, 1); 242 243 checkGraphConEdgeList(G, 3); 244 checkGraphConArcList(G, 6); 245 246 checkNodeIds(G); 247 checkEdgeIds(G); 248 checkArcIds(G); 249 checkGraphNodeMap(G); 250 checkGraphEdgeMap(G); 251 checkGraphArcMap(G); 252 253 G.addNode(); 254 snapshot.save(G); 255 256 G.addEdge(G.addNode(), G.addNode()); 257 258 snapshot.restore(); 259 260 checkGraphNodeList(G, 4); 261 checkGraphEdgeList(G, 3); 262 checkGraphArcList(G, 6); 263 } 264 265 void checkFullGraph(int num) { 266 typedef FullGraph Graph; 267 GRAPH_TYPEDEFS(Graph); 268 269 Graph G(num); 270 checkGraphNodeList(G, num); 271 checkGraphEdgeList(G, num * (num - 1) / 2); 272 273 for (NodeIt n(G); n != INVALID; ++n) { 274 checkGraphOutArcList(G, n, num - 1); 275 checkGraphInArcList(G, n, num - 1); 276 checkGraphIncEdgeList(G, n, num - 1); 277 } 278 279 checkGraphConArcList(G, num * (num - 1)); 280 checkGraphConEdgeList(G, num * (num - 1) / 2); 281 282 checkArcDirections(G); 283 284 checkNodeIds(G); 285 checkArcIds(G); 286 checkEdgeIds(G); 287 checkGraphNodeMap(G); 288 checkGraphArcMap(G); 289 checkGraphEdgeMap(G); 290 291 292 for (int i = 0; i < G.nodeNum(); ++i) { 293 check(G.index(G(i)) == i, "Wrong index"); 294 } 295 296 for (NodeIt u(G); u != INVALID; ++u) { 297 for (NodeIt v(G); v != INVALID; ++v) { 298 Edge e = G.edge(u, v); 299 Arc a = G.arc(u, v); 300 if (u == v) { 301 check(e == INVALID, "Wrong edge lookup"); 302 check(a == INVALID, "Wrong arc lookup"); 303 } else { 304 check((G.u(e) == u && G.v(e) == v) || 305 (G.u(e) == v && G.v(e) == u), "Wrong edge lookup"); 306 check(G.source(a) == u && G.target(a) == v, "Wrong arc lookup"); 307 } 308 } 309 } 310 } 311 98 312 void checkConcepts() { 99 313 { // Checking graph components … … 125 339 checkConcept<ClearableGraphComponent<>, SmartGraph>(); 126 340 } 127 // { // Checking FullGraph 128 // checkConcept<Graph, FullGraph>(); 129 // checkGraphIterators<FullGraph>(); 130 // } 131 // { // Checking GridGraph 132 // checkConcept<Graph, GridGraph>(); 133 // checkGraphIterators<GridGraph>(); 134 // } 341 { // Checking FullGraph 342 checkConcept<Graph, FullGraph>(); 343 } 344 { // Checking GridGraph 345 checkConcept<Graph, GridGraph>(); 346 } 347 { // Checking HypercubeGraph 348 checkConcept<Graph, HypercubeGraph>(); 349 } 135 350 } 136 351 … … 189 404 } 190 405 191 // void checkGridGraph(const GridGraph& g, int w, int h) { 192 // check(g.width() == w, "Wrong width"); 193 // check(g.height() == h, "Wrong height"); 194 195 // for (int i = 0; i < w; ++i) { 196 // for (int j = 0; j < h; ++j) { 197 // check(g.col(g(i, j)) == i, "Wrong col"); 198 // check(g.row(g(i, j)) == j, "Wrong row"); 199 // } 200 // } 201 202 // for (int i = 0; i < w; ++i) { 203 // for (int j = 0; j < h - 1; ++j) { 204 // check(g.source(g.down(g(i, j))) == g(i, j), "Wrong down"); 205 // check(g.target(g.down(g(i, j))) == g(i, j + 1), "Wrong down"); 206 // } 207 // check(g.down(g(i, h - 1)) == INVALID, "Wrong down"); 208 // } 209 210 // for (int i = 0; i < w; ++i) { 211 // for (int j = 1; j < h; ++j) { 212 // check(g.source(g.up(g(i, j))) == g(i, j), "Wrong up"); 213 // check(g.target(g.up(g(i, j))) == g(i, j - 1), "Wrong up"); 214 // } 215 // check(g.up(g(i, 0)) == INVALID, "Wrong up"); 216 // } 217 218 // for (int j = 0; j < h; ++j) { 219 // for (int i = 0; i < w - 1; ++i) { 220 // check(g.source(g.right(g(i, j))) == g(i, j), "Wrong right"); 221 // check(g.target(g.right(g(i, j))) == g(i + 1, j), "Wrong right"); 222 // } 223 // check(g.right(g(w - 1, j)) == INVALID, "Wrong right"); 224 // } 225 226 // for (int j = 0; j < h; ++j) { 227 // for (int i = 1; i < w; ++i) { 228 // check(g.source(g.left(g(i, j))) == g(i, j), "Wrong left"); 229 // check(g.target(g.left(g(i, j))) == g(i - 1, j), "Wrong left"); 230 // } 231 // check(g.left(g(0, j)) == INVALID, "Wrong left"); 232 // } 233 // } 406 void checkGridGraph(int width, int height) { 407 typedef GridGraph Graph; 408 GRAPH_TYPEDEFS(Graph); 409 Graph G(width, height); 410 411 check(G.width() == width, "Wrong column number"); 412 check(G.height() == height, "Wrong row number"); 413 414 for (int i = 0; i < width; ++i) { 415 for (int j = 0; j < height; ++j) { 416 check(G.col(G(i, j)) == i, "Wrong column"); 417 check(G.row(G(i, j)) == j, "Wrong row"); 418 check(G.pos(G(i, j)).x == i, "Wrong column"); 419 check(G.pos(G(i, j)).y == j, "Wrong row"); 420 } 421 } 422 423 for (int j = 0; j < height; ++j) { 424 for (int i = 0; i < width - 1; ++i) { 425 check(G.source(G.right(G(i, j))) == G(i, j), "Wrong right"); 426 check(G.target(G.right(G(i, j))) == G(i + 1, j), "Wrong right"); 427 } 428 check(G.right(G(width - 1, j)) == INVALID, "Wrong right"); 429 } 430 431 for (int j = 0; j < height; ++j) { 432 for (int i = 1; i < width; ++i) { 433 check(G.source(G.left(G(i, j))) == G(i, j), "Wrong left"); 434 check(G.target(G.left(G(i, j))) == G(i - 1, j), "Wrong left"); 435 } 436 check(G.left(G(0, j)) == INVALID, "Wrong left"); 437 } 438 439 for (int i = 0; i < width; ++i) { 440 for (int j = 0; j < height - 1; ++j) { 441 check(G.source(G.up(G(i, j))) == G(i, j), "Wrong up"); 442 check(G.target(G.up(G(i, j))) == G(i, j + 1), "Wrong up"); 443 } 444 check(G.up(G(i, height - 1)) == INVALID, "Wrong up"); 445 } 446 447 for (int i = 0; i < width; ++i) { 448 for (int j = 1; j < height; ++j) { 449 check(G.source(G.down(G(i, j))) == G(i, j), "Wrong down"); 450 check(G.target(G.down(G(i, j))) == G(i, j - 1), "Wrong down"); 451 } 452 check(G.down(G(i, 0)) == INVALID, "Wrong down"); 453 } 454 455 checkGraphNodeList(G, width * height); 456 checkGraphEdgeList(G, width * (height - 1) + (width - 1) * height); 457 checkGraphArcList(G, 2 * (width * (height - 1) + (width - 1) * height)); 458 459 for (NodeIt n(G); n != INVALID; ++n) { 460 int nb = 4; 461 if (G.col(n) == 0) --nb; 462 if (G.col(n) == width - 1) --nb; 463 if (G.row(n) == 0) --nb; 464 if (G.row(n) == height - 1) --nb; 465 466 checkGraphOutArcList(G, n, nb); 467 checkGraphInArcList(G, n, nb); 468 checkGraphIncEdgeList(G, n, nb); 469 } 470 471 checkArcDirections(G); 472 473 checkGraphConArcList(G, 2 * (width * (height - 1) + (width - 1) * height)); 474 checkGraphConEdgeList(G, width * (height - 1) + (width - 1) * height); 475 476 checkNodeIds(G); 477 checkArcIds(G); 478 checkEdgeIds(G); 479 checkGraphNodeMap(G); 480 checkGraphArcMap(G); 481 checkGraphEdgeMap(G); 482 483 } 484 485 void checkHypercubeGraph(int dim) { 486 GRAPH_TYPEDEFS(HypercubeGraph); 487 488 HypercubeGraph G(dim); 489 checkGraphNodeList(G, 1 << dim); 490 checkGraphEdgeList(G, dim * (1 << (dim-1))); 491 checkGraphArcList(G, dim * (1 << dim)); 492 493 Node n = G.nodeFromId(dim); 494 495 for (NodeIt n(G); n != INVALID; ++n) { 496 checkGraphIncEdgeList(G, n, dim); 497 for (IncEdgeIt e(G, n); e != INVALID; ++e) { 498 check( (G.u(e) == n && 499 G.id(G.v(e)) == (G.id(n) ^ (1 << G.dimension(e)))) || 500 (G.v(e) == n && 501 G.id(G.u(e)) == (G.id(n) ^ (1 << G.dimension(e)))), 502 "Wrong edge or wrong dimension"); 503 } 504 505 checkGraphOutArcList(G, n, dim); 506 for (OutArcIt a(G, n); a != INVALID; ++a) { 507 check(G.source(a) == n && 508 G.id(G.target(a)) == (G.id(n) ^ (1 << G.dimension(a))), 509 "Wrong arc or wrong dimension"); 510 } 511 512 checkGraphInArcList(G, n, dim); 513 for (InArcIt a(G, n); a != INVALID; ++a) { 514 check(G.target(a) == n && 515 G.id(G.source(a)) == (G.id(n) ^ (1 << G.dimension(a))), 516 "Wrong arc or wrong dimension"); 517 } 518 } 519 520 checkGraphConArcList(G, (1 << dim) * dim); 521 checkGraphConEdgeList(G, dim * (1 << (dim-1))); 522 523 checkArcDirections(G); 524 525 checkNodeIds(G); 526 checkArcIds(G); 527 checkEdgeIds(G); 528 checkGraphNodeMap(G); 529 checkGraphArcMap(G); 530 checkGraphEdgeMap(G); 531 } 234 532 235 533 void checkGraphs() { 236 534 { // Checking ListGraph 237 checkGraph<ListGraph>(); 535 checkGraphBuild<ListGraph>(); 536 checkGraphAlter<ListGraph>(); 537 checkGraphErase<ListGraph>(); 538 checkGraphSnapshot<ListGraph>(); 238 539 checkGraphValidityErase<ListGraph>(); 239 540 } 240 541 { // Checking SmartGraph 241 checkGraph<SmartGraph>(); 542 checkGraphBuild<SmartGraph>(); 543 checkGraphSnapshot<SmartGraph>(); 242 544 checkGraphValidity<SmartGraph>(); 243 545 } 244 // { // Checking FullGraph 245 // FullGraph g(5); 246 // checkGraphNodeList(g, 5); 247 // checkGraphEdgeList(g, 10); 248 // } 249 // { // Checking GridGraph 250 // GridGraph g(5, 6); 251 // checkGraphNodeList(g, 30); 252 // checkGraphEdgeList(g, 49); 253 // checkGridGraph(g, 5, 6); 254 // } 546 { // Checking FullGraph 547 checkFullGraph(7); 548 checkFullGraph(8); 549 } 550 { // Checking GridGraph 551 checkGridGraph(5, 8); 552 checkGridGraph(8, 5); 553 checkGridGraph(5, 5); 554 checkGridGraph(0, 0); 555 checkGridGraph(1, 1); 556 } 557 { // Checking HypercubeGraph 558 checkHypercubeGraph(1); 559 checkHypercubeGraph(2); 560 checkHypercubeGraph(3); 561 checkHypercubeGraph(4); 562 } 255 563 } 256 564 -
test/graph_test.h
r263 r463 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 115 115 check(e==INVALID,"Wrong IncEdge list linking."); 116 116 check(countIncEdges(G,n)==cnt,"Wrong IncEdge number."); 117 } 118 119 template <class Graph> 120 void checkGraphIncEdgeArcLists(const Graph &G, typename Graph::Node n, 121 int cnt) 122 { 123 checkGraphIncEdgeList(G, n, cnt); 124 checkGraphOutArcList(G, n, cnt); 125 checkGraphInArcList(G, n, cnt); 117 126 } 118 127 -
test/graph_utils_test.cc
r220 r619 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 39 39 digraph.addNode(); 40 40 } 41 DescriptorMap<Digraph, Node> nodes(digraph);42 typename DescriptorMap<Digraph, Node>::InverseMap invNodes(nodes);41 RangeIdMap<Digraph, Node> nodes(digraph); 42 typename RangeIdMap<Digraph, Node>::InverseMap invNodes(nodes); 43 43 for (int i = 0; i < 100; ++i) { 44 44 int src = rnd[invNodes.size()]; … … 47 47 } 48 48 typename Digraph::template ArcMap<bool> found(digraph, false); 49 DescriptorMap<Digraph, Arc> arcs(digraph);49 RangeIdMap<Digraph, Arc> arcs(digraph); 50 50 for (NodeIt src(digraph); src != INVALID; ++src) { 51 51 for (NodeIt trg(digraph); trg != INVALID; ++trg) { … … 114 114 graph.addNode(); 115 115 } 116 DescriptorMap<Graph, Node> nodes(graph);117 typename DescriptorMap<Graph, Node>::InverseMap invNodes(nodes);116 RangeIdMap<Graph, Node> nodes(graph); 117 typename RangeIdMap<Graph, Node>::InverseMap invNodes(nodes); 118 118 for (int i = 0; i < 100; ++i) { 119 119 int src = rnd[invNodes.size()]; … … 122 122 } 123 123 typename Graph::template EdgeMap<int> found(graph, 0); 124 DescriptorMap<Graph, Edge> edges(graph);124 RangeIdMap<Graph, Edge> edges(graph); 125 125 for (NodeIt src(graph); src != INVALID; ++src) { 126 126 for (NodeIt trg(graph); trg != INVALID; ++trg) { -
test/heap_test.cc
r293 r463 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). -
test/kruskal_test.cc
r209 r628 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 100 100 "Total cost should be 10"); 101 101 102 edge_cost_map .set(e1, -10);103 edge_cost_map .set(e2, -9);104 edge_cost_map .set(e3, -8);105 edge_cost_map .set(e4, -7);106 edge_cost_map .set(e5, -6);107 edge_cost_map .set(e6, -5);108 edge_cost_map .set(e7, -4);109 edge_cost_map .set(e8, -3);110 edge_cost_map .set(e9, -2);111 edge_cost_map .set(e10, -1);102 edge_cost_map[e1] = -10; 103 edge_cost_map[e2] = -9; 104 edge_cost_map[e3] = -8; 105 edge_cost_map[e4] = -7; 106 edge_cost_map[e5] = -6; 107 edge_cost_map[e6] = -5; 108 edge_cost_map[e7] = -4; 109 edge_cost_map[e8] = -3; 110 edge_cost_map[e9] = -2; 111 edge_cost_map[e10] = -1; 112 112 113 113 vector<Edge> tree_edge_vec(5); -
test/maps_test.cc
r210 r554 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 171 171 typedef ComposeMap<DoubleMap, ReadMap<B,A> > CompMap; 172 172 checkConcept<ReadMap<B,double>, CompMap>(); 173 CompMap map1 (DoubleMap(),ReadMap<B,A>());173 CompMap map1 = CompMap(DoubleMap(),ReadMap<B,A>()); 174 174 CompMap map2 = composeMap(DoubleMap(), ReadMap<B,A>()); 175 175 … … 184 184 typedef CombineMap<DoubleMap, DoubleMap, std::plus<double> > CombMap; 185 185 checkConcept<ReadMap<A,double>, CombMap>(); 186 CombMap map1 (DoubleMap(), DoubleMap());186 CombMap map1 = CombMap(DoubleMap(), DoubleMap()); 187 187 CombMap map2 = combineMap(DoubleMap(), DoubleMap(), std::plus<double>()); 188 188 … … 196 196 checkConcept<ReadMap<A,B>, FunctorToMap<F> >(); 197 197 FunctorToMap<F> map1; 198 FunctorToMap<F> map2 (F());198 FunctorToMap<F> map2 = FunctorToMap<F>(F()); 199 199 B b = functorToMap(F())[A()]; 200 200 201 201 checkConcept<ReadMap<A,B>, MapToFunctor<ReadMap<A,B> > >(); 202 MapToFunctor<ReadMap<A,B> > map (ReadMap<A,B>());202 MapToFunctor<ReadMap<A,B> > map = MapToFunctor<ReadMap<A,B> >(ReadMap<A,B>()); 203 203 204 204 check(functorToMap(&func)[A()] == 3, -
test/path_test.cc
r209 r463 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). -
test/random_test.cc
r209 r463 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). -
test/test_tools.h
r209 r463 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). -
test/test_tools_fail.cc
r209 r463 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). -
test/test_tools_pass.cc
r209 r463 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). -
test/time_measure_test.cc
r209 r605 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 40 40 Timer T; 41 41 unsigned int n; 42 for(n=0;T.realTime()< 1.0;n++) ;42 for(n=0;T.realTime()<0.1;n++) ; 43 43 std::cout << T << " (" << n << " time queries)\n"; 44 T.restart(); 45 while(T.realTime()<2.0) ; 46 std::cout << T << '\n'; 44 47 45 TimeStamp full; 48 46 TimeStamp t; 49 t=runningTimeTest(f, 1,&n,&full);47 t=runningTimeTest(f,0.1,&n,&full); 50 48 std::cout << t << " (" << n << " tests)\n"; 51 49 std::cout << "Total: " << full << "\n"; 52 50 53 t=runningTimeTest(g, 1,&n,&full);51 t=runningTimeTest(g,0.1,&n,&full); 54 52 std::cout << t << " (" << n << " tests)\n"; 55 53 std::cout << "Total: " << full << "\n"; -
test/unionfind_test.cc
r209 r463 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). -
tools/Makefile.am
r310 r573 1 1 if WANT_TOOLS 2 2 3 bin_PROGRAMS += 3 bin_PROGRAMS += \ 4 tools/dimacs-solver \ 5 tools/dimacs-to-lgf \ 6 tools/lgf-gen 7 4 8 dist_bin_SCRIPTS += tools/lemon-0.x-to-1.x.sh 5 9 6 10 endif WANT_TOOLS 11 12 tools_dimacs_solver_SOURCES = tools/dimacs-solver.cc 13 tools_dimacs_to_lgf_SOURCES = tools/dimacs-to-lgf.cc 14 tools_lgf_gen_SOURCES = tools/lgf-gen.cc -
tools/lemon-0.x-to-1.x.sh
r310 r621 4 4 5 5 if [ $# -eq 0 -o x$1 = "x-h" -o x$1 = "x-help" -o x$1 = "x--help" ]; then 6 7 echo " $0 source-file"8 6 echo "Usage:" 7 echo " $0 source-file(s)" 8 exit 9 9 fi 10 10 11 TMP=`mktemp` 12 13 sed -e "s/undirected graph/_gr_aph_label_/g"\ 14 -e "s/undirected edge/_ed_ge_label_/g"\ 15 -e "s/graph_/_gr_aph_label__/g"\ 16 -e "s/_graph/__gr_aph_label_/g"\ 17 -e "s/UGraph/_Gr_aph_label_/g"\ 18 -e "s/uGraph/_gr_aph_label_/g"\ 19 -e "s/ugraph/_gr_aph_label_/g"\ 20 -e "s/Graph/_Digr_aph_label_/g"\ 21 -e "s/graph/_digr_aph_label_/g"\ 22 -e "s/UEdge/_Ed_ge_label_/g"\ 23 -e "s/uEdge/_ed_ge_label_/g"\ 24 -e "s/uedge/_ed_ge_label_/g"\ 25 -e "s/IncEdgeIt/_In_cEd_geIt_label_/g"\ 26 -e "s/Edge/_Ar_c_label_/g"\ 27 -e "s/edge/_ar_c_label_/g"\ 28 -e "s/ANode/_Re_d_label_/g"\ 29 -e "s/BNode/_Blu_e_label_/g"\ 30 -e "s/A-Node/_Re_d_label_/g"\ 31 -e "s/B-Node/_Blu_e_label_/g"\ 32 -e "s/anode/_re_d_label_/g"\ 33 -e "s/bnode/_blu_e_label_/g"\ 34 -e "s/aNode/_re_d_label_/g"\ 35 -e "s/bNode/_blu_e_label_/g"\ 36 -e "s/_Digr_aph_label_/Digraph/g"\ 37 -e "s/_digr_aph_label_/digraph/g"\ 38 -e "s/_Gr_aph_label_/Graph/g"\ 39 -e "s/_gr_aph_label_/graph/g"\ 40 -e "s/_Ar_c_label_/Arc/g"\ 41 -e "s/_ar_c_label_/arc/g"\ 42 -e "s/_Ed_ge_label_/Edge/g"\ 43 -e "s/_ed_ge_label_/edge/g"\ 44 -e "s/_In_cEd_geIt_label_/IncEdgeIt/g"\ 45 -e "s/_Re_d_label_/Red/g"\ 46 -e "s/_Blu_e_label_/Blue/g"\ 47 -e "s/_re_d_label_/red/g"\ 48 -e "s/_blu_e_label_/blue/g"\ 49 -e "s/\(\W\)DefPredMap\(\W\)/\1SetPredMap\2/g"\ 50 -e "s/\(\W\)DefPredMap$/\1SetPredMap/g"\ 51 -e "s/^DefPredMap\(\W\)/SetPredMap\1/g"\ 52 -e "s/^DefPredMap$/SetPredMap/g"\ 53 -e "s/\(\W\)DefDistMap\(\W\)/\1SetDistMap\2/g"\ 54 -e "s/\(\W\)DefDistMap$/\1SetDistMap/g"\ 55 -e "s/^DefDistMap\(\W\)/SetDistMap\1/g"\ 56 -e "s/^DefDistMap$/SetDistMap/g"\ 57 -e "s/\(\W\)DefReachedMap\(\W\)/\1SetReachedMap\2/g"\ 58 -e "s/\(\W\)DefReachedMap$/\1SetReachedMap/g"\ 59 -e "s/^DefReachedMap\(\W\)/SetReachedMap\1/g"\ 60 -e "s/^DefReachedMap$/SetReachedMap/g"\ 61 -e "s/\(\W\)DefProcessedMap\(\W\)/\1SetProcessedMap\2/g"\ 62 -e "s/\(\W\)DefProcessedMap$/\1SetProcessedMap/g"\ 63 -e "s/^DefProcessedMap\(\W\)/SetProcessedMap\1/g"\ 64 -e "s/^DefProcessedMap$/SetProcessedMap/g"\ 65 -e "s/\(\W\)DefHeap\(\W\)/\1SetHeap\2/g"\ 66 -e "s/\(\W\)DefHeap$/\1SetHeap/g"\ 67 -e "s/^DefHeap\(\W\)/SetHeap\1/g"\ 68 -e "s/^DefHeap$/SetHeap/g"\ 69 -e "s/\(\W\)DefStandardHeap\(\W\)/\1SetStandradHeap\2/g"\ 70 -e "s/\(\W\)DefStandardHeap$/\1SetStandradHeap/g"\ 71 -e "s/^DefStandardHeap\(\W\)/SetStandradHeap\1/g"\ 72 -e "s/^DefStandardHeap$/SetStandradHeap/g"\ 73 -e "s/\(\W\)DefOperationTraits\(\W\)/\1SetOperationTraits\2/g"\ 74 -e "s/\(\W\)DefOperationTraits$/\1SetOperationTraits/g"\ 75 -e "s/^DefOperationTraits\(\W\)/SetOperationTraits\1/g"\ 76 -e "s/^DefOperationTraits$/SetOperationTraits/g"\ 77 -e "s/\(\W\)DefProcessedMapToBeDefaultMap\(\W\)/\1SetStandardProcessedMap\2/g"\ 78 -e "s/\(\W\)DefProcessedMapToBeDefaultMap$/\1SetStandardProcessedMap/g"\ 79 -e "s/^DefProcessedMapToBeDefaultMap\(\W\)/SetStandardProcessedMap\1/g"\ 80 -e "s/^DefProcessedMapToBeDefaultMap$/SetStandardProcessedMap/g"\ 81 -e "s/\(\W\)IntegerMap\(\W\)/\1RangeMap\2/g"\ 82 -e "s/\(\W\)IntegerMap$/\1RangeMap/g"\ 83 -e "s/^IntegerMap\(\W\)/RangeMap\1/g"\ 84 -e "s/^IntegerMap$/RangeMap/g"\ 85 -e "s/\(\W\)integerMap\(\W\)/\1rangeMap\2/g"\ 86 -e "s/\(\W\)integerMap$/\1rangeMap/g"\ 87 -e "s/^integerMap\(\W\)/rangeMap\1/g"\ 88 -e "s/^integerMap$/rangeMap/g"\ 89 -e "s/\(\W\)copyGraph\(\W\)/\1graphCopy\2/g"\ 90 -e "s/\(\W\)copyGraph$/\1graphCopy/g"\ 91 -e "s/^copyGraph\(\W\)/graphCopy\1/g"\ 92 -e "s/^copyGraph$/graphCopy/g"\ 93 -e "s/\(\W\)copyDigraph\(\W\)/\1digraphCopy\2/g"\ 94 -e "s/\(\W\)copyDigraph$/\1digraphCopy/g"\ 95 -e "s/^copyDigraph\(\W\)/digraphCopy\1/g"\ 96 -e "s/^copyDigraph$/digraphCopy/g"\ 97 -e "s/\(\W\)\([sS]\)tdMap\(\W\)/\1\2parseMap\3/g"\ 98 -e "s/\(\W\)\([sS]\)tdMap$/\1\2parseMap/g"\ 99 -e "s/^\([sS]\)tdMap\(\W\)/\1parseMap\2/g"\ 100 -e "s/^\([sS]\)tdMap$/\1parseMap/g"\ 101 -e "s/\(\W\)\([Ff]\)unctorMap\(\W\)/\1\2unctorToMap\3/g"\ 102 -e "s/\(\W\)\([Ff]\)unctorMap$/\1\2unctorToMap/g"\ 103 -e "s/^\([Ff]\)unctorMap\(\W\)/\1unctorToMap\2/g"\ 104 -e "s/^\([Ff]\)unctorMap$/\1unctorToMap/g"\ 105 -e "s/\(\W\)\([Mm]\)apFunctor\(\W\)/\1\2apToFunctor\3/g"\ 106 -e "s/\(\W\)\([Mm]\)apFunctor$/\1\2apToFunctor/g"\ 107 -e "s/^\([Mm]\)apFunctor\(\W\)/\1apToFunctor\2/g"\ 108 -e "s/^\([Mm]\)apFunctor$/\1apToFunctor/g"\ 109 -e "s/\(\W\)\([Ff]\)orkWriteMap\(\W\)/\1\2orkMap\3/g"\ 110 -e "s/\(\W\)\([Ff]\)orkWriteMap$/\1\2orkMap/g"\ 111 -e "s/^\([Ff]\)orkWriteMap\(\W\)/\1orkMap\2/g"\ 112 -e "s/^\([Ff]\)orkWriteMap$/\1orkMap/g"\ 113 -e "s/\(\W\)StoreBoolMap\(\W\)/\1LoggerBoolMap\2/g"\ 114 -e "s/\(\W\)StoreBoolMap$/\1LoggerBoolMap/g"\ 115 -e "s/^StoreBoolMap\(\W\)/LoggerBoolMap\1/g"\ 116 -e "s/^StoreBoolMap$/LoggerBoolMap/g"\ 117 -e "s/\(\W\)storeBoolMap\(\W\)/\1loggerBoolMap\2/g"\ 118 -e "s/\(\W\)storeBoolMap$/\1loggerBoolMap/g"\ 119 -e "s/^storeBoolMap\(\W\)/loggerBoolMap\1/g"\ 120 -e "s/^storeBoolMap$/loggerBoolMap/g"\ 121 -e "s/\(\W\)BoundingBox\(\W\)/\1Box\2/g"\ 122 -e "s/\(\W\)BoundingBox$/\1Box/g"\ 123 -e "s/^BoundingBox\(\W\)/Box\1/g"\ 124 -e "s/^BoundingBox$/Box/g"\ 125 <$1 > $TMP 126 127 mv $TMP $1 11 for i in $@ 12 do 13 echo Update $i... 14 TMP=`mktemp` 15 sed -e "s/\<undirected graph\>/_gr_aph_label_/g"\ 16 -e "s/\<undirected graphs\>/_gr_aph_label_s/g"\ 17 -e "s/\<undirected edge\>/_ed_ge_label_/g"\ 18 -e "s/\<undirected edges\>/_ed_ge_label_s/g"\ 19 -e "s/\<directed graph\>/_digr_aph_label_/g"\ 20 -e "s/\<directed graphs\>/_digr_aph_label_s/g"\ 21 -e "s/\<directed edge\>/_ar_c_label_/g"\ 22 -e "s/\<directed edges\>/_ar_c_label_s/g"\ 23 -e "s/UGraph/_Gr_aph_label_/g"\ 24 -e "s/u[Gg]raph/_gr_aph_label_/g"\ 25 -e "s/Graph\>/_Digr_aph_label_/g"\ 26 -e "s/\<graph\>/_digr_aph_label_/g"\ 27 -e "s/Graphs\>/_Digr_aph_label_s/g"\ 28 -e "s/\<graphs\>/_digr_aph_label_s/g"\ 29 -e "s/\([Gg]\)raph\([a-z]\)/_\1r_aph_label_\2/g"\ 30 -e "s/\([a-z_]\)graph/\1_gr_aph_label_/g"\ 31 -e "s/Graph/_Digr_aph_label_/g"\ 32 -e "s/graph/_digr_aph_label_/g"\ 33 -e "s/UEdge/_Ed_ge_label_/g"\ 34 -e "s/u[Ee]dge/_ed_ge_label_/g"\ 35 -e "s/IncEdgeIt/_In_cEd_geIt_label_/g"\ 36 -e "s/Edge\>/_Ar_c_label_/g"\ 37 -e "s/\<edge\>/_ar_c_label_/g"\ 38 -e "s/_edge\>/_ar_c_label_/g"\ 39 -e "s/Edges\>/_Ar_c_label_s/g"\ 40 -e "s/\<edges\>/_ar_c_label_s/g"\ 41 -e "s/_edges\>/_ar_c_label_s/g"\ 42 -e "s/\([Ee]\)dge\([a-z]\)/_\1d_ge_label_\2/g"\ 43 -e "s/\([a-z]\)edge/\1_ed_ge_label_/g"\ 44 -e "s/Edge/_Ar_c_label_/g"\ 45 -e "s/edge/_ar_c_label_/g"\ 46 -e "s/A[Nn]ode/_Re_d_label_/g"\ 47 -e "s/B[Nn]ode/_Blu_e_label_/g"\ 48 -e "s/A-[Nn]ode/_Re_d_label_/g"\ 49 -e "s/B-[Nn]ode/_Blu_e_label_/g"\ 50 -e "s/a[Nn]ode/_re_d_label_/g"\ 51 -e "s/b[Nn]ode/_blu_e_label_/g"\ 52 -e "s/\<UGRAPH_TYPEDEFS\([ \t]*([ \t]*\)typename[ \t]/TEMPLATE__GR_APH_TY_PEDE_FS_label_\1/g"\ 53 -e "s/\<GRAPH_TYPEDEFS\([ \t]*([ \t]*\)typename[ \t]/TEMPLATE__DIGR_APH_TY_PEDE_FS_label_\1/g"\ 54 -e "s/\<UGRAPH_TYPEDEFS\>/_GR_APH_TY_PEDE_FS_label_/g"\ 55 -e "s/\<GRAPH_TYPEDEFS\>/_DIGR_APH_TY_PEDE_FS_label_/g"\ 56 -e "s/_Digr_aph_label_/Digraph/g"\ 57 -e "s/_digr_aph_label_/digraph/g"\ 58 -e "s/_Gr_aph_label_/Graph/g"\ 59 -e "s/_gr_aph_label_/graph/g"\ 60 -e "s/_Ar_c_label_/Arc/g"\ 61 -e "s/_ar_c_label_/arc/g"\ 62 -e "s/_Ed_ge_label_/Edge/g"\ 63 -e "s/_ed_ge_label_/edge/g"\ 64 -e "s/_In_cEd_geIt_label_/IncEdgeIt/g"\ 65 -e "s/_Re_d_label_/Red/g"\ 66 -e "s/_Blu_e_label_/Blue/g"\ 67 -e "s/_re_d_label_/red/g"\ 68 -e "s/_blu_e_label_/blue/g"\ 69 -e "s/_GR_APH_TY_PEDE_FS_label_/GRAPH_TYPEDEFS/g"\ 70 -e "s/_DIGR_APH_TY_PEDE_FS_label_/DIGRAPH_TYPEDEFS/g"\ 71 -e "s/DigraphToEps/GraphToEps/g"\ 72 -e "s/digraphToEps/graphToEps/g"\ 73 -e "s/\<DefPredMap\>/SetPredMap/g"\ 74 -e "s/\<DefDistMap\>/SetDistMap/g"\ 75 -e "s/\<DefReachedMap\>/SetReachedMap/g"\ 76 -e "s/\<DefProcessedMap\>/SetProcessedMap/g"\ 77 -e "s/\<DefHeap\>/SetHeap/g"\ 78 -e "s/\<DefStandardHeap\>/SetStandradHeap/g"\ 79 -e "s/\<DefOperationTraits\>/SetOperationTraits/g"\ 80 -e "s/\<DefProcessedMapToBeDefaultMap\>/SetStandardProcessedMap/g"\ 81 -e "s/\<copyGraph\>/graphCopy/g"\ 82 -e "s/\<copyDigraph\>/digraphCopy/g"\ 83 -e "s/\<HyperCubeDigraph\>/HypercubeGraph/g"\ 84 -e "s/\<IntegerMap\>/RangeMap/g"\ 85 -e "s/\<integerMap\>/rangeMap/g"\ 86 -e "s/\<\([sS]\)tdMap\>/\1parseMap/g"\ 87 -e "s/\<\([Ff]\)unctorMap\>/\1unctorToMap/g"\ 88 -e "s/\<\([Mm]\)apFunctor\>/\1apToFunctor/g"\ 89 -e "s/\<\([Ff]\)orkWriteMap\>/\1orkMap/g"\ 90 -e "s/\<StoreBoolMap\>/LoggerBoolMap/g"\ 91 -e "s/\<storeBoolMap\>/loggerBoolMap/g"\ 92 -e "s/\<InvertableMap\>/CrossRefMap/g"\ 93 -e "s/\<invertableMap\>/crossRefMap/g"\ 94 -e "s/\<DescriptorMap\>/RangeIdMap/g"\ 95 -e "s/\<descriptorMap\>/rangeIdMap/g"\ 96 -e "s/\<BoundingBox\>/Box/g"\ 97 -e "s/\<readNauty\>/readNautyGraph/g"\ 98 -e "s/\<RevDigraphAdaptor\>/ReverseDigraph/g"\ 99 -e "s/\<revDigraphAdaptor\>/reverseDigraph/g"\ 100 -e "s/\<SubDigraphAdaptor\>/SubDigraph/g"\ 101 -e "s/\<subDigraphAdaptor\>/subDigraph/g"\ 102 -e "s/\<SubGraphAdaptor\>/SubGraph/g"\ 103 -e "s/\<subGraphAdaptor\>/subGraph/g"\ 104 -e "s/\<NodeSubDigraphAdaptor\>/FilterNodes/g"\ 105 -e "s/\<nodeSubDigraphAdaptor\>/filterNodes/g"\ 106 -e "s/\<ArcSubDigraphAdaptor\>/FilterArcs/g"\ 107 -e "s/\<arcSubDigraphAdaptor\>/filterArcs/g"\ 108 -e "s/\<UndirDigraphAdaptor\>/Undirector/g"\ 109 -e "s/\<undirDigraphAdaptor\>/undirector/g"\ 110 -e "s/\<ResDigraphAdaptor\>/ResidualDigraph/g"\ 111 -e "s/\<resDigraphAdaptor\>/residualDigraph/g"\ 112 -e "s/\<SplitDigraphAdaptor\>/SplitNodes/g"\ 113 -e "s/\<splitDigraphAdaptor\>/splitNodes/g"\ 114 -e "s/\<SubGraphAdaptor\>/SubGraph/g"\ 115 -e "s/\<subGraphAdaptor\>/subGraph/g"\ 116 -e "s/\<NodeSubGraphAdaptor\>/FilterNodes/g"\ 117 -e "s/\<nodeSubGraphAdaptor\>/filterNodes/g"\ 118 -e "s/\<ArcSubGraphAdaptor\>/FilterEdges/g"\ 119 -e "s/\<arcSubGraphAdaptor\>/filterEdges/g"\ 120 -e "s/\<DirGraphAdaptor\>/Orienter/g"\ 121 -e "s/\<dirGraphAdaptor\>/orienter/g"\ 122 -e "s/\<LpCplex\>/CplexLp/g"\ 123 -e "s/\<MipCplex\>/CplexMip/g"\ 124 -e "s/\<LpGlpk\>/GlpkLp/g"\ 125 -e "s/\<MipGlpk\>/GlpkMip/g"\ 126 -e "s/\<LpSoplex\>/SoplexLp/g"\ 127 <$i > $TMP 128 mv $TMP $i 129 done
Note: See TracChangeset
for help on using the changeset viewer.