COIN-OR::LEMON - Graph Library

Ignore:
Files:
67 added
106 edited

Legend:

Unmodified
Added
Removed
  • .hgignore

    r514 r610  
    2323lemon/stamp-h2
    2424doc/Doxyfile
    25 cmake/cmake.version
     25cmake/version.cmake
    2626.dirstamp
    2727.libs/*
    2828.deps/*
    2929demo/*.eps
     30m4/libtool.m4
     31m4/ltoptions.m4
     32m4/ltsugar.m4
     33m4/ltversion.m4
     34m4/lt~obsolete.m4
    3035
    3136syntax: regexp
     
    3641^autom4te.cache/.*
    3742^build-aux/.*
    38 ^objs.*/.*
     43^.*objs.*/.*
    3944^test/[a-z_]*$
     45^tools/[a-z-_]*$
    4046^demo/.*_demo$
    41 ^build/.*
     47^.*build.*/.*
    4248^doc/gen-images/.*
    4349CMakeFiles
  • CMakeLists.txt

    r520 r674  
    1010PROJECT(${PROJECT_NAME})
    1111
    12 SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
     12SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
    1313
    1414INCLUDE(FindDoxygen)
    1515INCLUDE(FindGhostscript)
     16FIND_PACKAGE(GLPK 4.33)
     17FIND_PACKAGE(CPLEX)
     18FIND_PACKAGE(COIN)
     19
     20ADD_DEFINITIONS(-DHAVE_CONFIG_H)
     21
     22IF(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
     29ENDIF(MSVC)
     30
     31ADD_DEFINITIONS(-DHAVE_CONFIG_H)
    1632
    1733INCLUDE(CheckTypeSize)
    18 CHECK_TYPE_SIZE("long long" LONG_LONG)
     34CHECK_TYPE_SIZE("long long" LEMON_LONG_LONG)
    1935
    2036ENABLE_TESTING()
    2137
    2238ADD_SUBDIRECTORY(lemon)
    23 ADD_SUBDIRECTORY(demo)
    24 ADD_SUBDIRECTORY(doc)
    25 ADD_SUBDIRECTORY(test)
     39IF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
     40  ADD_SUBDIRECTORY(demo)
     41  ADD_SUBDIRECTORY(tools)
     42  ADD_SUBDIRECTORY(doc)
     43  ADD_SUBDIRECTORY(test)
     44ENDIF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
    2645
    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")
     46IF(${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")
    3353
    34   SET(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
     54    SET(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
    3555
    36   SET(CPACK_PACKAGE_INSTALL_DIRECTORY
    37     "${PROJECT_NAME} ${PROJECT_VERSION}")
    38   SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY
    39     "${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}")
    4060
    41   SET(CPACK_COMPONENTS_ALL headers library html_documentation)
     61    SET(CPACK_COMPONENTS_ALL headers library html_documentation bin)
    4262
    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")
    4667
    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")
    5376
    54   SET(CPACK_COMPONENT_HEADERS_DEPENDS library)
     77    SET(CPACK_COMPONENT_HEADERS_DEPENDS library)
    5578
    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")
    5982
    60   SET(CPACK_COMPONENT_GROUP_DEVELOPMENT_DESCRIPTION
    61     "Components needed to develop software using LEMON")
    62   SET(CPACK_COMPONENT_GROUP_DOCUMENTATION_DESCRIPTION
    63     "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")
    6487
    65   SET(CPACK_ALL_INSTALL_TYPES Full Developer)
     88    SET(CPACK_ALL_INSTALL_TYPES Full Developer)
    6689
    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)
    7093
    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_TEMP
    85     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      ")
    87110
    88   INCLUDE(CPack)
    89 ENDIF(WIN32)
     111    INCLUDE(CPack)
     112  ENDIF(WIN32)
     113ENDIF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
  • INSTALL

    r526 r615  
    2828
    2929      This command compiles the non-template part of LEMON into libemon.a
    30       file. It also compiles the programs in the tools and demo subdirectories
    31       when enabled.
     30      file. It also compiles the programs in the tools subdirectory by
     31      default.
    3232
    3333   4. `make check'
     
    7575
    7676  Set the installation prefix to PREFIX. By default it is /usr/local.
    77 
    78 --enable-demo
    79 
    80    Build the examples in the demo subdirectory.
    81 
    82 --disable-demo
    83 
    84    Do not build the examples in the demo subdirectory (default).
    8577
    8678--enable-tools
     
    159151
    160152   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  
    22copyright/license.
    33
    4 Copyright (C) 2003-2008 Egervary Jeno Kombinatorikus Optimalizalasi
     4Copyright (C) 2003-2009 Egervary Jeno Kombinatorikus Optimalizalasi
    55Kutatocsoport (Egervary Combinatorial Optimization Research Group,
    66EGRES).
  • Makefile.am

    r503 r614  
    11ACLOCAL_AMFLAGS = -I m4
     2
     3AM_CXXFLAGS = $(WARNINGCXXFLAGS)
    24
    35AM_CPPFLAGS = -I$(top_srcdir) -I$(top_builddir)
     
    1012        m4/lx_check_glpk.m4 \
    1113        m4/lx_check_soplex.m4 \
     14        m4/lx_check_clp.m4 \
     15        m4/lx_check_cbc.m4 \
    1216        CMakeLists.txt \
    1317        cmake/FindGhostscript.cmake \
     18        cmake/FindGLPK.cmake \
    1419        cmake/version.cmake.in \
    1520        cmake/version.cmake \
     
    3742include test/Makefile.am
    3843include doc/Makefile.am
    39 include demo/Makefile.am
    4044include tools/Makefile.am
     45
     46DIST_SUBDIRS = demo
     47
     48demo:
     49        $(MAKE) $(AM_MAKEFLAGS) -C demo
    4150
    4251MRPROPERFILES = \
     
    6675        bzip2 --best -c > $(PACKAGE)-$(VERSION).tar.bz2
    6776
    68 .PHONY: mrproper dist-bz2 distcheck-bz2
     77.PHONY: demo mrproper dist-bz2 distcheck-bz2
  • configure.ac

    r515 r674  
    2020AC_CONFIG_HEADERS([config.h lemon/config.h])
    2121
    22 lx_cmdline_cxxflags_set=${CXXFLAGS+set}
    23 
    2422dnl Do compilation tests using the C++ compiler.
    2523AC_LANG([C++])
     
    2826AC_CHECK_TYPE(long long, [long_long_found=yes], [long_long_found=no])
    2927if 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.])
    3129fi
    3230
     
    5351
    5452dnl Set custom compiler flags when using g++.
    55 if test x"$lx_cmdline_cxxflags_set" != x"set" -a "$GXX" = yes -a "$ICC" = no; then
    56   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"
     53if 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"
    5755fi
     56AC_SUBST([WARNINGCXXFLAGS])
    5857
    5958dnl Checks for libraries.
    60 #LX_CHECK_GLPK
    61 #LX_CHECK_CPLEX
    62 #LX_CHECK_SOPLEX
     59LX_CHECK_GLPK
     60LX_CHECK_CPLEX
     61LX_CHECK_SOPLEX
     62LX_CHECK_COIN
    6363
    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"])
     64AM_CONDITIONAL([HAVE_LP], [test x"$lx_lp_found" = x"yes"])
     65AM_CONDITIONAL([HAVE_MIP], [test x"$lx_mip_found" = x"yes"])
    7666
    7767dnl Disable/enable building the binary tools.
     
    10898AC_CONFIG_FILES([
    10999Makefile
     100demo/Makefile
    110101cmake/version.cmake
    111102doc/Doxyfile
     
    121112echo
    122113echo C++ compiler.................. : $CXX
    123 echo C++ compiles flags............ : $CXXFLAGS
     114echo C++ compiles flags............ : $WARNINGCXXFLAGS $CXXFLAGS
    124115echo
    125116echo Compiler supports long long... : $long_long_found
    126117echo
    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
     118echo GLPK support.................. : $lx_glpk_found
     119echo CPLEX support................. : $lx_cplex_found
     120echo SOPLEX support................ : $lx_soplex_found
     121echo CLP support................... : $lx_clp_found
     122echo CBC support................... : $lx_cbc_found
     123echo
    132124echo Build additional tools........ : $enable_tools
    133125echo
  • demo/CMakeLists.txt

    r225 r674  
    1 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
     1INCLUDE_DIRECTORIES(
     2  ${PROJECT_SOURCE_DIR}
     3  ${PROJECT_BINARY_DIR}
     4)
    25
    3 LINK_DIRECTORIES(${CMAKE_BINARY_DIR}/lemon)
     6LINK_DIRECTORIES(${PROJECT_BINARY_DIR}/lemon)
    47
    58SET(DEMOS
  • demo/Makefile.am

    r164 r611  
    1 EXTRA_DIST += \
    2         demo/CMakeLists.txt \
    3         demo/digraph.lgf
     1AM_CXXFLAGS = $(WARNINGCXXFLAGS)
    42
    5 if WANT_DEMO
     3AM_CPPFLAGS = -I$(top_srcdir) -I$(top_builddir)
     4LDADD = $(top_builddir)/lemon/libemon.la
    65
    7 noinst_PROGRAMS += \
    8         demo/arg_parser_demo \
    9         demo/graph_to_eps_demo \
    10         demo/lgf_demo
     6EXTRA_DIST = \
     7        CMakeLists.txt \
     8        digraph.lgf
    119
    12 endif WANT_DEMO
     10noinst_PROGRAMS = \
     11        arg_parser_demo \
     12        graph_to_eps_demo \
     13        lgf_demo
    1314
    14 demo_arg_parser_demo_SOURCES = demo/arg_parser_demo.cc
    15 demo_graph_to_eps_demo_SOURCES = demo/graph_to_eps_demo.cc
    16 demo_lgf_demo_SOURCES = demo/lgf_demo.cc
     15arg_parser_demo_SOURCES = arg_parser_demo.cc
     16graph_to_eps_demo_SOURCES = graph_to_eps_demo.cc
     17lgf_demo_SOURCES = lgf_demo.cc
  • demo/arg_parser_demo.cc

    r311 r463  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
  • demo/graph_to_eps_demo.cc

    r313 r659  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    8686    coords(coords).
    8787    title("Sample .eps figure").
    88     copyright("(C) 2003-2008 LEMON Project").
     88    copyright("(C) 2003-2009 LEMON Project").
    8989    run();
    9090
     
    9393    coords(coords).
    9494    title("Sample .eps figure").
    95     copyright("(C) 2003-2008 LEMON Project").
     95    copyright("(C) 2003-2009 LEMON Project").
    9696    absoluteNodeSizes().absoluteArcWidths().
    9797    nodeScale(2).nodeSizes(sizes).
     
    106106  graphToEps(g,"graph_to_eps_demo_out_3_arr.eps").
    107107    title("Sample .eps figure (with arrowheads)").
    108     copyright("(C) 2003-2008 LEMON Project").
     108    copyright("(C) 2003-2009 LEMON Project").
    109109    absoluteNodeSizes().absoluteArcWidths().
    110110    nodeColors(composeMap(palette,colors)).
     
    133133  graphToEps(g,"graph_to_eps_demo_out_4_par.eps").
    134134    title("Sample .eps figure (parallel arcs)").
    135     copyright("(C) 2003-2008 LEMON Project").
     135    copyright("(C) 2003-2009 LEMON Project").
    136136    absoluteNodeSizes().absoluteArcWidths().
    137137    nodeShapes(shapes).
     
    148148  graphToEps(g,"graph_to_eps_demo_out_5_par_arr.eps").
    149149    title("Sample .eps figure (parallel arcs and arrowheads)").
    150     copyright("(C) 2003-2008 LEMON Project").
     150    copyright("(C) 2003-2009 LEMON Project").
    151151    absoluteNodeSizes().absoluteArcWidths().
    152152    nodeScale(2).nodeSizes(sizes).
     
    164164  graphToEps(g,"graph_to_eps_demo_out_6_par_arr_a4.eps").
    165165    title("Sample .eps figure (fits to A4)").
    166     copyright("(C) 2003-2008 LEMON Project").
     166    copyright("(C) 2003-2009 LEMON Project").
    167167    scaleToA4().
    168168    absoluteNodeSizes().absoluteArcWidths().
     
    183183  ListDigraph::NodeMap<Point> hcoords(h);
    184184
    185   int cols=int(sqrt(double(palette.size())));
     185  int cols=int(std::sqrt(double(palette.size())));
    186186  for(int i=0;i<int(paletteW.size());i++) {
    187187    Node n=h.addNode();
     
    194194    scale(60).
    195195    title("Sample .eps figure (Palette demo)").
    196     copyright("(C) 2003-2008 LEMON Project").
     196    copyright("(C) 2003-2009 LEMON Project").
    197197    coords(hcoords).
    198198    absoluteNodeSizes().absoluteArcWidths().
  • demo/lgf_demo.cc

    r294 r463  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
  • doc/CMakeLists.txt

    r520 r633  
    11SET(PACKAGE_NAME ${PROJECT_NAME})
    22SET(PACKAGE_VERSION ${PROJECT_VERSION})
    3 SET(abs_top_srcdir ${CMAKE_SOURCE_DIR})
    4 SET(abs_top_builddir ${CMAKE_BINARY_DIR})
     3SET(abs_top_srcdir ${PROJECT_SOURCE_DIR})
     4SET(abs_top_builddir ${PROJECT_BINARY_DIR})
    55
    66CONFIGURE_FILE(
    7   ${CMAKE_SOURCE_DIR}/doc/Doxyfile.in
    8   ${CMAKE_BINARY_DIR}/doc/Doxyfile
     7  ${PROJECT_SOURCE_DIR}/doc/Doxyfile.in
     8  ${PROJECT_BINARY_DIR}/doc/Doxyfile
    99  @ONLY)
    1010
     
    1515      COMMAND rm -rf gen-images
    1616      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
    1723      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
    1824      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
     
    2026      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
    2127      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
    2229      COMMAND rm -rf html
    2330      COMMAND ${DOXYGEN_EXECUTABLE} Doxyfile
     
    2734      COMMAND if exist gen-images rmdir /s /q gen-images
    2835      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
    2942      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
    3043      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
     
    3245      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
    3346      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
    3448      COMMAND if exist html rmdir /s /q html
    3549      COMMAND ${DOXYGEN_EXECUTABLE} Doxyfile
  • doc/Doxyfile.in

    r316 r379  
    6767ENABLED_SECTIONS       =
    6868MAX_INITIALIZER_LINES  = 5
    69 SHOW_USED_FILES        = YES
     69SHOW_USED_FILES        = NO
    7070SHOW_DIRECTORIES       = YES
    7171SHOW_FILES             = YES
  • doc/Makefile.am

    r317 r634  
    1515
    1616DOC_EPS_IMAGES18 = \
     17        grid_graph.eps \
    1718        nodeshape_0.eps \
    1819        nodeshape_1.eps \
     
    2122        nodeshape_4.eps
    2223
     24DOC_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
    2332DOC_EPS_IMAGES = \
    24         $(DOC_EPS_IMAGES18)
     33        $(DOC_EPS_IMAGES18) \
     34        $(DOC_EPS_IMAGES27)
    2535
    2636DOC_PNG_IMAGES = \
     
    3848        if test ${gs_found} = yes; then \
    3949          $(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=$@ $<; \
    4061        else \
    4162          echo; \
  • doc/coding_style.dox

    r210 r463  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
  • doc/dirs.dox

    r318 r463  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    7272\brief Auxiliary tools for implementation.
    7373
    74 This directory contains some auxiliary classes for implementing graphs, 
     74This directory contains some auxiliary classes for implementing graphs,
    7575maps and some other classes.
    7676As a user you typically don't have to deal with these files.
  • doc/groups.dox

    r318 r658  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    1717 */
    1818
     19namespace lemon {
     20
    1921/**
    2022@defgroup datas Data Structures
    21 This group describes the several data structures implemented in LEMON.
     23This group contains the several data structures implemented in LEMON.
    2224*/
    2325
     
    6163
    6264/**
     65@defgroup graph_adaptors Adaptor Classes for Graphs
     66@ingroup graphs
     67\brief Adaptor classes for digraphs and graphs
     68
     69This group contains several useful adaptor classes for digraphs and graphs.
     70
     71The main parts of LEMON are the different graph structures, generic
     72graph algorithms, graph concepts, which couple them, and graph
     73adaptors. While the previous notions are more or less clear, the
     74latter one needs further explanation. Graph adaptors are graph classes
     75which serve for considering graph structures in different ways.
     76
     77A short example makes this much clearer.  Suppose that we have an
     78instance \c g of a directed graph type, say ListDigraph and an algorithm
     79\code
     80template <typename Digraph>
     81int algorithm(const Digraph&);
     82\endcode
     83is 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
     85arcs.  In this case, an adaptor class is used, which (according
     86to LEMON \ref concepts::Digraph "digraph concepts") works as a digraph.
     87The adaptor uses the original digraph structure and digraph operations when
     88methods of the reversed oriented graph are called.  This means that the adaptor
     89have minor memory usage, and do not perform sophisticated algorithmic
     90actions.  The purpose of it is to give a tool for the cases when a
     91graph have to be used in a specific alteration.  If this alteration is
     92obtained by a usual construction like filtering the node or the arc set or
     93considering a new orientation, then an adaptor is worthwhile to use.
     94To come back to the reverse oriented graph, in this situation
     95\code
     96template<typename Digraph> class ReverseDigraph;
     97\endcode
     98template class can be used. The code looks as follows
     99\code
     100ListDigraph g;
     101ReverseDigraph<ListDigraph> rg(g);
     102int result = algorithm(rg);
     103\endcode
     104During running the algorithm, the original digraph \c g is untouched.
     105This techniques give rise to an elegant code, and based on stable
     106graph adaptors, complex algorithms can be implemented easily.
     107
     108In flow, circulation and matching problems, the residual
     109graph is of particular importance. Combining an adaptor implementing
     110this with shortest path algorithms or minimum mean cycle algorithms,
     111a range of weighted and cardinality optimization algorithms can be
     112obtained. For other examples, the interested user is referred to the
     113detailed documentation of particular adaptors.
     114
     115The behavior of graph adaptors can be very different. Some of them keep
     116capabilities of the original graph while in other cases this would be
     117meaningless. This means that the concepts that they meet depend
     118on the graph adaptor, and the wrapped graph.
     119For example, if an arc of a reversed digraph is deleted, this is carried
     120out by deleting the corresponding arc of the original digraph, thus the
     121adaptor modifies the original digraph.
     122However in case of a residual digraph, this operation has no sense.
     123
     124Let us stand one more example here to simplify your work.
     125ReverseDigraph has constructor
     126\code
     127ReverseDigraph(Digraph& digraph);
     128\endcode
     129This means that in a situation, when a <tt>const %ListDigraph&</tt>
     130reference to a graph is given, then it have to be instantiated with
     131<tt>Digraph=const %ListDigraph</tt>.
     132\code
     133int algorithm1(const ListDigraph& g) {
     134  ReverseDigraph<const ListDigraph> rg(g);
     135  return algorithm2(rg);
     136}
     137\endcode
     138*/
     139
     140/**
    63141@defgroup semi_adaptors Semi-Adaptor Classes for Graphs
    64142@ingroup graphs
    65143\brief Graph types between real graphs and graph adaptors.
    66144
    67 This group describes some graph types between real graphs and graph adaptors.
     145This group contains some graph types between real graphs and graph adaptors.
    68146These classes wrap graphs to give new functionality as the adaptors do it.
    69147On the other hand they are not light-weight structures as the adaptors.
     
    75153\brief Map structures implemented in LEMON.
    76154
    77 This group describes the map structures implemented in LEMON.
     155This group contains the map structures implemented in LEMON.
    78156
    79157LEMON provides several special purpose maps and map adaptors that e.g. combine
     
    88166\brief Special graph-related maps.
    89167
    90 This group describes maps that are specifically designed to assign
    91 values to the nodes and arcs of graphs.
     168This group contains maps that are specifically designed to assign
     169values to the nodes and arcs/edges of graphs.
     170
     171If you are looking for the standard graph maps (\c NodeMap, \c ArcMap,
     172\c EdgeMap), see the \ref graph_concepts "Graph Structure Concepts".
    92173*/
    93174
     
    97178\brief Tools to create new maps from existing ones
    98179
    99 This group describes map adaptors that are used to create "implicit"
     180This group contains map adaptors that are used to create "implicit"
    100181maps from other maps.
    101182
    102 Most of them are \ref lemon::concepts::ReadMap "read-only maps".
     183Most of them are \ref concepts::ReadMap "read-only maps".
    103184They can make arithmetic and logical operations between one or two maps
    104185(negation, shifting, addition, multiplication, logical 'and', 'or',
     
    160241\brief Two dimensional data storages implemented in LEMON.
    161242
    162 This group describes two dimensional data storages implemented in LEMON.
     243This group contains two dimensional data storages implemented in LEMON.
    163244*/
    164245
     
    168249\brief %Path structures implemented in LEMON.
    169250
    170 This group describes the path structures implemented in LEMON.
     251This group contains the path structures implemented in LEMON.
    171252
    172253LEMON provides flexible data structures to work with paths.
     
    184265\brief Auxiliary data structures implemented in LEMON.
    185266
    186 This group describes some data structures implemented in LEMON in
     267This group contains some data structures implemented in LEMON in
    187268order to make it easier to implement combinatorial algorithms.
    188269*/
     
    190271/**
    191272@defgroup algs Algorithms
    192 \brief This group describes the several algorithms
     273\brief This group contains the several algorithms
    193274implemented in LEMON.
    194275
    195 This group describes the several algorithms
     276This group contains the several algorithms
    196277implemented in LEMON.
    197278*/
     
    202283\brief Common graph search algorithms.
    203284
    204 This group describes the common graph search algorithms like
    205 Breadth-First Search (BFS) and Depth-First Search (DFS).
     285This group contains the common graph search algorithms, namely
     286\e breadth-first \e search (BFS) and \e depth-first \e search (DFS).
    206287*/
    207288
     
    211292\brief Algorithms for finding shortest paths.
    212293
    213 This group describes the algorithms for finding shortest paths in graphs.
     294This 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.
    214308*/
    215309
     
    219313\brief Algorithms for finding maximum flows.
    220314
    221 This group describes the algorithms for finding maximum flows and
     315This group contains the algorithms for finding maximum flows and
    222316feasible circulations.
    223317
    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]
     318The \e maximum \e flow \e problem is to find a flow of maximum value between
     319a single source and a single target. Formally, there is a \f$G=(V,A)\f$
     320digraph, a \f$cap: A\rightarrow\mathbf{R}^+_0\f$ capacity function and
     321\f$s, t \in V\f$ source and target nodes.
     322A maximum flow is an \f$f: A\rightarrow\mathbf{R}^+_0\f$ solution of the
     323following 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]
    234329
    235330LEMON 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 the
    242 fastest method to compute the maximum flow. All impelementations
    243 provides functions to query the minimum cut, which is the dual linear
    244 programming 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
     336In most cases the \ref Preflow "Preflow" algorithm provides the
     337fastest method for computing a maximum flow. All implementations
     338provides functions to also query the minimum cut, which is the dual
     339problem of the maximum flow.
    245340*/
    246341
     
    251346\brief Algorithms for finding minimum cost flows and circulations.
    252347
    253 This group describes the algorithms for finding minimum cost flows and
     348This group contains the algorithms for finding minimum cost flows and
    254349circulations.
     350
     351The \e minimum \e cost \e flow \e problem is to find a feasible flow of
     352minimum total cost from a set of supply nodes to a set of demand nodes
     353in a network with capacity constraints (lower and upper bounds)
     354and arc costs.
     355Formally, let \f$G=(V,A)\f$ be a digraph,
     356\f$lower, upper: A\rightarrow\mathbf{Z}^+_0\f$ denote the lower and
     357upper 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
     360on the arcs, and \f$sup: V\rightarrow\mathbf{Z}\f$ denotes the
     361signed supply values of the nodes.
     362If \f$sup(u)>0\f$, then \f$u\f$ is a supply node with \f$sup(u)\f$
     363supply, if \f$sup(u)<0\f$, then \f$u\f$ is a demand node with
     364\f$-sup(u)\f$ demand.
     365A minimum cost flow is an \f$f: A\rightarrow\mathbf{Z}^+_0\f$ solution
     366of 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
     373The sum of the supply values, i.e. \f$\sum_{u\in V} sup(u)\f$ must be
     374zero or negative in order to have a feasible solution (since the sum
     375of the expressions on the left-hand side of the inequalities is zero).
     376It means that the total demand must be greater or equal to the total
     377supply and all the supplies have to be carried out from the supply nodes,
     378but there could be demands that are not satisfied.
     379If \f$\sum_{u\in V} sup(u)\f$ is zero, then all the supply/demand
     380constraints have to be satisfied with equality, i.e. all demands
     381have to be satisfied and all supplies have to be used.
     382
     383If 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
     385have to be satisfied while there could be supplies that are not used),
     386then you could easily transform the problem to the above form by reversing
     387the direction of the arcs and taking the negative of the supply values
     388(e.g. using \ref ReverseDigraph and \ref NegMap adaptors).
     389However \ref NetworkSimplex algorithm also supports this form directly
     390for the sake of convenience.
     391
     392A feasible solution for this problem can be found using \ref Circulation.
     393
     394Note that the above formulation is actually more general than the usual
     395definition of the minimum cost flow problem, in which strict equalities
     396are 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
     401However if the sum of the supply values is zero, then these two problems
     402are equivalent. So if you need the equality form, you have to ensure this
     403additional contraint for the algorithms.
     404
     405The dual solution of the minimum cost flow problem is represented by node
     406potentials \f$\pi: V\rightarrow\mathbf{Z}\f$.
     407An \f$f: A\rightarrow\mathbf{Z}^+_0\f$ feasible solution of the problem
     408is optimal if and only if for some \f$\pi: V\rightarrow\mathbf{Z}\f$
     409node potentials the following \e complementary \e slackness optimality
     410conditions 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 
     420Here \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
     424All algorithms provide dual solution (node potentials) as well
     425if an optimal flow is found.
     426
     427LEMON 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
     437Most of these implementations support the general inequality form of the
     438minimum cost flow problem, but CancelAndTighten and CycleCanceling
     439only support the equality form due to the primal method they use.
     440
     441In general NetworkSimplex is the most efficient implementation,
     442but in special cases other algorithms could be faster.
     443For example, if the total supply and/or capacities are rather small,
     444CapacityScaling is usually the fastest algorithm (without effective scaling).
    255445*/
    256446
     
    261451\brief Algorithms for finding minimum cut in graphs.
    262452
    263 This group describes the algorithms for finding minimum cut in graphs.
    264 
    265 The minimum cut problem is to find a non-empty and non-complete
    266 \f$X\f$ subset of the vertices with minimum overall capacity on
    267 outgoing arcs. Formally, there is \f$G=(V,A)\f$ directed graph, an
    268 \f$c_a:A\rightarrow\mathbf{R}^+_0\f$ capacity function. The minimum
     453This group contains the algorithms for finding minimum cut in graphs.
     454
     455The \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
     457outgoing 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
    269459cut is the \f$X\f$ solution of the next optimization problem:
    270460
    271461\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]
    273463
    274464LEMON contains several algorithms related to minimum cut problems:
    275465
    276 - \ref lemon::HaoOrlin "Hao-Orlin algorithm" to calculate minimum cut
    277   in directed graphs
    278 - \ref lemon::NagamochiIbaraki "Nagamochi-Ibaraki algorithm" to
    279   calculate minimum cut in undirected graphs
    280 - \ref lemon::GomoryHuTree "Gomory-Hu tree computation" to calculate all
    281   pairs minimum cut in undirected graphs
     466- \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.
    282472
    283473If 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 Properties
     474see the \ref max_flow "maximum flow problem".
     475*/
     476
     477/**
     478@defgroup graph_properties Connectivity and Other Graph Properties
    289479@ingroup algs
    290480\brief Algorithms for discovering the graph properties
    291481
    292 This group describes the algorithms for discovering the graph properties
     482This group contains the algorithms for discovering the graph properties
    293483like connectivity, bipartiteness, euler property, simplicity etc.
    294484
     
    302492\brief Algorithms for planarity checking, embedding and drawing
    303493
    304 This group describes the algorithms for planarity checking,
     494This group contains the algorithms for planarity checking,
    305495embedding and drawing.
    306496
     
    314504\brief Algorithms for finding matchings in graphs and bipartite graphs.
    315505
    316 This group contains algorithm objects and functions to calculate
     506This group contains the algorithms for calculating
    317507matchings in graphs and bipartite graphs. The general matching problem is
    318 finding a subset of the arcs which does not shares common endpoints.
     508finding a subset of the edges for which each node has at most one incident
     509edge.
    319510
    320511There are several different algorithms for calculate matchings in
    321512graphs.  The matching problems in bipartite graphs are generally
    322513easier than in general graphs. The goal of the matching optimization
    323 can be the finding maximum cardinality, maximum weight or minimum cost
     514can be finding maximum cardinality, maximum weight or minimum cost
    324515matching. The search can be constrained to find perfect or
    325516maximum cardinality matching.
    326517
    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
     518The 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.
    347536
    348537\image html bipartite_matching.png
     
    355544\brief Algorithms for finding a minimum cost spanning tree in a graph.
    356545
    357 This group describes the algorithms for finding a minimum cost spanning
    358 tree in a graph
     546This group contains the algorithms for finding a minimum cost spanning
     547tree in a graph.
    359548*/
    360549
     
    364553\brief Auxiliary algorithms implemented in LEMON.
    365554
    366 This group describes some algorithms implemented in LEMON
     555This group contains some algorithms implemented in LEMON
    367556in order to make it easier to implement complex algorithms.
    368557*/
     
    373562\brief Approximation algorithms.
    374563
    375 This group describes the approximation and heuristic algorithms
     564This group contains the approximation and heuristic algorithms
    376565implemented in LEMON.
    377566*/
     
    379568/**
    380569@defgroup gen_opt_group General Optimization Tools
    381 \brief This group describes some general optimization frameworks
     570\brief This group contains some general optimization frameworks
    382571implemented in LEMON.
    383572
    384 This group describes some general optimization frameworks
     573This group contains some general optimization frameworks
    385574implemented in LEMON.
    386575*/
     
    391580\brief Lp and Mip solver interfaces for LEMON.
    392581
    393 This group describes Lp and Mip solver interfaces for LEMON. The
     582This group contains Lp and Mip solver interfaces for LEMON. The
    394583various LP solvers could be used in the same manner with this
    395584interface.
     
    410599\brief Metaheuristics for LEMON library.
    411600
    412 This group describes some metaheuristic optimization tools.
     601This group contains some metaheuristic optimization tools.
    413602*/
    414603
     
    425614\brief Simple basic graph utilities.
    426615
    427 This group describes some simple basic graph utilities.
     616This group contains some simple basic graph utilities.
    428617*/
    429618
     
    433622\brief Tools for development, debugging and testing.
    434623
    435 This group describes several useful tools for development,
     624This group contains several useful tools for development,
    436625debugging and testing.
    437626*/
     
    442631\brief Simple tools for measuring the performance of algorithms.
    443632
    444 This group describes simple tools for measuring the performance
     633This group contains simple tools for measuring the performance
    445634of algorithms.
    446635*/
     
    451640\brief Exceptions defined in LEMON.
    452641
    453 This group describes the exceptions defined in LEMON.
     642This group contains the exceptions defined in LEMON.
    454643*/
    455644
     
    458647\brief Graph Input-Output methods
    459648
    460 This group describes the tools for importing and exporting graphs
     649This group contains the tools for importing and exporting graphs
    461650and graph related data. Now it supports the \ref lgf-format
    462651"LEMON Graph Format", the \c DIMACS format and the encapsulated
     
    465654
    466655/**
    467 @defgroup lemon_io LEMON Input-Output
     656@defgroup lemon_io LEMON Graph Format
    468657@ingroup io_group
    469658\brief Reading and writing LEMON Graph Format.
    470659
    471 This group describes methods for reading and writing
     660This group contains methods for reading and writing
    472661\ref lgf-format "LEMON Graph Format".
    473662*/
     
    478667\brief General \c EPS drawer and graph exporter
    479668
    480 This group describes general \c EPS drawing methods and special
     669This group contains general \c EPS drawing methods and special
    481670graph 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
     678Tools 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
     686Tool to read graphs from \e Nauty format data.
    482687*/
    483688
     
    486691\brief Skeleton classes and concept checking classes
    487692
    488 This group describes the data/algorithm skeletons and concept checking
     693This group contains the data/algorithm skeletons and concept checking
    489694classes implemented in LEMON.
    490695
     
    516721\brief Skeleton and concept checking classes for graph structures
    517722
    518 This group describes the skeletons and concept checking classes of LEMON's
     723This group contains the skeletons and concept checking classes of LEMON's
    519724graph structures and helper classes used to implement these.
    520725*/
     
    525730\brief Skeleton and concept checking classes for maps
    526731
    527 This group describes the skeletons and concept checking classes of maps.
     732This group contains the skeletons and concept checking classes of maps.
    528733*/
    529734
     
    531736\anchor demoprograms
    532737
    533 @defgroup demos Demo programs
     738@defgroup demos Demo Programs
    534739
    535740Some demo programs are listed here. Their full source codes can be found in
    536741the \c demo subdirectory of the source tree.
    537742
    538 It order to compile them, use <tt>--enable-demo</tt> configure option when
    539 build the library.
    540 */
    541 
    542 /**
    543 @defgroup tools Standalone utility applications
     743In 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
    544749
    545750Some utility applications are listed here.
     
    549754*/
    550755
     756}
  • doc/lgf.dox

    r313 r463  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
  • doc/license.dox

    r209 r463  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
  • doc/mainpage.dox

    r314 r606  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    4646"Quick Tour to LEMON" which will guide you along.
    4747
    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".
     48If you already feel like using our library, see the
     49<a class="el" href="http://lemon.cs.elte.hu/pub/tutorial/">LEMON Tutorial</a>.
    5450
    5551If 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.
    5853
    5954If you are a user of the old (0.x) series of LEMON, please check out the
  • doc/migration.dox

    r314 r463  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    2626
    2727Many of these changes adjusted automatically by the
    28 <tt>script/lemon-0.x-to-1.x.sh</tt> tool. Those requiring manual
     28<tt>lemon-0.x-to-1.x.sh</tt> tool. Those requiring manual
    2929update are typeset <b>boldface</b>.
    3030
     
    5454
    5555\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
     58strings, comments etc. as well as in all LEMON specific identifiers.
     59So use the script carefully and make a backup copy of your source files
     60before applying the script to them.</b>
    5961
    6062\section migration-lgf LGF tools
  • doc/named-param.dox

    r269 r463  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
  • doc/namespaces.dox

    r209 r463  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
  • doc/template.h

    r209 r463  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
  • lemon/CMakeLists.txt

    r511 r674  
    1 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
     1INCLUDE_DIRECTORIES(
     2  ${PROJECT_SOURCE_DIR}
     3  ${PROJECT_BINARY_DIR}
     4)
    25
    3 ADD_LIBRARY(lemon
     6CONFIGURE_FILE(
     7  ${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake
     8  ${CMAKE_CURRENT_BINARY_DIR}/config.h
     9)
     10
     11SET(LEMON_SOURCES
    412  arg_parser.cc
    513  base.cc
    614  color.cc
     15  lp_base.cc
     16  lp_skeleton.cc
    717  random.cc
    818  bits/windows.cc
    919)
     20
     21IF(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)
     29ENDIF(LEMON_HAVE_GLPK)
     30
     31IF(LEMON_HAVE_CPLEX)
     32  SET(LEMON_SOURCES ${LEMON_SOURCES} cplex.cc)
     33  INCLUDE_DIRECTORIES(${CPLEX_INCLUDE_DIRS})
     34ENDIF(LEMON_HAVE_CPLEX)
     35
     36IF(LEMON_HAVE_CLP)
     37  SET(LEMON_SOURCES ${LEMON_SOURCES} clp.cc)
     38  INCLUDE_DIRECTORIES(${COIN_INCLUDE_DIRS})
     39ENDIF(LEMON_HAVE_CLP)
     40
     41IF(LEMON_HAVE_CBC)
     42  SET(LEMON_SOURCES ${LEMON_SOURCES} cbc.cc)
     43  INCLUDE_DIRECTORIES(${COIN_INCLUDE_DIRS})
     44ENDIF(LEMON_HAVE_CBC)
     45
     46ADD_LIBRARY(lemon ${LEMON_SOURCES})
    1047
    1148INSTALL(
     
    1956  COMPONENT headers
    2057  FILES_MATCHING PATTERN "*.h")
     58
     59INSTALL(
     60  FILES ${CMAKE_CURRENT_BINARY_DIR}/config.h
     61  DESTINATION include/lemon
     62  COMPONENT headers)
  • lemon/Makefile.am

    r511 r674  
    88
    99lemon_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 \
    1416        lemon/bits/windows.cc
    1517
    16 #lemon_libemon_la_CXXFLAGS = $(GLPK_CFLAGS) $(CPLEX_CFLAGS) $(SOPLEX_CXXFLAGS)
    17 #lemon_libemon_la_LDFLAGS = $(GLPK_LIBS) $(CPLEX_LIBS) $(SOPLEX_LIBS)
     18
     19lemon_libemon_la_CXXFLAGS = \
     20        $(AM_CXXFLAGS) \
     21        $(GLPK_CFLAGS) \
     22        $(CPLEX_CFLAGS) \
     23        $(SOPLEX_CXXFLAGS) \
     24        $(CLP_CXXFLAGS) \
     25        $(CBC_CXXFLAGS)
     26
     27lemon_libemon_la_LDFLAGS = \
     28        $(GLPK_LIBS) \
     29        $(CPLEX_LIBS) \
     30        $(SOPLEX_LIBS) \
     31        $(CLP_LIBS) \
     32        $(CBC_LIBS)
     33
     34if HAVE_GLPK
     35lemon_libemon_la_SOURCES += lemon/glpk.cc
     36endif
     37
     38if HAVE_CPLEX
     39lemon_libemon_la_SOURCES += lemon/cplex.cc
     40endif
     41
     42if HAVE_SOPLEX
     43lemon_libemon_la_SOURCES += lemon/soplex.cc
     44endif
     45
     46if HAVE_CLP
     47lemon_libemon_la_SOURCES += lemon/clp.cc
     48endif
     49
     50if HAVE_CBC
     51lemon_libemon_la_SOURCES += lemon/cbc.cc
     52endif
    1853
    1954lemon_HEADERS += \
    20         lemon/arg_parser.h \
     55        lemon/adaptors.h \
     56        lemon/arg_parser.h \
    2157        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 \
    2563        lemon/concept_check.h \
    26         lemon/counter.h \
     64        lemon/config.h \
     65        lemon/connectivity.h \
     66        lemon/counter.h \
    2767        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 \
    3175        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 \
    3383        lemon/kruskal.h \
     84        lemon/hao_orlin.h \
    3485        lemon/lgf_reader.h \
    3586        lemon/lgf_writer.h \
    3687        lemon/list_graph.h \
     88        lemon/lp.h \
     89        lemon/lp_base.h \
     90        lemon/lp_skeleton.h \
     91        lemon/list_graph.h \
    3792        lemon/maps.h \
     93        lemon/matching.h \
    3894        lemon/math.h \
     95        lemon/min_cost_arborescence.h \
     96        lemon/nauty_reader.h \
     97        lemon/network_simplex.h \
    3998        lemon/path.h \
    40         lemon/random.h \
     99        lemon/preflow.h \
     100        lemon/radix_sort.h \
     101        lemon/random.h \
    41102        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 \
    44107        lemon/unionfind.h \
    45108        lemon/bits/windows.h
     
    49112        lemon/bits/array_map.h \
    50113        lemon/bits/base_extender.h \
    51         lemon/bits/bezier.h \
     114        lemon/bits/bezier.h \
    52115        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 \
    54119        lemon/bits/graph_extender.h \
    55120        lemon/bits/map_extender.h \
    56121        lemon/bits/path_dump.h \
     122        lemon/bits/solver_bits.h \
    57123        lemon/bits/traits.h \
     124        lemon/bits/variant.h \
    58125        lemon/bits/vector_map.h
    59126
  • lemon/arg_parser.cc

    r311 r463  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
  • lemon/arg_parser.h

    r311 r463  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
  • lemon/assert.h

    r290 r463  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
  • lemon/base.cc

    r220 r554  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    2424namespace lemon {
    2525
    26   float Tolerance<float>::def_epsilon = 1e-4;
     26  float Tolerance<float>::def_epsilon = static_cast<float>(1e-4);
    2727  double Tolerance<double>::def_epsilon = 1e-10;
    2828  long double Tolerance<long double>::def_epsilon = 1e-14;
  • lemon/bfs.h

    r301 r525  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    5050    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
    5151    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.
    5555    ///\param g is the digraph, to which we would like to define the
    56     ///PredMap.
     56    ///\ref PredMap.
    5757    static PredMap *createPredMap(const Digraph &g)
    5858    {
     
    6565    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
    6666    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.
    7070    ///\param g is the digraph, to which
    71     ///we would like to define the ProcessedMap
     71    ///we would like to define the \ref ProcessedMap
    7272#ifdef DOXYGEN
    7373    static ProcessedMap *createProcessedMap(const Digraph &g)
     
    8484    ///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
    8585    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.
    8989    ///\param g is the digraph, to which
    90     ///we would like to define the ReachedMap.
     90    ///we would like to define the \ref ReachedMap.
    9191    static ReachedMap *createReachedMap(const Digraph &g)
    9292    {
     
    9999    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
    100100    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.
    104104    ///\param g is the digraph, to which we would like to define the
    105     ///DistMap.
     105    ///\ref DistMap.
    106106    static DistMap *createDistMap(const Digraph &g)
    107107    {
     
    120120  ///
    121121  ///\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.
    129123#ifdef DOXYGEN
    130124  template <typename GR,
     
    152146    typedef PredMapPath<Digraph, PredMap> Path;
    153147
    154     ///The traits class.
     148    ///The \ref BfsDefaultTraits "traits class" of the algorithm.
    155149    typedef TR Traits;
    156150
     
    214208    typedef Bfs Create;
    215209
    216     ///\name Named template parameters
     210    ///\name Named Template Parameters
    217211
    218212    ///@{
     
    228222    };
    229223    ///\brief \ref named-templ-param "Named parameter" for setting
    230     ///PredMap type.
     224    ///\c PredMap type.
    231225    ///
    232226    ///\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.
    234229    template <class T>
    235230    struct SetPredMap : public Bfs< Digraph, SetPredMapTraits<T> > {
     
    247242    };
    248243    ///\brief \ref named-templ-param "Named parameter" for setting
    249     ///DistMap type.
     244    ///\c DistMap type.
    250245    ///
    251246    ///\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.
    253249    template <class T>
    254250    struct SetDistMap : public Bfs< Digraph, SetDistMapTraits<T> > {
     
    266262    };
    267263    ///\brief \ref named-templ-param "Named parameter" for setting
    268     ///ReachedMap type.
     264    ///\c ReachedMap type.
    269265    ///
    270266    ///\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.
    272269    template <class T>
    273270    struct SetReachedMap : public Bfs< Digraph, SetReachedMapTraits<T> > {
     
    285282    };
    286283    ///\brief \ref named-templ-param "Named parameter" for setting
    287     ///ProcessedMap type.
     284    ///\c ProcessedMap type.
    288285    ///
    289286    ///\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.
    291289    template <class T>
    292290    struct SetProcessedMap : public Bfs< Digraph, SetProcessedMapTraits<T> > {
     
    303301    };
    304302    ///\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>.
    306304    ///
    307305    ///\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>.
    309307    ///If you don't set it explicitly, it will be automatically allocated.
    310308    struct SetStandardProcessedMap :
     
    341339
    342340    ///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.
    346345    ///\return <tt> (*this) </tt>
    347346    Bfs &predMap(PredMap &m)
     
    358357
    359358    ///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.
    363363    ///\return <tt> (*this) </tt>
    364364    Bfs &reachedMap(ReachedMap &m)
     
    375375
    376376    ///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.
    380381    ///\return <tt> (*this) </tt>
    381382    Bfs &processedMap(ProcessedMap &m)
     
    393394    ///Sets the map that stores the distances of the nodes calculated by
    394395    ///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.
    398400    ///\return <tt> (*this) </tt>
    399401    Bfs &distMap(DistMap &m)
     
    409411  public:
    410412
    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.
    420420
    421421    ///@{
    422422
     423    ///\brief Initializes the internal data structures.
     424    ///
    423425    ///Initializes the internal data structures.
    424 
    425     ///Initializes the internal data structures.
    426     ///
    427426    void init()
    428427    {
     
    558557    }
    559558
    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.
    565563    bool emptyQueue() const { return _queue_tail==_queue_head; }
    566564
    567565    ///Returns the number of the nodes to be processed.
    568566
    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.
    570569    int queueSize() const { return _queue_head-_queue_tail; }
    571570
     
    732731
    733732    ///\name Query Functions
    734     ///The result of the %BFS algorithm can be obtained using these
     733    ///The results of the BFS algorithm can be obtained using these
    735734    ///functions.\n
    736     ///Either \ref lemon::Bfs::run() "run()" or \ref lemon::Bfs::start()
    737     ///"start()" must be called before using them.
     735    ///Either \ref run(Node) "run()" or \ref start() should be called
     736    ///before using them.
    738737
    739738    ///@{
     
    743742    ///Returns the shortest path to a node.
    744743    ///
    745     ///\warning \c t should be reachable from the root(s).
    746     ///
    747     ///\pre Either \ref run() or \ref start() must be called before
    748     ///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.
    749748    Path path(Node t) const { return Path(*G, *_pred, t); }
    750749
     
    753752    ///Returns the distance of a node from the root(s).
    754753    ///
    755     ///\warning If node \c v is not reachable from the root(s), then
     754    ///\warning If node \c v is not reached from the root(s), then
    756755    ///the return value of this function is undefined.
    757756    ///
    758     ///\pre Either \ref run() or \ref start() must be called before
    759     ///using this function.
     757    ///\pre Either \ref run(Node) "run()" or \ref init()
     758    ///must be called before using this function.
    760759    int dist(Node v) const { return (*_dist)[v]; }
    761760
     
    764763    ///This function returns the 'previous arc' of the shortest path
    765764    ///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 v
    767     ///is not reachable from 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.
    768767    ///
    769768    ///The shortest path tree used here is equal to the shortest path
    770769    ///tree used in \ref predNode().
    771770    ///
    772     ///\pre Either \ref run() or \ref start() must be called before
    773     ///using this function.
     771    ///\pre Either \ref run(Node) "run()" or \ref init()
     772    ///must be called before using this function.
    774773    Arc predArc(Node v) const { return (*_pred)[v];}
    775774
     
    778777    ///This function returns the 'previous node' of the shortest path
    779778    ///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 INVALID
    781     ///if \c v is not reachable from 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.
    782781    ///
    783782    ///The shortest path tree used here is equal to the shortest path
    784783    ///tree used in \ref predArc().
    785784    ///
    786     ///\pre Either \ref run() or \ref start() must be called before
    787     ///using this function.
     785    ///\pre Either \ref run(Node) "run()" or \ref init()
     786    ///must be called before using this function.
    788787    Node predNode(Node v) const { return (*_pred)[v]==INVALID ? INVALID:
    789788                                  G->source((*_pred)[v]); }
     
    795794    ///of the nodes calculated by the algorithm.
    796795    ///
    797     ///\pre Either \ref run() or \ref init()
     796    ///\pre Either \ref run(Node) "run()" or \ref init()
    798797    ///must be called before using this function.
    799798    const DistMap &distMap() const { return *_dist;}
     
    805804    ///arcs, which form the shortest path tree.
    806805    ///
    807     ///\pre Either \ref run() or \ref init()
     806    ///\pre Either \ref run(Node) "run()" or \ref init()
    808807    ///must be called before using this function.
    809808    const PredMap &predMap() const { return *_pred;}
    810809
    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()
    815815    ///must be called before using this function.
    816816    bool reached(Node v) const { return (*_reached)[v]; }
     
    958958  /// This auxiliary class is created to implement the
    959959  /// \ref bfs() "function-type interface" of \ref Bfs algorithm.
    960   /// It does not have own \ref run() method, it uses the functions
    961   /// 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.
    962962  ///
    963963  /// This class should only be used through the \ref bfs() function,
     
    11791179  ///  bool reached = bfs(g).path(p).dist(d).run(s,t);
    11801180  ///\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()"
    11821182  ///to the end of the parameter list.
    11831183  ///\sa BfsWizard
     
    11951195  /// This class defines the interface of the BfsVisit events, and
    11961196  /// it could be the base of a real visitor class.
    1197   template <typename _Digraph>
     1197  template <typename GR>
    11981198  struct BfsVisitor {
    1199     typedef _Digraph Digraph;
     1199    typedef GR Digraph;
    12001200    typedef typename Digraph::Arc Arc;
    12011201    typedef typename Digraph::Node Node;
     
    12251225  };
    12261226#else
    1227   template <typename _Digraph>
     1227  template <typename GR>
    12281228  struct BfsVisitor {
    1229     typedef _Digraph Digraph;
     1229    typedef GR Digraph;
    12301230    typedef typename Digraph::Arc Arc;
    12311231    typedef typename Digraph::Node Node;
     
    12551255  ///
    12561256  /// Default traits class of BfsVisit class.
    1257   /// \tparam _Digraph The 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>
    12591259  struct BfsVisitDefaultTraits {
    12601260
    12611261    /// \brief The type of the digraph the algorithm runs on.
    1262     typedef _Digraph Digraph;
     1262    typedef GR Digraph;
    12631263
    12641264    /// \brief The type of the map that indicates which nodes are reached.
     
    12811281  /// \ingroup search
    12821282  ///
    1283   /// \brief %BFS algorithm class with visitor interface.
     1283  /// \brief BFS algorithm class with visitor interface.
    12841284  ///
    1285   /// This class provides an efficient implementation of the %BFS algorithm
     1285  /// This class provides an efficient implementation of the BFS algorithm
    12861286  /// with visitor interface.
    12871287  ///
    1288   /// The %BfsVisit class provides an alternative interface to the Bfs
     1288  /// The BfsVisit class provides an alternative interface to the Bfs
    12891289  /// class. It works with callback mechanism, the BfsVisit object calls
    12901290  /// the member functions of the \c Visitor class on every BFS event.
     
    12951295  /// instead.
    12961296  ///
    1297   /// \tparam _Digraph The type of the digraph the algorithm runs on.
    1298   /// The default value is
    1299   /// \ref ListDigraph. The value of _Digraph is not used directly by
    1300   /// \ref BfsVisit, it is only passed to \ref BfsVisitDefaultTraits.
    1301   /// \tparam _Visitor The Visitor type that is used by the algorithm.
    1302   /// \ref BfsVisitor "BfsVisitor<_Digraph>" is an empty visitor, which
     1297  /// \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
    13031303  /// does not observe the BFS events. If you want to observe the BFS
    13041304  /// events, you should implement your own visitor class.
    1305   /// \tparam _Traits Traits class to set various data types used by the
     1305  /// \tparam TR Traits class to set various data types used by the
    13061306  /// algorithm. The default traits class is
    1307   /// \ref BfsVisitDefaultTraits "BfsVisitDefaultTraits<_Digraph>".
     1307  /// \ref BfsVisitDefaultTraits "BfsVisitDefaultTraits<GR>".
    13081308  /// See \ref BfsVisitDefaultTraits for the documentation of
    13091309  /// a BFS visit traits class.
    13101310#ifdef DOXYGEN
    1311   template <typename _Digraph, typename _Visitor, typename _Traits>
     1311  template <typename GR, typename VS, typename TR>
    13121312#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> >
    13161316#endif
    13171317  class BfsVisit {
     
    13191319
    13201320    ///The traits class.
    1321     typedef _Traits Traits;
     1321    typedef TR Traits;
    13221322
    13231323    ///The type of the digraph the algorithm runs on.
     
    13251325
    13261326    ///The visitor type used by the algorithm.
    1327     typedef _Visitor Visitor;
     1327    typedef VS Visitor;
    13281328
    13291329    ///The type of the map that indicates which nodes are reached.
     
    13651365    typedef BfsVisit Create;
    13661366
    1367     /// \name Named template parameters
     1367    /// \name Named Template Parameters
    13681368
    13691369    ///@{
     
    14071407    ///
    14081408    /// 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.
    14121413    /// \return <tt> (*this) </tt>
    14131414    BfsVisit &reachedMap(ReachedMap &m) {
     
    14221423  public:
    14231424
    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.
    14341432
    14351433    /// @{
     
    17311729
    17321730    /// \name Query Functions
    1733     /// The result of the %BFS algorithm can be obtained using these
     1731    /// The results of the BFS algorithm can be obtained using these
    17341732    /// functions.\n
    1735     /// Either \ref lemon::BfsVisit::run() "run()" or
    1736     /// \ref lemon::BfsVisit::start() "start()" must be called before
    1737     /// using them.
     1733    /// Either \ref run(Node) "run()" or \ref start() should be called
     1734    /// before using them.
     1735
    17381736    ///@{
    17391737
    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()
    17441743    /// must be called before using this function.
    1745     bool reached(Node v) { return (*_reached)[v]; }
     1744    bool reached(Node v) const { return (*_reached)[v]; }
    17461745
    17471746    ///@}
  • lemon/bin_heap.h

    r209 r631  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    3434  ///\brief A Binary Heap implementation.
    3535  ///
    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.
    4143  ///
    42   ///\tparam _Prio Type of the priority of the items.
    43   ///\tparam _ItemIntMap A read and writable Item int map, used internally
     44  ///\tparam PR Type of the priority of the items.
     45  ///\tparam IM A read and writable item map with int values, used internally
    4446  ///to handle the cross references.
    45   ///\tparam _Compare A class for the ordering of the priorities. The
    46   ///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>.
    4749  ///
    4850  ///\sa FibHeap
    4951  ///\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> >
    5253  class BinHeap {
    5354
    5455  public:
    5556    ///\e
    56     typedef _ItemIntMap ItemIntMap;
    57     ///\e
    58     typedef _Prio Prio;
     57    typedef IM ItemIntMap;
     58    ///\e
     59    typedef PR Prio;
    5960    ///\e
    6061    typedef typename ItemIntMap::Key Item;
     
    6263    typedef std::pair<Item,Prio> Pair;
    6364    ///\e
    64     typedef _Compare Compare;
     65    typedef Comp Compare;
    6566
    6667    /// \brief Type to represent the items states.
     
    7071    /// heap's point of view, but may be useful to the user.
    7172    ///
    72     /// The ItemIntMap \e should be initialized in such way that it maps
    73     /// 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.
    7475    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.
    7879    };
    7980
    8081  private:
    81     std::vector<Pair> data;
    82     Compare comp;
    83     ItemIntMap &iim;
     82    std::vector<Pair> _data;
     83    Compare _comp;
     84    ItemIntMap &_iim;
    8485
    8586  public:
     
    8788    ///
    8889    /// 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
    9099    /// internally to handle the cross references. The value of the map
    91100    /// 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) {}
    104105
    105106
     
    107108    ///
    108109    /// \brief Returns the number of items stored in the heap.
    109     int size() const { return data.size(); }
     110    int size() const { return _data.size(); }
    110111
    111112    /// \brief Checks if the heap stores no items.
    112113    ///
    113114    /// 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(); }
    115116
    116117    /// \brief Make empty this heap.
     
    121122    /// each item to \c PRE_HEAP.
    122123    void clear() {
    123       data.clear();
     124      _data.clear();
    124125    }
    125126
     
    129130    static int second_child(int i) { return 2*i+2; }
    130131    bool less(const Pair &p1, const Pair &p2) const {
    131       return comp(p1.second, p2.second);
     132      return _comp(p1.second, p2.second);
    132133    }
    133134
    134135    int bubble_up(int hole, Pair p) {
    135136      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);
    138139        hole = par;
    139140        par = parent(hole);
     
    146147      int child = second_child(hole);
    147148      while(child < length) {
    148         if( less(data[child-1], data[child]) ) {
     149        if( less(_data[child-1], _data[child]) ) {
    149150          --child;
    150151        }
    151         if( !less(data[child], p) )
     152        if( !less(_data[child], p) )
    152153          goto ok;
    153         move(data[child], hole);
     154        move(_data[child], hole);
    154155        hole = child;
    155156        child = second_child(hole);
    156157      }
    157158      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);
    160161        hole=child;
    161162      }
     
    166167
    167168    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);
    170171    }
    171172
     
    176177    /// \param p The pair to insert.
    177178    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);
    180181      bubble_up(n, p);
    181182    }
     
    194195    /// \pre The heap must be nonempty.
    195196    Item top() const {
    196       return data[0].first;
     197      return _data[0].first;
    197198    }
    198199
     
    202203    /// \pre The heap must be nonempty.
    203204    Prio prio() const {
    204       return data[0].second;
     205      return _data[0].second;
    205206    }
    206207
     
    211212    /// \pre The heap must be non-empty.
    212213    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);
    215216      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();
    219220    }
    220221
     
    225226    /// \pre The item should be in the heap.
    226227    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);
    230231      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);
    233234        }
    234235      }
    235       data.pop_back();
     236      _data.pop_back();
    236237    }
    237238
     
    240241    ///
    241242    /// This function returns the priority of item \c i.
     243    /// \param i The item.
    242244    /// \pre \c i must be in the heap.
    243     /// \param i The item.
    244245    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;
    247248    }
    248249
     
    255256    /// \param p The priority.
    256257    void set(const Item &i, const Prio &p) {
    257       int idx = iim[i];
     258      int idx = _iim[i];
    258259      if( idx < 0 ) {
    259260        push(i,p);
    260261      }
    261       else if( comp(p, data[idx].second) ) {
     262      else if( _comp(p, _data[idx].second) ) {
    262263        bubble_up(idx, Pair(i,p));
    263264      }
    264265      else {
    265         bubble_down(idx, Pair(i,p), data.size());
     266        bubble_down(idx, Pair(i,p), _data.size());
    266267      }
    267268    }
     
    270271    ///
    271272    /// This method decreases the priority of item \c i to \c p.
     273    /// \param i The item.
     274    /// \param p The priority.
    272275    /// \pre \c i must be stored in the heap with priority at least \c
    273276    /// 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.
    274285    /// \param i The item.
    275286    /// \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.
    284287    /// \pre \c i must be stored in the heap with priority at most \c
    285288    /// p relative to \c Compare.
    286     /// \param i The item.
    287     /// \param p The priority.
    288289    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());
    291292    }
    292293
     
    300301    /// \param i The item.
    301302    State state(const Item &i) const {
    302       int s = iim[i];
     303      int s = _iim[i];
    303304      if( s>=0 )
    304305        s=0;
     
    320321          erase(i);
    321322        }
    322         iim[i] = st;
     323        _iim[i] = st;
    323324        break;
    324325      case IN_HEAP:
     
    334335    /// with the same prioriority as prevoiusly the \c i item.
    335336    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;
    340341    }
    341342
  • lemon/bits/alteration_notifier.h

    r314 r463  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    3636  // a container.
    3737  //
    38   // The simple graph's can be refered as two containers, one node container
    39   // and one edge container. But they are not standard containers they
    40   // does not store values directly they are just key continars for more
    41   // value containers which are the node and edge maps.
    42   //
    43   // The graph's node and edge sets can be changed as we add or erase
     38  // 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
    4444  // nodes and edges in the graph. LEMON would like to handle easily
    4545  // that the node and edge maps should contain values for all nodes or
    4646  // edges. If we want to check on every indicing if the map contains
    4747  // the current indicing key that cause a drawback in the performance
    48   // in the library. We use another solution we notify all maps about
     48  // in the library. We use another solution: we notify all maps about
    4949  // an alteration in the graph, which cause only drawback on the
    5050  // alteration of the graph.
    5151  //
    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.
    5657  //
    5758  // For the proper functonality of this class, we should notify it
    58   // about each alteration in the container. The alterations have four type
    59   // as \e add(), \e erase(), \e build() and \e clear(). The \e add() and
    60   // \e erase() signals that only one or few items added or erased to or
    61   // from the graph. If all items are erased from the graph or from an empty
    62   // graph a new graph is builded then it can be signaled with the
     59  // 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
    6364  // clear() and build() members. Important rule that if we erase items
    64   // from graph we should first signal the alteration and after that erase
     65  // from graphs we should first signal the alteration and after that erase
    6566  // them from the container, on the other way on item addition we should
    6667  // first extend the container and just after that signal the alteration.
    6768  //
    6869  // The alteration can be observed with a class inherited from the
    69   // \e ObserverBase nested class. The signals can be handled with
     70  // ObserverBase nested class. The signals can be handled with
    7071  // overriding the virtual functions defined in the base class.  The
    7172  // observer base can be attached to the notifier with the
    72   // \e attach() member and can be detached with detach() function. The
     73  // attach() member and can be detached with detach() function. The
    7374  // alteration handlers should not call any function which signals
    7475  // an other alteration in the same notifier and should not
    7576  // detach any observer from the notifier.
    7677  //
    77   // Alteration observers try to be exception safe. If an \e add() or
    78   // a \e clear() function throws an exception then the remaining
     78  // Alteration observers try to be exception safe. If an add() or
     79  // a clear() function throws an exception then the remaining
    7980  // 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 throw
    82   // exception. Actullay, it can be throw only \ref ImmediateDetach
    83   // exception which detach the observer from the notifier.
    84   //
    85   // There are some place when the alteration observing is not completly
     81  // 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
    8687  // reliable. If we want to carry out the node degree in the graph
    87   // as in the \ref InDegMap and we use the reverseEdge that cause
     88  // as in the \ref InDegMap and we use the reverseArc(), then it cause
    8889  // unreliable functionality. Because the alteration observing signals
    89   // only erasing and adding but not the reversing it will stores bad
    90   // degrees. The sub graph adaptors cannot signal the alterations because
    91   // just a setting in the filter map can modify the graph and this cannot
    92   // 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.
    9394  //
    9495  // \param _Container The container which is observed.
     
    104105    typedef _Item Item;
    105106
    106     // \brief Exception which can be called from \e clear() and
    107     // \e erase().
    108     //
    109     // From the \e clear() and \e erase() function only this
     107    // \brief Exception which can be called from clear() and
     108    // erase().
     109    //
     110    // From the clear() and erase() function only this
    110111    // exception is allowed to throw. The exception immediatly
    111112    // detaches the current observer from the notifier. Because the
    112     // \e clear() and \e erase() should not throw other exceptions
     113    // clear() and erase() should not throw other exceptions
    113114    // it can be used to invalidate the observer.
    114115    struct ImmediateDetach {};
     
    122123    // The observer interface contains some pure virtual functions
    123124    // 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.
    126126    //
    127127    // The build() and clear() members are to notify the observer
  • lemon/bits/array_map.h

    r314 r664  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    3737  // \brief Graph map based on the array storage.
    3838  //
    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.
    4342  //
    44   // The template parameters are the Graph the current Item type and
     43  // The template parameters are the Graph, the current Item type and
    4544  // the Value type of the map.
    4645  template <typename _Graph, typename _Item, typename _Value>
     
    4847    : public ItemSetTraits<_Graph, _Item>::ItemNotifier::ObserverBase {
    4948  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.
    5352    typedef _Item Item;
    5453    // The reference map tag.
    5554    typedef True ReferenceMapTag;
    5655
    57     // The key type of the maps.
     56    // The key type of the map.
    5857    typedef _Item Key;
    5958    // The value type of the map.
     
    6564    typedef _Value& Reference;
    6665
     66    // The map type.
     67    typedef ArrayMap Map;
     68
    6769    // The notifier type.
    6870    typedef typename ItemSetTraits<_Graph, _Item>::ItemNotifier Notifier;
    6971
     72  private:
     73 
    7074    // The MapBase of the Map which imlements the core regisitry function.
    7175    typedef typename Notifier::ObserverBase Parent;
    7276
    73   private:
    7477    typedef std::allocator<Value> Allocator;
    7578
     
    7982    //
    8083    // Graph initialized map constructor.
    81     explicit ArrayMap(const Graph& graph) {
     84    explicit ArrayMap(const GraphType& graph) {
    8285      Parent::attach(graph.notifier(Item()));
    8386      allocate_memory();
     
    9396    //
    9497    // 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) {
    9699      Parent::attach(graph.notifier(Item()));
    97100      allocate_memory();
     
    137140    // \brief Template assign operator.
    138141    //
    139     // The given parameter should be conform to the ReadMap
     142    // The given parameter should conform to the ReadMap
    140143    // concecpt and could be indiced by the current item set of
    141144    // the NodeMap. In this case the value for each item
     
    201204    // \brief Adds a new key to the map.
    202205    //
    203     // It adds a new key to the map. It called by the observer notifier
     206    // It adds a new key to the map. It is called by the observer notifier
    204207    // and it overrides the add() member function of the observer base.
    205208    virtual void add(const Key& key) {
     
    229232    // \brief Adds more new keys to the map.
    230233    //
    231     // It adds more new keys to the map. It called by the observer notifier
     234    // It adds more new keys to the map. It is called by the observer notifier
    232235    // and it overrides the add() member function of the observer base.
    233236    virtual void add(const std::vector<Key>& keys) {
     
    273276    // \brief Erase a key from the map.
    274277    //
    275     // Erase a key from the map. It called by the observer notifier
     278    // Erase a key from the map. It is called by the observer notifier
    276279    // and it overrides the erase() member function of the observer base.
    277280    virtual void erase(const Key& key) {
     
    282285    // \brief Erase more keys from the map.
    283286    //
    284     // Erase more keys from the map. It called by the observer notifier
     287    // Erase more keys from the map. It is called by the observer notifier
    285288    // and it overrides the erase() member function of the observer base.
    286289    virtual void erase(const std::vector<Key>& keys) {
     
    291294    }
    292295
    293     // \brief Buildes the map.
    294     //
    295     // It buildes the map. It called by the observer notifier
     296    // \brief Builds the map.
     297    //
     298    // It builds the map. It is called by the observer notifier
    296299    // and it overrides the build() member function of the observer base.
    297300    virtual void build() {
     
    307310    // \brief Clear the map.
    308311    //
    309     // It erase all items from the map. It called by the observer notifier
     312    // It erase all items from the map. It is called by the observer notifier
    310313    // and it overrides the clear() member function of the observer base.
    311314    virtual void clear() {
  • lemon/bits/base_extender.h

    r314 r664  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    3131//\ingroup digraphbits
    3232//\file
    33 //\brief Extenders for the digraph types
     33//\brief Extenders for the graph types
    3434namespace lemon {
    3535
     
    3939  template <typename Base>
    4040  class UndirDigraphExtender : public Base {
     41    typedef Base Parent;
    4142
    4243  public:
    4344
    44     typedef Base Parent;
    4545    typedef typename Parent::Arc Edge;
    4646    typedef typename Parent::Node Node;
     
    281281  template <typename Base>
    282282  class BidirBpGraphExtender : public Base {
     283    typedef Base Parent;
     284
    283285  public:
    284     typedef Base Parent;
    285286    typedef BidirBpGraphExtender Digraph;
    286287
  • lemon/bits/bezier.h

    r314 r463  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
  • lemon/bits/default_map.h

    r523 r674  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    9898
    9999
    100 #if defined HAVE_LONG_LONG
     100#if defined LEMON_HAVE_LONG_LONG
    101101
    102102  // long long
     
    154154  class DefaultMap
    155155    : public DefaultMapSelector<_Graph, _Item, _Value>::Map {
     156    typedef typename DefaultMapSelector<_Graph, _Item, _Value>::Map Parent;
     157
    156158  public:
    157     typedef typename DefaultMapSelector<_Graph, _Item, _Value>::Map Parent;
    158159    typedef DefaultMap<_Graph, _Item, _Value> Map;
    159 
    160     typedef typename Parent::Graph Graph;
     160   
     161    typedef typename Parent::GraphType GraphType;
    161162    typedef typename Parent::Value Value;
    162163
    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)
    165166      : Parent(graph, value) {}
    166167
  • lemon/bits/enable_if.h

    r314 r463  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
  • lemon/bits/graph_extender.h

    r314 r664  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    3030//\ingroup graphbits
    3131//\file
    32 //\brief Extenders for the digraph types
     32//\brief Extenders for the graph types
    3333namespace lemon {
    3434
    3535  // \ingroup graphbits
    3636  //
    37   // \brief Extender for the Digraphs
     37  // \brief Extender for the digraph implementations
    3838  template <typename Base>
    3939  class DigraphExtender : public Base {
     40    typedef Base Parent;
     41
    4042  public:
    4143
    42     typedef Base Parent;
    4344    typedef DigraphExtender Digraph;
    4445
     
    219220    class NodeMap
    220221      : public MapExtender<DefaultMap<Digraph, Node, _Value> > {
    221     public:
    222       typedef DigraphExtender Digraph;
    223222      typedef MapExtender<DefaultMap<Digraph, Node, _Value> > Parent;
    224223
     224    public:
    225225      explicit NodeMap(const Digraph& digraph)
    226226        : Parent(digraph) {}
     
    244244    class ArcMap
    245245      : public MapExtender<DefaultMap<Digraph, Arc, _Value> > {
    246     public:
    247       typedef DigraphExtender Digraph;
    248246      typedef MapExtender<DefaultMap<Digraph, Arc, _Value> > Parent;
    249247
     248    public:
    250249      explicit ArcMap(const Digraph& digraph)
    251250        : Parent(digraph) {}
     
    331330  template <typename Base>
    332331  class GraphExtender : public Base {
     332    typedef Base Parent;
     333
    333334  public:
    334335
    335     typedef Base Parent;
    336336    typedef GraphExtender Graph;
    337337
     
    602602    class NodeMap
    603603      : public MapExtender<DefaultMap<Graph, Node, _Value> > {
    604     public:
    605       typedef GraphExtender Graph;
    606604      typedef MapExtender<DefaultMap<Graph, Node, _Value> > Parent;
    607605
     606    public:
    608607      NodeMap(const Graph& graph)
    609608        : Parent(graph) {}
     
    627626    class ArcMap
    628627      : public MapExtender<DefaultMap<Graph, Arc, _Value> > {
    629     public:
    630       typedef GraphExtender Graph;
    631628      typedef MapExtender<DefaultMap<Graph, Arc, _Value> > Parent;
    632629
     630    public:
    633631      ArcMap(const Graph& graph)
    634632        : Parent(graph) {}
     
    652650    class EdgeMap
    653651      : public MapExtender<DefaultMap<Graph, Edge, _Value> > {
    654     public:
    655       typedef GraphExtender Graph;
    656652      typedef MapExtender<DefaultMap<Graph, Edge, _Value> > Parent;
    657653
     654    public:
    658655      EdgeMap(const Graph& graph)
    659656        : Parent(graph) {}
  • lemon/bits/map_extender.h

    r314 r664  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    3737  template <typename _Map>
    3838  class MapExtender : public _Map {
    39   public:
    40 
    4139    typedef _Map Parent;
     40    typedef typename Parent::GraphType GraphType;
     41
     42  public:
     43
    4244    typedef MapExtender Map;
    43 
    44 
    45     typedef typename Parent::Graph Graph;
    4645    typedef typename Parent::Key Item;
    4746
    4847    typedef typename Parent::Key Key;
    4948    typedef typename Parent::Value Value;
     49    typedef typename Parent::Reference Reference;
     50    typedef typename Parent::ConstReference ConstReference;
    5051
    5152    class MapIt;
     
    5758  public:
    5859
    59     MapExtender(const Graph& graph)
     60    MapExtender(const GraphType& graph)
    6061      : Parent(graph) {}
    6162
    62     MapExtender(const Graph& graph, const Value& value)
     63    MapExtender(const GraphType& graph, const Value& value)
    6364      : Parent(graph, value) {}
    6465
     
    7677  public:
    7778    class MapIt : public Item {
    78     public:
    79 
    80       typedef Item Parent;
     79      typedef Item Parent;
     80
     81    public:
     82
    8183      typedef typename Map::Value Value;
    8284
     
    115117
    116118    class ConstMapIt : public Item {
    117     public:
    118 
    119       typedef Item Parent;
     119      typedef Item Parent;
     120
     121    public:
    120122
    121123      typedef typename Map::Value Value;
     
    146148
    147149    class ItemIt : public Item {
    148     public:
    149 
    150       typedef Item Parent;
     150      typedef Item Parent;
     151
     152    public:
    151153
    152154      ItemIt() {}
     
    177179  template <typename _Graph, typename _Map>
    178180  class SubMapExtender : public _Map {
    179   public:
    180 
    181181    typedef _Map Parent;
     182    typedef _Graph GraphType;
     183
     184  public:
     185
    182186    typedef SubMapExtender Map;
    183 
    184     typedef _Graph Graph;
    185 
    186187    typedef typename Parent::Key Item;
    187188
    188189    typedef typename Parent::Key Key;
    189190    typedef typename Parent::Value Value;
     191    typedef typename Parent::Reference Reference;
     192    typedef typename Parent::ConstReference ConstReference;
    190193
    191194    class MapIt;
     
    197200  public:
    198201
    199     SubMapExtender(const Graph& _graph)
     202    SubMapExtender(const GraphType& _graph)
    200203      : Parent(_graph), graph(_graph) {}
    201204
    202     SubMapExtender(const Graph& _graph, const Value& _value)
     205    SubMapExtender(const GraphType& _graph, const Value& _value)
    203206      : Parent(_graph, _value), graph(_graph) {}
    204207
     
    220223  public:
    221224    class MapIt : public Item {
    222     public:
    223 
    224       typedef Item Parent;
     225      typedef Item Parent;
     226
     227    public:
    225228      typedef typename Map::Value Value;
    226229
     
    259262
    260263    class ConstMapIt : public Item {
    261     public:
    262 
    263       typedef Item Parent;
     264      typedef Item Parent;
     265
     266    public:
    264267
    265268      typedef typename Map::Value Value;
     
    290293
    291294    class ItemIt : public Item {
    292     public:
    293 
    294       typedef Item Parent;
     295      typedef Item Parent;
     296
     297    public:
    295298
    296299      ItemIt() {}
     
    317320  private:
    318321
    319     const Graph& graph;
     322    const GraphType& graph;
    320323
    321324  };
  • lemon/bits/path_dump.h

    r209 r576  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    1717 */
    1818
    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>
    2124
    2225namespace lemon {
  • lemon/bits/traits.h

    r314 r663  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    3030  struct InvalidType {};
    3131
    32   template <typename _Graph, typename _Item>
     32  template <typename GR, typename _Item>
    3333  class ItemSetTraits {};
    3434
    3535
    36   template <typename Graph, typename Enable = void>
     36  template <typename GR, typename Enable = void>
    3737  struct NodeNotifierIndicator {
    3838    typedef InvalidType Type;
    3939  };
    40   template <typename Graph>
     40  template <typename GR>
    4141  struct NodeNotifierIndicator<
    42     Graph,
    43     typename enable_if<typename Graph::NodeNotifier::Notifier, void>::type
    44   > {
    45     typedef typename Graph::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> {
    5050  public:
    5151
    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
    6164    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;
    6466      typedef typename Parent::Value Value;
    6567
    66       Map(const Graph& _digraph) : Parent(_digraph) {}
    67       Map(const Graph& _digraph, const Value& _value)
     68      Map(const GR& _digraph) : Parent(_digraph) {}
     69      Map(const GR& _digraph, const Value& _value)
    6870        : Parent(_digraph, _value) {}
    6971
     
    7274  };
    7375
    74   template <typename Graph, typename Enable = void>
     76  template <typename GR, typename Enable = void>
    7577  struct ArcNotifierIndicator {
    7678    typedef InvalidType Type;
    7779  };
    78   template <typename Graph>
     80  template <typename GR>
    7981  struct ArcNotifierIndicator<
    80     Graph,
    81     typename enable_if<typename Graph::ArcNotifier::Notifier, void>::type
    82   > {
    83     typedef typename Graph::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> {
    8890  public:
    8991
    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
    99104    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;
    102106      typedef typename Parent::Value Value;
    103107
    104       Map(const Graph& _digraph) : Parent(_digraph) {}
    105       Map(const Graph& _digraph, const Value& _value)
     108      Map(const GR& _digraph) : Parent(_digraph) {}
     109      Map(const GR& _digraph, const Value& _value)
    106110        : Parent(_digraph, _value) {}
    107111    };
     
    109113  };
    110114
    111   template <typename Graph, typename Enable = void>
     115  template <typename GR, typename Enable = void>
    112116  struct EdgeNotifierIndicator {
    113117    typedef InvalidType Type;
    114118  };
    115   template <typename Graph>
     119  template <typename GR>
    116120  struct EdgeNotifierIndicator<
    117     Graph,
    118     typename enable_if<typename Graph::EdgeNotifier::Notifier, void>::type
    119   > {
    120     typedef typename Graph::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> {
    125129  public:
    126130
    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
    136143    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;
    139145      typedef typename Parent::Value Value;
    140146
    141       Map(const Graph& _digraph) : Parent(_digraph) {}
    142       Map(const Graph& _digraph, const Value& _value)
     147      Map(const GR& _digraph) : Parent(_digraph) {}
     148      Map(const GR& _digraph, const Value& _value)
    143149        : Parent(_digraph, _value) {}
    144150    };
     
    205211  // Indicators for the tags
    206212
    207   template <typename Graph, typename Enable = void>
     213  template <typename GR, typename Enable = void>
    208214  struct NodeNumTagIndicator {
    209215    static const bool value = false;
    210216  };
    211217
    212   template <typename Graph>
     218  template <typename GR>
    213219  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>
    221240  struct EdgeNumTagIndicator {
    222241    static const bool value = false;
    223242  };
    224243
    225   template <typename Graph>
     244  template <typename GR>
    226245  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>
    234266  struct FindEdgeTagIndicator {
    235267    static const bool value = false;
    236268  };
    237269
    238   template <typename Graph>
     270  template <typename GR>
    239271  struct FindEdgeTagIndicator<
    240     Graph,
    241     typename enable_if<typename Graph::FindEdgeTag, void>::type
    242   > {
    243     static const bool value = true;
    244   };
    245 
    246   template <typename Graph, 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>
    247279  struct UndirectedTagIndicator {
    248280    static const bool value = false;
    249281  };
    250282
    251   template <typename Graph>
     283  template <typename GR>
    252284  struct UndirectedTagIndicator<
    253     Graph,
    254     typename enable_if<typename Graph::UndirectedTag, void>::type
    255   > {
    256     static const bool value = true;
    257   };
    258 
    259   template <typename Graph, 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>
    260292  struct BuildTagIndicator {
    261293    static const bool value = false;
    262294  };
    263295
    264   template <typename Graph>
     296  template <typename GR>
    265297  struct BuildTagIndicator<
    266     Graph,
    267     typename enable_if<typename Graph::BuildTag, void>::type
     298    GR,
     299    typename enable_if<typename GR::BuildTag, void>::type
    268300  > {
    269301    static const bool value = true;
  • lemon/bits/vector_map.h

    r314 r664  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    3939  // \brief Graph map based on the std::vector storage.
    4040  //
    41   // The VectorMap template class is graph map structure what
    42   // automatically updates the map when a key is added to or erased from
    43   // the map. This map type uses the std::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.
    4444  //
    4545  // \tparam _Graph The graph this map is attached to.
     
    5757
    5858    // The graph type of the map.
    59     typedef _Graph Graph;
     59    typedef _Graph GraphType;
    6060    // The item type of the map.
    6161    typedef _Item Item;
     
    7373    // The map type.
    7474    typedef VectorMap Map;
    75     // The base class of the map.
    76     typedef typename Notifier::ObserverBase Parent;
    7775
    7876    // The reference type of the map;
     
    8179    typedef typename Container::const_reference ConstReference;
    8280
     81  private:
     82
     83    // The base class of the map.
     84    typedef typename Notifier::ObserverBase Parent;
     85
     86  public:
    8387
    8488    // \brief Constructor to attach the new map into the notifier.
     
    8690    // It constructs a map and attachs it into the notifier.
    8791    // It adds all the items of the graph to the map.
    88     VectorMap(const Graph& graph) {
     92    VectorMap(const GraphType& graph) {
    8993      Parent::attach(graph.notifier(Item()));
    9094      container.resize(Parent::notifier()->maxId() + 1);
     
    9599    // It constructs a map uses a given value to initialize the map.
    96100    // 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) {
    98102      Parent::attach(graph.notifier(Item()));
    99103      container.resize(Parent::notifier()->maxId() + 1, value);
     
    125129    // \brief Template assign operator.
    126130    //
    127     // The given parameter should be conform to the ReadMap
     131    // The given parameter should conform to the ReadMap
    128132    // concecpt and could be indiced by the current item set of
    129133    // the NodeMap. In this case the value for each item
     
    170174    // \brief Adds a new key to the map.
    171175    //
    172     // It adds a new key to the map. It called by the observer notifier
     176    // It adds a new key to the map. It is called by the observer notifier
    173177    // and it overrides the add() member function of the observer base.
    174178    virtual void add(const Key& key) {
     
    181185    // \brief Adds more new keys to the map.
    182186    //
    183     // It adds more new keys to the map. It called by the observer notifier
     187    // It adds more new keys to the map. It is called by the observer notifier
    184188    // and it overrides the add() member function of the observer base.
    185189    virtual void add(const std::vector<Key>& keys) {
     
    196200    // \brief Erase a key from the map.
    197201    //
    198     // Erase a key from the map. It called by the observer notifier
     202    // Erase a key from the map. It is called by the observer notifier
    199203    // and it overrides the erase() member function of the observer base.
    200204    virtual void erase(const Key& key) {
     
    204208    // \brief Erase more keys from the map.
    205209    //
    206     // Erase more keys from the map. It called by the observer notifier
     210    // It erases more keys from the map. It is called by the observer notifier
    207211    // and it overrides the erase() member function of the observer base.
    208212    virtual void erase(const std::vector<Key>& keys) {
     
    212216    }
    213217
    214     // \brief Buildes the map.
    215     //
    216     // It buildes the map. It called by the observer notifier
     218    // \brief Build the map.
     219    //
     220    // It builds the map. It is called by the observer notifier
    217221    // and it overrides the build() member function of the observer base.
    218222    virtual void build() {
     
    224228    // \brief Clear the map.
    225229    //
    226     // It erase all items from the map. It called by the observer notifier
     230    // It erases all items from the map. It is called by the observer notifier
    227231    // and it overrides the clear() member function of the observer base.
    228232    virtual void clear() {
  • lemon/bits/windows.h

    r511 r576  
    1717 */
    1818
    19 #ifndef LEMON_WINDOWS_H
    20 #define LEMON_WINDOWS_H
     19#ifndef LEMON_BITS_WINDOWS_H
     20#define LEMON_BITS_WINDOWS_H
    2121
    2222#include <string>
  • lemon/color.cc

    r209 r463  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
  • lemon/color.h

    r313 r463  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
  • lemon/concept_check.h

    r285 r463  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
  • lemon/concepts/digraph.h

    r263 r627  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    1717 */
    1818
    19 #ifndef LEMON_CONCEPT_DIGRAPH_H
    20 #define LEMON_CONCEPT_DIGRAPH_H
     19#ifndef LEMON_CONCEPTS_DIGRAPH_H
     20#define LEMON_CONCEPTS_DIGRAPH_H
    2121
    2222///\ingroup graph_concepts
     
    422422      Node oppositeNode(const Node&, const Arc&) const { return INVALID; }
    423423
    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.
    428427      template<class T>
    429       class NodeMap : public ReadWriteMap< Node, T > {
     428      class NodeMap : public ReferenceMap<Node, T, T&, const T&> {
    430429      public:
    431430
     
    437436      private:
    438437        ///Copy constructor
    439         NodeMap(const NodeMap& nm) : ReadWriteMap< Node, T >(nm) { }
     438        NodeMap(const NodeMap& nm) :
     439          ReferenceMap<Node, T, T&, const T&>(nm) { }
    440440        ///Assignment operator
    441441        template <typename CMap>
     
    446446      };
    447447
    448       /// \brief Read write map of the arcs to type \c T.
     448      /// \brief Reference map of the arcs to type \c T.
    449449      ///
    450450      /// Reference map of the arcs to type \c T.
    451       /// \sa Reference
    452451      template<class T>
    453       class ArcMap : public ReadWriteMap<Arc,T> {
     452      class ArcMap : public ReferenceMap<Arc, T, T&, const T&> {
    454453      public:
    455454
     
    460459      private:
    461460        ///Copy constructor
    462         ArcMap(const ArcMap& em) : ReadWriteMap<Arc,T>(em) { }
     461        ArcMap(const ArcMap& em) :
     462          ReferenceMap<Arc, T, T&, const T&>(em) { }
    463463        ///Assignment operator
    464464        template <typename CMap>
     
    472472      struct Constraints {
    473473        void constraints() {
     474          checkConcept<BaseDigraphComponent, _Digraph>();
    474475          checkConcept<IterableDigraphComponent<>, _Digraph>();
    475476          checkConcept<IDableDigraphComponent<>, _Digraph>();
     
    485486
    486487
    487 #endif // LEMON_CONCEPT_DIGRAPH_H
     488#endif
  • lemon/concepts/graph.h

    r263 r627  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    2121///\brief The concept of Undirected Graphs.
    2222
    23 #ifndef LEMON_CONCEPT_GRAPH_H
    24 #define LEMON_CONCEPT_GRAPH_H
     23#ifndef LEMON_CONCEPTS_GRAPH_H
     24#define LEMON_CONCEPTS_GRAPH_H
    2525
    2626#include <lemon/concepts/graph_components.h>
    27 #include <lemon/concepts/graph.h>
    2827#include <lemon/core.h>
    2928
     
    499498      };
    500499
    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.
    505503      template<class T>
    506       class NodeMap : public ReadWriteMap< Node, T >
     504      class NodeMap : public ReferenceMap<Node, T, T&, const T&>
    507505      {
    508506      public:
     
    515513      private:
    516514        ///Copy constructor
    517         NodeMap(const NodeMap& nm) : ReadWriteMap< Node, T >(nm) { }
     515        NodeMap(const NodeMap& nm) :
     516          ReferenceMap<Node, T, T&, const T&>(nm) { }
    518517        ///Assignment operator
    519518        template <typename CMap>
     
    524523      };
    525524
    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.
    530528      template<class T>
    531       class ArcMap : public ReadWriteMap<Arc,T>
     529      class ArcMap : public ReferenceMap<Arc, T, T&, const T&>
    532530      {
    533531      public:
     
    539537      private:
    540538        ///Copy constructor
    541         ArcMap(const ArcMap& em) : ReadWriteMap<Arc,T>(em) { }
     539        ArcMap(const ArcMap& em) :
     540          ReferenceMap<Arc, T, T&, const T&>(em) { }
    542541        ///Assignment operator
    543542        template <typename CMap>
     
    548547      };
    549548
    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.
    554552      template<class T>
    555       class EdgeMap : public ReadWriteMap<Edge,T>
     553      class EdgeMap : public ReferenceMap<Edge, T, T&, const T&>
    556554      {
    557555      public:
     
    563561      private:
    564562        ///Copy constructor
    565         EdgeMap(const EdgeMap& em) : ReadWriteMap<Edge,T>(em) {}
     563        EdgeMap(const EdgeMap& em) :
     564          ReferenceMap<Edge, T, T&, const T&>(em) {}
    566565        ///Assignment operator
    567566        template <typename CMap>
     
    603602      /// \brief Opposite node on an arc
    604603      ///
    605       /// \return the opposite of the given Node on the given Edge
     604      /// \return The opposite of the given node on the given edge.
    606605      Node oppositeNode(Node, Edge) const { return INVALID; }
    607606
    608607      /// \brief First node of the edge.
    609608      ///
    610       /// \return the first node of the given Edge.
     609      /// \return The first node of the given edge.
    611610      ///
    612611      /// Naturally edges don't have direction and thus
    613       /// don't have source and target node. But we use these two methods
    614       /// to query the two nodes of the arc. The direction of the arc
    615       /// which arises this way is called the inherent direction of the
     612      /// 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
    616615      /// edge, and is used to define the "default" direction
    617616      /// of the directed versions of the arcs.
    618       /// \sa direction
     617      /// \sa v()
     618      /// \sa direction()
    619619      Node u(Edge) const { return INVALID; }
    620620
    621621      /// \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()
    622633      Node v(Edge) const { return INVALID; }
    623634
     
    738749      struct Constraints {
    739750        void constraints() {
     751          checkConcept<BaseGraphComponent, _Graph>();
    740752          checkConcept<IterableGraphComponent<>, _Graph>();
    741753          checkConcept<IDableGraphComponent<>, _Graph>();
  • lemon/concepts/graph_components.h

    r313 r664  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    2121///\brief The concept of graph components.
    2222
    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
    2625
    2726#include <lemon/core.h>
     
    3332  namespace concepts {
    3433
    35     /// \brief Skeleton class for graph Node and Arc types
    36     ///
    37     /// This class describes the interface of Node and Arc (and Edge
    38     /// in undirected graphs) subtypes of graph 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.
    3938    ///
    4039    /// \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'.
    4644#ifndef DOXYGEN
    47     template <char _selector = '0'>
     45    template <char sel = '0'>
    4846#endif
    4947    class GraphItem {
     
    5149      /// \brief Default constructor.
    5250      ///
     51      /// Default constructor.
    5352      /// \warning The default constructor is not required to set
    5453      /// the item to some well-defined value. So you should consider it
    5554      /// as uninitialized.
    5655      GraphItem() {}
     56
    5757      /// \brief Copy constructor.
    5858      ///
    5959      /// Copy constructor.
    60       ///
    6160      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.
    6566      /// \sa Invalid for more details.
    6667      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
    7274      /// \brief Equality operator.
    7375      ///
    74       /// Two iterators are equal if and only if they represents the
    75       /// 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
    7779      /// \brief Inequality operator.
    7880      ///
    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 or
    86       /// 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).
    8789      ///
    8890      /// \note This operator only have to define some strict ordering of
    8991      /// the items; this order has nothing to do with the iteration
    9092      /// ordering of the items.
    91       bool operator<(GraphItem) const { return false; }
     93      bool operator<(const GraphItem&) const { return false; }
    9294
    9395      template<typename _GraphItem>
     
    101103
    102104          bool b;
    103           //          b = (ia == ib) && (ia != ib) && (ia < ib);
    104105          b = (ia == ib) && (ia != ib);
    105106          b = (ia == INVALID) && (ib != INVALID);
     
    112113    };
    113114
    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.
    121121    class BaseDigraphComponent {
    122122    public:
     
    126126      /// \brief Node class of the digraph.
    127127      ///
    128       /// This class represents the Nodes of the digraph.
    129       ///
     128      /// This class represents the nodes of the digraph.
    130129      typedef GraphItem<'n'> Node;
    131130
    132131      /// \brief Arc class of the digraph.
    133132      ///
    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.
    153149      Node oppositeNode(const Node&, const Arc&) const {
    154150        return INVALID;
     
    176172    };
    177173
    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.
    187181    class BaseGraphComponent : public BaseDigraphComponent {
    188182    public:
     183
     184      typedef BaseGraphComponent Graph;
     185
    189186      typedef BaseDigraphComponent::Node Node;
    190187      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
    199197      public:
    200         typedef GraphItem<'u'> Parent;
    201198        /// \brief Default constructor.
    202199        ///
     200        /// Default constructor.
    203201        /// \warning The default constructor is not required to set
    204202        /// the item to some well-defined value. So you should consider it
    205203        /// as uninitialized.
    206204        Edge() {}
     205
    207206        /// \brief Copy constructor.
    208207        ///
    209208        /// Copy constructor.
    210         ///
    211209        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.
    215215        /// \sa Invalid for more details.
    216216        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.
    219221        /// Besides the core graph item functionality each arc should
    220222        /// be convertible to the represented edge.
    221223        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.
    224228        /// Besides the core graph item functionality each arc should
    225229        /// be convertible to the represented edge.
     
    227231      };
    228232
    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.
    230256      ///
    231257      /// Returns the direction of the arc. Each arc represents an
     
    234260      bool direction(const Arc&) const { return true; }
    235261
    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; }
    263267
    264268      template <typename _Graph>
     
    270274        void constraints() {
    271275          checkConcept<BaseDigraphComponent, _Graph>();
    272           checkConcept<GraphItem<'u'>, Edge>();
     276          checkConcept<GraphItem<'e'>, Edge>();
    273277          {
    274278            Node n;
     
    278282            n = graph.v(ue);
    279283            e = graph.direct(ue, true);
     284            e = graph.direct(ue, false);
    280285            e = graph.direct(ue, n);
    281286            e = graph.oppositeArc(e);
     
    291296    };
    292297
    293     /// \brief An empty idable base digraph class.
    294     ///
    295     /// This class provides beside the core digraph features
    296     /// core id functions for the digraph structure.
    297     /// The most of the base digraphs should be conform to this concept.
    298     /// The id's are unique and immutable.
    299     template <typename _Base = BaseDigraphComponent>
    300     class IDableDigraphComponent : public _Base {
    301     public:
    302 
    303       typedef _Base Base;
     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;
    304309      typedef typename Base::Node Node;
    305310      typedef typename Base::Arc Arc;
    306311
    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; }
    346349
    347350      template <typename _Digraph>
     
    369372    };
    370373
    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;
    382386      typedef typename Base::Edge Edge;
    383387
    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; }
    405408
    406409      template <typename _Graph>
     
    408411
    409412        void constraints() {
    410           checkConcept<Base, _Graph >();
    411413          checkConcept<IDableDigraphComponent<Base>, _Graph >();
    412414          typename _Graph::Edge edge;
     
    422424    };
    423425
    424     /// \brief Skeleton class for graph NodeIt and ArcIt
    425     ///
    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 {
    430432    public:
    431433      /// \brief Default constructor.
    432434      ///
    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.
    435439      GraphItemIt() {}
     440
    436441      /// \brief Copy constructor.
    437442      ///
    438443      /// 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.
    449455      /// \sa Invalid for more details.
    450456      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.
    455461      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.
    460467      GraphItemIt& operator++() { return *this; }
     468 
    461469      /// \brief Equality operator
    462470      ///
     471      /// Equality operator.
    463472      /// Two iterators are equal if and only if they point to the
    464473      /// same object or both are invalid.
    465474      bool operator==(const GraphItemIt&) const { return true;}
     475
    466476      /// \brief Inequality operator
    467477      ///
    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.
    470481      bool operator!=(const GraphItemIt&) const { return true;}
    471482
     
    473484      struct Constraints {
    474485        void constraints() {
     486          checkConcept<GraphItem<>, _GraphItemIt>();
    475487          _GraphItemIt it1(g);
    476488          _GraphItemIt it2;
     489          _GraphItemIt it3 = it1;
     490          _GraphItemIt it4 = INVALID;
    477491
    478492          it2 = ++it1;
     
    480494          ++(++it1);
    481495
    482           _Item bi = it1;
     496          Item bi = it1;
    483497          bi = it2;
    484498        }
    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 {
    500518    public:
    501519      /// \brief Default constructor.
    502520      ///
    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.
    505525      GraphIncIt() {}
     526
    506527      /// \brief Copy constructor.
    507528      ///
    508529      /// 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.
    521543      /// \sa Invalid for more details.
    522544      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.
    532555      GraphIncIt& operator++() { return *this; }
    533556
    534557      /// \brief Equality operator
    535558      ///
     559      /// Equality operator.
    536560      /// Two iterators are equal if and only if they point to the
    537561      /// same object or both are invalid.
     
    540564      /// \brief Inequality operator
    541565      ///
    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.
    544569      bool operator!=(const GraphIncIt&) const { return true;}
    545570
     
    547572      struct Constraints {
    548573        void constraints() {
    549           checkConcept<GraphItem<_selector>, _GraphIncIt>();
     574          checkConcept<GraphItem<sel>, _GraphIncIt>();
    550575          _GraphIncIt it1(graph, node);
    551576          _GraphIncIt it2;
     577          _GraphIncIt it3 = it1;
     578          _GraphIncIt it4 = INVALID;
    552579
    553580          it2 = ++it1;
    554581          ++it2 = it1;
    555582          ++(++it1);
    556           _Item e = it1;
     583          Item e = it1;
    557584          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.
    573596    /// This concept is part of the Digraph concept.
    574     template <typename _Base = BaseDigraphComponent>
    575     class IterableDigraphComponent : public _Base {
    576 
    577     public:
    578 
    579       typedef _Base Base;
     597    template <typename BAS = BaseDigraphComponent>
     598    class IterableDigraphComponent : public BAS {
     599
     600    public:
     601
     602      typedef BAS Base;
    580603      typedef typename Base::Node Node;
    581604      typedef typename Base::Arc Arc;
     
    583606      typedef IterableDigraphComponent Digraph;
    584607
    585       /// \name Base iteration
    586       ///
    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.
    588611      ///
    589612      /// @{
    590613
    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.
    595617      void first(Node&) const {}
    596618
    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.
    601622      void next(Node&) const {}
    602623
    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.
    607627      void first(Arc&) const {}
    608628
    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.
    613632      void next(Arc&) const {}
    614633
    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.
    621638      void firstIn(Arc&, const Node&) const {}
    622639
    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.
    628644      void nextIn(Arc&) const {}
    629645
    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
    631649      /// given node.
    632       ///
    633       /// Gives back the first of the arcs start from the given node.
    634       ///
    635650      void firstOut(Arc&, const Node&) const {}
    636651
    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.
    642656      void nextOut(Arc&) const {}
    643657
    644658      /// @}
    645659
    646       /// \name Class based iteration
    647       ///
    648       /// This interface provides functions for iteration on digraph items
     660      /// \name Class Based Iteration
     661      ///
     662      /// This interface provides iterator classes for digraph items.
    649663      ///
    650664      /// @{
     
    656670      typedef GraphItemIt<Digraph, Node> NodeIt;
    657671
    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.
    661675      ///
    662676      typedef GraphItemIt<Digraph, Arc> ArcIt;
     
    664678      /// \brief This iterator goes trough the incoming arcs of a node.
    665679      ///
    666       /// This iterator goes trough the \e inccoming arcs of a certain node
     680      /// This iterator goes trough the \e incoming arcs of a certain node
    667681      /// of a digraph.
    668682      typedef GraphIncIt<Digraph, Arc, Node, 'i'> InArcIt;
     
    676690      /// \brief The base node of the iterator.
    677691      ///
    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.
    680694      Node baseNode(const InArcIt&) const { return INVALID; }
    681695
    682696      /// \brief The running node of the iterator.
    683697      ///
    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.
    686700      Node runningNode(const InArcIt&) const { return INVALID; }
    687701
    688702      /// \brief The base node of the iterator.
    689703      ///
    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.
    692706      Node baseNode(const OutArcIt&) const { return INVALID; }
    693707
    694708      /// \brief The running node of the iterator.
    695709      ///
    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.
    698712      Node runningNode(const OutArcIt&) const { return INVALID; }
    699713
     
    737751
    738752            typename _Digraph::Node n;
    739             typename _Digraph::InArcIt ieit(INVALID);
    740             typename _Digraph::OutArcIt oeit(INVALID);
    741             n = digraph.baseNode(ieit);
    742             n = digraph.runningNode(ieit);
    743             n = digraph.baseNode(oeit);
    744             n = digraph.runningNode(oeit);
     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);
    745759            ignore_unused_variable_warning(n);
    746760          }
     
    748762
    749763        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 iterator
    757     /// 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.
    758772    /// This concept is part of the Graph concept.
    759     template <typename _Base = BaseGraphComponent>
    760     class IterableGraphComponent : public IterableDigraphComponent<_Base> {
    761     public:
    762 
    763       typedef _Base Base;
     773    template <typename BAS = BaseGraphComponent>
     774    class IterableGraphComponent : public IterableDigraphComponent<BAS> {
     775    public:
     776
     777      typedef BAS Base;
    764778      typedef typename Base::Node Node;
    765779      typedef typename Base::Arc Arc;
     
    769783      typedef IterableGraphComponent Graph;
    770784
    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      ///
    774789      /// @{
    775790
    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.
    784797      void first(Edge&) const {}
    785798
    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.
    791802      void next(Edge&) const {}
    792803
    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
    795809      /// given node.
    796       ///
    797       /// Gives back the first of the edges from the given
    798       /// node. The bool parameter gives back that direction which
    799       /// gives a good direction of the edge so the source of the
    800       /// directed arc is the given node.
    801810      void firstInc(Edge&, bool&, const Node&) const {}
    802811
     
    804813      /// given node.
    805814      ///
    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.
    809817      void nextInc(Edge&, bool&) const {}
    810818
    811       using IterableDigraphComponent<_Base>::baseNode;
    812       using IterableDigraphComponent<_Base>::runningNode;
     819      using IterableDigraphComponent<Base>::baseNode;
     820      using IterableDigraphComponent<Base>::runningNode;
    813821
    814822      /// @}
    815823
    816       /// \name Class based iteration
    817       ///
    818       /// This interface provides functions for iteration on graph items
     824      /// \name Class Based Iteration
     825      ///
     826      /// This interface provides iterator classes for edges.
    819827      ///
    820828      /// @{
    821829
    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.
    825833      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
    827836      /// node.
    828837      ///
    829       /// This iterator goes trough the incident arcs of a certain
     838      /// This iterator goes trough the incident edges of a certain
    830839      /// node of a graph.
    831       typedef GraphIncIt<Graph, Edge, Node, 'u'> IncEdgeIt;
     840      typedef GraphIncIt<Graph, Edge, Node, 'e'> IncEdgeIt;
     841
    832842      /// \brief The base node of the iterator.
    833843      ///
    834       /// Gives back the base node of the iterator.
     844      /// This function gives back the base node of the iterator.
    835845      Node baseNode(const IncEdgeIt&) const { return INVALID; }
    836846
    837847      /// \brief The running node of the iterator.
    838848      ///
    839       /// Gives back the running node of the iterator.
     849      /// This function gives back the running node of the iterator.
    840850      Node runningNode(const IncEdgeIt&) const { return INVALID; }
    841851
     
    866876              typename _Graph::EdgeIt >();
    867877            checkConcept<GraphIncIt<_Graph, typename _Graph::Edge,
    868               typename _Graph::Node, 'u'>, typename _Graph::IncEdgeIt>();
     878              typename _Graph::Node, 'e'>, typename _Graph::IncEdgeIt>();
    869879
    870880            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);
    874884          }
    875885        }
    876886
    877887        const _Graph& graph;
    878 
    879       };
    880     };
    881 
    882     /// \brief An empty alteration notifier digraph class.
    883     ///
    884     /// This class provides beside the core digraph features alteration
    885     /// notifier interface for the digraph structure.  This implements
     888      };
     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
    886896    /// an observer-notifier pattern for each digraph item. More
    887897    /// 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
    889899    /// notified about it.
    890     template <typename _Base = BaseDigraphComponent>
    891     class AlterableDigraphComponent : public _Base {
    892     public:
    893 
    894       typedef _Base Base;
     900    template <typename BAS = BaseDigraphComponent>
     901    class AlterableDigraphComponent : public BAS {
     902    public:
     903
     904      typedef BAS Base;
    895905      typedef typename Base::Node Node;
    896906      typedef typename Base::Arc Arc;
    897907
    898908
    899       /// The node observer registry.
     909      /// Node alteration notifier class.
    900910      typedef AlterationNotifier<AlterableDigraphComponent, Node>
    901911      NodeNotifier;
    902       /// The arc observer registry.
     912      /// Arc alteration notifier class.
    903913      typedef AlterationNotifier<AlterableDigraphComponent, Arc>
    904914      ArcNotifier;
    905915
    906       /// \brief Gives back the 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.
    909919      NodeNotifier& notifier(Node) const {
    910         return NodeNotifier();
     920         return NodeNotifier();
    911921      }
    912922
    913       /// \brief Gives back the 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.
    916926      ArcNotifier& notifier(Arc) const {
    917927        return ArcNotifier();
     
    933943
    934944        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
    945954    /// 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
    947956    /// notified about it.
    948     template <typename _Base = BaseGraphComponent>
    949     class AlterableGraphComponent : public AlterableDigraphComponent<_Base> {
    950     public:
    951 
    952       typedef _Base Base;
     957    template <typename BAS = BaseGraphComponent>
     958    class AlterableGraphComponent : public AlterableDigraphComponent<BAS> {
     959    public:
     960
     961      typedef BAS Base;
    953962      typedef typename Base::Edge Edge;
    954963
    955964
    956       /// The arc observer registry.
     965      /// Edge alteration notifier class.
    957966      typedef AlterationNotifier<AlterableGraphComponent, Edge>
    958967      EdgeNotifier;
    959968
    960       /// \brief Gives back the arc alteration notifier.
    961       ///
    962       /// Gives back the arc alteration notifier.
     969      /// \brief Return the edge alteration notifier.
     970      ///
     971      /// This function gives back the edge alteration notifier.
    963972      EdgeNotifier& notifier(Edge) const {
    964973        return EdgeNotifier();
     
    968977      struct Constraints {
    969978        void constraints() {
    970           checkConcept<AlterableGraphComponent<Base>, _Graph>();
     979          checkConcept<AlterableDigraphComponent<Base>, _Graph>();
    971980          typename _Graph::EdgeNotifier& uen
    972981            = graph.notifier(typename _Graph::Edge());
     
    975984
    976985        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
    9951001      /// The key type of the map.
    996       typedef _Item Key;
     1002      typedef K Key;
    9971003      /// 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;
    9991012
    10001013      /// \brief Construct a new map.
    10011014      ///
    10021015      /// Construct a new map for the graph.
    1003       explicit GraphMap(const Graph&) {}
     1016      explicit GraphMap(const GR&) {}
    10041017      /// \brief Construct a new map with default value.
    10051018      ///
    1006       /// Construct a new map for the graph and initalise the values.
    1007       GraphMap(const Graph&, const Value&) {}
     1019      /// Construct a new map for the graph and initalize the values.
     1020      GraphMap(const GR&, const Value&) {}
    10081021
    10091022    private:
     
    10131026      GraphMap(const GraphMap&) : Parent() {}
    10141027
    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,
    10181031      /// it just iterates on the current item set and set the  map
    10191032      /// with the value returned by the assigned map.
     
    10281041      struct Constraints {
    10291042        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
    10381052          // 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 Graph &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;
    10481062        const typename GraphMap::Value &t;
    10491063      };
     
    10511065    };
    10521066
    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.
    10571072    /// This concept is part of the Digraph concept.
    1058     template <typename _Base = BaseDigraphComponent>
    1059     class MappableDigraphComponent : public _Base  {
    1060     public:
    1061 
    1062       typedef _Base Base;
     1073    template <typename BAS = BaseDigraphComponent>
     1074    class MappableDigraphComponent : public BAS  {
     1075    public:
     1076
     1077      typedef BAS Base;
    10631078      typedef typename Base::Node Node;
    10641079      typedef typename Base::Arc Arc;
     
    10661081      typedef MappableDigraphComponent Digraph;
    10671082
    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
    10741091      public:
    1075         typedef GraphMap<MappableDigraphComponent, Node, _Value> Parent;
    1076 
    10771092        /// \brief Construct a new map.
    10781093        ///
     
    10831098        /// \brief Construct a new map with default value.
    10841099        ///
    1085         /// Construct a new map for the digraph and initalise 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)
    10871102          : Parent(digraph, value) {}
    10881103
     
    10931108        NodeMap(const NodeMap& nm) : Parent(nm) {}
    10941109
    1095         /// \brief Assign operator.
    1096         ///
    1097         /// Assign operator.
     1110        /// \brief Assignment operator.
     1111        ///
     1112        /// Assignment operator.
    10981113        template <typename CMap>
    10991114        NodeMap& operator=(const CMap&) {
    1100           checkConcept<ReadMap<Node, _Value>, CMap>();
     1115          checkConcept<ReadMap<Node, V>, CMap>();
    11011116          return *this;
    11021117        }
     
    11041119      };
    11051120
    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
    11121129      public:
    1113         typedef GraphMap<MappableDigraphComponent, Arc, _Value> Parent;
    1114 
    11151130        /// \brief Construct a new map.
    11161131        ///
     
    11211136        /// \brief Construct a new map with default value.
    11221137        ///
    1123         /// Construct a new map for the digraph and initalise 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)
    11251140          : Parent(digraph, value) {}
    11261141
     
    11311146        ArcMap(const ArcMap& nm) : Parent(nm) {}
    11321147
    1133         /// \brief Assign operator.
    1134         ///
    1135         /// Assign operator.
     1148        /// \brief Assignment operator.
     1149        ///
     1150        /// Assignment operator.
    11361151        template <typename CMap>
    11371152        ArcMap& operator=(const CMap&) {
    1138           checkConcept<ReadMap<Arc, _Value>, CMap>();
     1153          checkConcept<ReadMap<Arc, V>, CMap>();
    11391154          return *this;
    11401155        }
     
    11831198        }
    11841199
    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).
    11931209    /// This concept is part of the Graph concept.
    1194     template <typename _Base = BaseGraphComponent>
    1195     class MappableGraphComponent : public MappableDigraphComponent<_Base>  {
    1196     public:
    1197 
    1198       typedef _Base Base;
     1210    template <typename BAS = BaseGraphComponent>
     1211    class MappableGraphComponent : public MappableDigraphComponent<BAS>  {
     1212    public:
     1213
     1214      typedef BAS Base;
    11991215      typedef typename Base::Edge Edge;
    12001216
    12011217      typedef MappableGraphComponent Graph;
    12021218
    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
    12091227      public:
    1210         typedef GraphMap<MappableGraphComponent, Edge, _Value> Parent;
    1211 
    12121228        /// \brief Construct a new map.
    12131229        ///
     
    12181234        /// \brief Construct a new map with default value.
    12191235        ///
    1220         /// Construct a new map for the graph and initalise 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)
    12221238          : Parent(graph, value) {}
    12231239
     
    12281244        EdgeMap(const EdgeMap& nm) : Parent(nm) {}
    12291245
    1230         /// \brief Assign operator.
    1231         ///
    1232         /// Assign operator.
     1246        /// \brief Assignment operator.
     1247        ///
     1248        /// Assignment operator.
    12331249        template <typename CMap>
    12341250        EdgeMap& operator=(const CMap&) {
    1235           checkConcept<ReadMap<Edge, _Value>, CMap>();
     1251          checkConcept<ReadMap<Edge, V>, CMap>();
    12361252          return *this;
    12371253        }
     
    12501266
    12511267        void constraints() {
    1252           checkConcept<MappableGraphComponent<Base>, _Graph>();
     1268          checkConcept<MappableDigraphComponent<Base>, _Graph>();
    12531269
    12541270          { // int map test
     
    12671283        }
    12681284
    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.
    12911306      Node addNode() {
    12921307        return INVALID;
    12931308      }
    12941309
    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.
    12981314      Arc addArc(const Node&, const Node&) {
    12991315        return INVALID;
     
    13151331    };
    13161332
    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.
    13361350      Node addNode() {
    13371351        return INVALID;
    13381352      }
    13391353
    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&) {
    13441359        return INVALID;
    13451360      }
     
    13601375    };
    13611376
    1362     /// \brief An empty erasable digraph class.
    1363     ///
    1364     /// This class provides beside the core digraph features core erase
    1365     /// functions for the digraph structure. The main difference between
    1366     /// the base and this interface is that the digraph alterations
    1367     /// should handled already on this level.
    1368     template <typename _Base = BaseDigraphComponent>
    1369     class ErasableDigraphComponent : public _Base {
    1370     public:
    1371 
    1372       typedef _Base Base;
     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;
    13731388      typedef typename Base::Node Node;
    13741389      typedef typename Base::Arc Arc;
     
    13761391      /// \brief Erase a node from the digraph.
    13771392      ///
    1378       /// Erase a node from the digraph. This function should
    1379       /// erase all arcs connecting to the node.
     1393      /// This function erases the given node from the digraph and all arcs
     1394      /// connected to the node.
    13801395      void erase(const Node&) {}
    13811396
    13821397      /// \brief Erase an arc from the digraph.
    13831398      ///
    1384       /// Erase an arc from the digraph.
    1385       ///
     1399      /// This function erases the given arc from the digraph.
    13861400      void erase(const Arc&) {}
    13871401
     
    13901404        void constraints() {
    13911405          checkConcept<Base, _Digraph>();
    1392           typename _Digraph::Node node;
     1406          const typename _Digraph::Node node(INVALID);
    13931407          digraph.erase(node);
    1394           typename _Digraph::Arc arc;
     1408          const typename _Digraph::Arc arc(INVALID);
    13951409          digraph.erase(arc);
    13961410        }
     
    14001414    };
    14011415
    1402     /// \brief An empty erasable base undirected graph class.
    1403     ///
    1404     /// This class provides beside the core undirected graph features
    1405     /// core erase functions for the undirceted graph structure. The
    1406     /// main difference between the base and this interface is that
    1407     /// the graph alterations should handled already on this level.
    1408     template <typename _Base = BaseGraphComponent>
    1409     class ErasableGraphComponent : public _Base {
    1410     public:
    1411 
    1412       typedef _Base Base;
     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;
    14131427      typedef typename Base::Node Node;
    14141428      typedef typename Base::Edge Edge;
     
    14161430      /// \brief Erase a node from the graph.
    14171431      ///
    1418       /// Erase a node from the graph. This function should erase
    1419       /// arcs connecting to the node.
     1432      /// This function erases the given node from the graph and all edges
     1433      /// connected to the node.
    14201434      void erase(const Node&) {}
    14211435
    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.
    14261439      void erase(const Edge&) {}
    14271440
     
    14301443        void constraints() {
    14311444          checkConcept<Base, _Graph>();
    1432           typename _Graph::Node node;
     1445          const typename _Graph::Node node(INVALID);
    14331446          graph.erase(node);
    1434           typename _Graph::Edge edge;
     1447          const typename _Graph::Edge edge(INVALID);
    14351448          graph.erase(edge);
    14361449        }
     
    14401453    };
    14411454
    1442     /// \brief An empty clearable base digraph class.
    1443     ///
    1444     /// This class provides beside the core digraph features core clear
    1445     /// functions for the digraph structure. The main difference between
    1446     /// the base and this interface is that the digraph alterations
    1447     /// should handled already on this level.
    1448     template <typename _Base = BaseDigraphComponent>
    1449     class ClearableDigraphComponent : public _Base {
    1450     public:
    1451 
    1452       typedef _Base Base;
     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;
    14531466
    14541467      /// \brief Erase all nodes and arcs from the digraph.
    14551468      ///
    1456       /// Erase all nodes and arcs from the digraph.
    1457       ///
     1469      /// This function erases all nodes and arcs from the digraph.
    14581470      void clear() {}
    14591471
     
    14651477        }
    14661478
    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() {}
    14821499
    14831500      template <typename _Graph>
    14841501      struct Constraints {
    14851502        void constraints() {
    1486           checkConcept<ClearableGraphComponent<Base>, _Graph>();
    1487         }
    1488 
    1489         _Graph graph;
     1503          checkConcept<Base, _Graph>();
     1504          graph.clear();
     1505        }
     1506
     1507        _Graph& graph;
    14901508      };
    14911509    };
  • lemon/concepts/heap.h

    r290 r631  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    2121///\brief The concept of heaps.
    2222
    23 #ifndef LEMON_CONCEPT_HEAP_H
    24 #define LEMON_CONCEPT_HEAP_H
     23#ifndef LEMON_CONCEPTS_HEAP_H
     24#define LEMON_CONCEPTS_HEAP_H
    2525
    2626#include <lemon/core.h>
     27#include <lemon/concept_check.h>
    2728
    2829namespace lemon {
     
    3536    /// \brief The heap concept.
    3637    ///
    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
    3954    class Heap {
    4055    public:
    4156
     57      /// Type of the item-int map.
     58      typedef IM ItemIntMap;
     59      /// Type of the priorities.
     60      typedef PR Prio;
    4261      /// Type of the items stored in the heap.
    4362      typedef typename ItemIntMap::Key Item;
    44 
    45       /// Type of the priorities.
    46       typedef Priority Prio;
    4763
    4864      /// \brief Type to represent the states of the items.
     
    5369      /// the user.
    5470      ///
    55       /// The \c ItemIntMap must be initialized in such a way, that it
    56       /// 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.
    5773      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.
    6177      };
    6278
     
    119135      ///
    120136      /// Returns the priority of the given item.
     137      /// \param i The item.
    121138      /// \pre \c i must be in the heap.
    122       /// \param i The item.
    123139      Prio operator[](const Item &i) const {}
    124140
     
    137153      ///
    138154      /// Decreases the priority of an item to the given value.
     155      /// \param i The item.
     156      /// \param p The priority.
    139157      /// \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.
    140163      /// \param i The item.
    141164      /// \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.
    147165      /// \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.
    150166      void increase(const Item &i, const Prio &p) {}
    151167
     
    243259  } // namespace lemon
    244260}
    245 #endif // LEMON_CONCEPT_PATH_H
     261#endif
  • lemon/concepts/maps.h

    r314 r576  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    1717 */
    1818
    19 #ifndef LEMON_CONCEPT_MAPS_H
    20 #define LEMON_CONCEPT_MAPS_H
     19#ifndef LEMON_CONCEPTS_MAPS_H
     20#define LEMON_CONCEPTS_MAPS_H
    2121
    2222#include <lemon/core.h>
     
    214214} //namespace lemon
    215215
    216 #endif // LEMON_CONCEPT_MAPS_H
     216#endif
  • lemon/concepts/path.h

    r281 r606  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    2222///
    2323
    24 #ifndef LEMON_CONCEPT_PATH_H
    25 #define LEMON_CONCEPT_PATH_H
     24#ifndef LEMON_CONCEPTS_PATH_H
     25#define LEMON_CONCEPTS_PATH_H
    2626
    2727#include <lemon/core.h>
     
    3939    /// A skeleton structure for representing directed paths in a
    4040    /// digraph.
    41     /// \tparam _Digraph The digraph type in which the path is.
     41    /// \tparam GR The digraph type in which the path is.
    4242    ///
    4343    /// In a sense, the path can be treated as a list of arcs. The
     
    4646    /// paths cannot store the source.
    4747    ///
    48     template <typename _Digraph>
     48    template <typename GR>
    4949    class Path {
    5050    public:
    5151
    5252      /// Type of the underlying digraph.
    53       typedef _Digraph Digraph;
     53      typedef GR Digraph;
    5454      /// Arc type of the underlying digraph.
    5555      typedef typename Digraph::Arc Arc;
     
    206206    /// assigned to a real path and the dumpers can be implemented as
    207207    /// an adaptor class to the predecessor map.
    208 
    209     /// \tparam _Digraph The digraph type in which the path is.
     208    ///
     209    /// \tparam GR The digraph type in which the path is.
    210210    ///
    211211    /// The paths can be constructed from any path type by a
    212212    /// template constructor or a template assignment operator.
    213     ///
    214     template <typename _Digraph>
     213    template <typename GR>
    215214    class PathDumper {
    216215    public:
    217216
    218217      /// Type of the underlying digraph.
    219       typedef _Digraph Digraph;
     218      typedef GR Digraph;
    220219      /// Arc type of the underlying digraph.
    221220      typedef typename Digraph::Arc Arc;
     
    306305} // namespace lemon
    307306
    308 #endif // LEMON_CONCEPT_PATH_H
     307#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
    110/* Define to 1 if you have CPLEX. */
    2 #undef HAVE_CPLEX
     11#undef LEMON_HAVE_CPLEX
    312
    413/* Define to 1 if you have GLPK. */
    5 #undef HAVE_GLPK
     14#undef LEMON_HAVE_GLPK
    615
    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  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    10351035  ///\sa findArc()
    10361036  ///\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
    10391041  public:
    10401042
    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;
    10461045
    10471046    /// \brief Constructor.
     
    10491048    /// Construct a new ConArcIt iterating on the arcs that
    10501049    /// connects nodes \c u and \c v.
    1051     ConArcIt(const Graph& g, Node u, Node v) : _graph(g) {
     1050    ConArcIt(const GR& g, Node u, Node v) : _graph(g) {
    10521051      Parent::operator=(findArc(_graph, u, v));
    10531052    }
     
    10561055    ///
    10571056    /// Construct a new ConArcIt that continues the iterating from arc \c a.
    1058     ConArcIt(const Graph& g, Arc a) : Parent(a), _graph(g) {}
     1057    ConArcIt(const GR& g, Arc a) : Parent(a), _graph(g) {}
    10591058
    10601059    /// \brief Increment operator.
     
    10671066    }
    10681067  private:
    1069     const Graph& _graph;
     1068    const GR& _graph;
    10701069  };
    10711070
     
    11581157  ///
    11591158  ///\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
    11621163  public:
    11631164
    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;
    11691167
    11701168    /// \brief Constructor.
     
    11721170    /// Construct a new ConEdgeIt iterating on the edges that
    11731171    /// connects nodes \c u and \c v.
    1174     ConEdgeIt(const Graph& 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) {
    11751173      Parent::operator=(findEdge(_graph, _u, _v));
    11761174    }
     
    11791177    ///
    11801178    /// Construct a new ConEdgeIt that continues iterating from edge \c e.
    1181     ConEdgeIt(const Graph& g, Edge e) : Parent(e), _graph(g) {}
     1179    ConEdgeIt(const GR& g, Edge e) : Parent(e), _graph(g) {}
    11821180
    11831181    /// \brief Increment operator.
     
    11891187    }
    11901188  private:
    1191     const Graph& _graph;
     1189    const GR& _graph;
    11921190    Node _u, _v;
    11931191  };
     
    12121210  ///queries.
    12131211  ///
    1214   ///\tparam G The type of the underlying digraph.
     1212  ///\tparam GR The type of the underlying digraph.
    12151213  ///
    12161214  ///\sa ArcLookUp
    12171215  ///\sa AllArcLookUp
    1218   template<class G>
     1216  template <typename GR>
    12191217  class DynArcLookUp
    1220     : protected ItemSetTraits<G, typename G::Arc>::ItemNotifier::ObserverBase
     1218    : protected ItemSetTraits<GR, typename GR::Arc>::ItemNotifier::ObserverBase
    12211219  {
     1220    typedef typename ItemSetTraits<GR, typename GR::Arc>
     1221    ::ItemNotifier::ObserverBase Parent;
     1222
     1223    TEMPLATE_DIGRAPH_TYPEDEFS(GR);
     1224
    12221225  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;
    12281229
    12291230  protected:
    12301231
    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
    12321235    public:
    12331236
    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) {}
    12371238
    12381239      virtual void add(const Node& node) {
     
    12571258      }
    12581259    };
    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;
    12651260
    12661261    class ArcLess {
     
    12741269    };
    12751270
     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
    12761279  public:
    12771280
     
    13161319    virtual void clear() {
    13171320      for(NodeIt n(_g);n!=INVALID;++n) {
    1318         _head.set(n, INVALID);
     1321        _head[n] = INVALID;
    13191322      }
    13201323    }
     
    13231326      Node s = _g.source(arc);
    13241327      Node t = _g.target(arc);
    1325       _left.set(arc, INVALID);
    1326       _right.set(arc, INVALID);
     1328      _left[arc] = INVALID;
     1329      _right[arc] = INVALID;
    13271330
    13281331      Arc e = _head[s];
    13291332      if (e == INVALID) {
    1330         _head.set(s, arc);
    1331         _parent.set(arc, INVALID);
     1333        _head[s] = arc;
     1334        _parent[arc] = INVALID;
    13321335        return;
    13331336      }
     
    13351338        if (t < _g.target(e)) {
    13361339          if (_left[e] == INVALID) {
    1337             _left.set(e, arc);
    1338             _parent.set(arc, e);
     1340            _left[e] = arc;
     1341            _parent[arc] = e;
    13391342            splay(arc);
    13401343            return;
     
    13441347        } else {
    13451348          if (_right[e] == INVALID) {
    1346             _right.set(e, arc);
    1347             _parent.set(arc, e);
     1349            _right[e] = arc;
     1350            _parent[arc] = e;
    13481351            splay(arc);
    13491352            return;
     
    13581361      if (_left[arc] == INVALID) {
    13591362        if (_right[arc] != INVALID) {
    1360           _parent.set(_right[arc], _parent[arc]);
     1363          _parent[_right[arc]] = _parent[arc];
    13611364        }
    13621365        if (_parent[arc] != INVALID) {
    13631366          if (_left[_parent[arc]] == arc) {
    1364             _left.set(_parent[arc], _right[arc]);
     1367            _left[_parent[arc]] = _right[arc];
    13651368          } else {
    1366             _right.set(_parent[arc], _right[arc]);
     1369            _right[_parent[arc]] = _right[arc];
    13671370          }
    13681371        } else {
    1369           _head.set(_g.source(arc), _right[arc]);
     1372          _head[_g.source(arc)] = _right[arc];
    13701373        }
    13711374      } else if (_right[arc] == INVALID) {
    1372         _parent.set(_left[arc], _parent[arc]);
     1375        _parent[_left[arc]] = _parent[arc];
    13731376        if (_parent[arc] != INVALID) {
    13741377          if (_left[_parent[arc]] == arc) {
    1375             _left.set(_parent[arc], _left[arc]);
     1378            _left[_parent[arc]] = _left[arc];
    13761379          } else {
    1377             _right.set(_parent[arc], _left[arc]);
     1380            _right[_parent[arc]] = _left[arc];
    13781381          }
    13791382        } else {
    1380           _head.set(_g.source(arc), _left[arc]);
     1383          _head[_g.source(arc)] = _left[arc];
    13811384        }
    13821385      } else {
     
    13881391          }
    13891392          Arc s = _parent[e];
    1390           _right.set(_parent[e], _left[e]);
     1393          _right[_parent[e]] = _left[e];
    13911394          if (_left[e] != INVALID) {
    1392             _parent.set(_left[e], _parent[e]);
     1395            _parent[_left[e]] = _parent[e];
    13931396          }
    13941397
    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];
    14011404          if (_parent[arc] != INVALID) {
    14021405            if (_left[_parent[arc]] == arc) {
    1403               _left.set(_parent[arc], e);
     1406              _left[_parent[arc]] = e;
    14041407            } else {
    1405               _right.set(_parent[arc], e);
     1408              _right[_parent[arc]] = e;
    14061409            }
    14071410          }
    14081411          splay(s);
    14091412        } 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];
    14131416
    14141417          if (_parent[arc] != INVALID) {
    14151418            if (_left[_parent[arc]] == arc) {
    1416               _left.set(_parent[arc], e);
     1419              _left[_parent[arc]] = e;
    14171420            } else {
    1418               _right.set(_parent[arc], e);
     1421              _right[_parent[arc]] = e;
    14191422            }
    14201423          } else {
    1421             _head.set(_g.source(arc), e);
     1424            _head[_g.source(arc)] = e;
    14221425          }
    14231426        }
     
    14311434      if (a < m) {
    14321435        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;
    14351438      } else {
    1436         _left.set(me, INVALID);
     1439        _left[me] = INVALID;
    14371440      }
    14381441      if (m < b) {
    14391442        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;
    14421445      } else {
    1443         _right.set(me, INVALID);
     1446        _right[me] = INVALID;
    14441447      }
    14451448      return me;
     
    14531456          std::sort(v.begin(),v.end(),ArcLess(_g));
    14541457          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;
    14591462      }
    14601463    }
     
    14621465    void zig(Arc v) {
    14631466      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;
    14681471      if (_parent[v] != INVALID) {
    14691472        if (_right[_parent[v]] == w) {
    1470           _right.set(_parent[v], v);
     1473          _right[_parent[v]] = v;
    14711474        } else {
    1472           _left.set(_parent[v], v);
     1475          _left[_parent[v]] = v;
    14731476        }
    14741477      }
    14751478      if (_left[w] != INVALID){
    1476         _parent.set(_left[w], w);
     1479        _parent[_left[w]] = w;
    14771480      }
    14781481    }
     
    14801483    void zag(Arc v) {
    14811484      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;
    14861489      if (_parent[v] != INVALID){
    14871490        if (_left[_parent[v]] == w) {
    1488           _left.set(_parent[v], v);
     1491          _left[_parent[v]] = v;
    14891492        } else {
    1490           _right.set(_parent[v], v);
     1493          _right[_parent[v]] = v;
    14911494        }
    14921495      }
    14931496      if (_right[w] != INVALID){
    1494         _parent.set(_right[w], w);
     1497        _parent[_right[w]] = w;
    14951498      }
    14961499    }
     
    16241627  ///(<em>O</em>(<em>m</em> log<em>m</em>)) to the number of arcs).
    16251628  ///
    1626   ///\tparam G The type of the underlying digraph.
     1629  ///\tparam GR The type of the underlying digraph.
    16271630  ///
    16281631  ///\sa DynArcLookUp
    16291632  ///\sa AllArcLookUp
    1630   template<class G>
     1633  template<class GR>
    16311634  class ArcLookUp
    16321635  {
     1636    TEMPLATE_DIGRAPH_TYPEDEFS(GR);
     1637
    16331638  public:
    1634     TEMPLATE_DIGRAPH_TYPEDEFS(G);
    1635     typedef G Digraph;
     1639
     1640    /// The Digraph type
     1641    typedef GR Digraph;
    16361642
    16371643  protected:
     
    17341740  ///(<em>O</em>(<em>m</em> log<em>m</em>)) to the number of arcs).
    17351741  ///
    1736   ///\tparam G The type of the underlying digraph.
     1742  ///\tparam GR The type of the underlying digraph.
    17371743  ///
    17381744  ///\sa DynArcLookUp
    17391745  ///\sa ArcLookUp
    1740   template<class G>
    1741   class AllArcLookUp : public ArcLookUp<G>
     1746  template<class GR>
     1747  class AllArcLookUp : public ArcLookUp<GR>
    17421748  {
    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;
    17521757
    17531758    Arc refreshNext(Arc head,Arc next=INVALID)
     
    17681773
    17691774  public:
     1775
     1776    /// The Digraph type
     1777    typedef GR Digraph;
     1778
    17701779    ///Constructor
    17711780
     
    17741783    ///It builds up the search database, which remains valid until the digraph
    17751784    ///changes.
    1776     AllArcLookUp(const Digraph &g) : ArcLookUp<G>(g), _next(g) {refreshNext();}
     1785    AllArcLookUp(const Digraph &g) : ArcLookUp<GR>(g), _next(g) {refreshNext();}
    17771786
    17781787    ///Refresh the data structure at a node.
     
    17841793    void refresh(Node n)
    17851794    {
    1786       ArcLookUp<G>::refresh(n);
     1795      ArcLookUp<GR>::refresh(n);
    17871796      refreshNext(_head[n]);
    17881797    }
     
    18311840    Arc operator()(Node s, Node t, Arc prev=INVALID) const {}
    18321841#else
    1833     using ArcLookUp<G>::operator() ;
     1842    using ArcLookUp<GR>::operator() ;
    18341843    Arc operator()(Node s, Node t, Arc prev) const
    18351844    {
  • lemon/counter.h

    r209 r463  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
  • lemon/dfs.h

    r319 r631  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    5050    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
    5151    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.
    5555    ///\param g is the digraph, to which we would like to define the
    56     ///PredMap.
     56    ///\ref PredMap.
    5757    static PredMap *createPredMap(const Digraph &g)
    5858    {
     
    6565    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
    6666    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.
    7070    ///\param g is the digraph, to which
    71     ///we would like to define the ProcessedMap
     71    ///we would like to define the \ref ProcessedMap.
    7272#ifdef DOXYGEN
    7373    static ProcessedMap *createProcessedMap(const Digraph &g)
     
    8484    ///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
    8585    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.
    8989    ///\param g is the digraph, to which
    90     ///we would like to define the ReachedMap.
     90    ///we would like to define the \ref ReachedMap.
    9191    static ReachedMap *createReachedMap(const Digraph &g)
    9292    {
     
    9999    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
    100100    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.
    104104    ///\param g is the digraph, to which we would like to define the
    105     ///DistMap.
     105    ///\ref DistMap.
    106106    static DistMap *createDistMap(const Digraph &g)
    107107    {
     
    120120  ///
    121121  ///\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.
    129123#ifdef DOXYGEN
    130124  template <typename GR,
     
    152146    typedef PredMapPath<Digraph, PredMap> Path;
    153147
    154     ///The traits class.
     148    ///The \ref DfsDefaultTraits "traits class" of the algorithm.
    155149    typedef TR Traits;
    156150
     
    213207    typedef Dfs Create;
    214208
    215     ///\name Named template parameters
     209    ///\name Named Template Parameters
    216210
    217211    ///@{
     
    227221    };
    228222    ///\brief \ref named-templ-param "Named parameter" for setting
    229     ///PredMap type.
     223    ///\c PredMap type.
    230224    ///
    231225    ///\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.
    233228    template <class T>
    234229    struct SetPredMap : public Dfs<Digraph, SetPredMapTraits<T> > {
     
    246241    };
    247242    ///\brief \ref named-templ-param "Named parameter" for setting
    248     ///DistMap type.
     243    ///\c DistMap type.
    249244    ///
    250245    ///\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.
    252248    template <class T>
    253249    struct SetDistMap : public Dfs< Digraph, SetDistMapTraits<T> > {
     
    265261    };
    266262    ///\brief \ref named-templ-param "Named parameter" for setting
    267     ///ReachedMap type.
     263    ///\c ReachedMap type.
    268264    ///
    269265    ///\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.
    271268    template <class T>
    272269    struct SetReachedMap : public Dfs< Digraph, SetReachedMapTraits<T> > {
     
    284281    };
    285282    ///\brief \ref named-templ-param "Named parameter" for setting
    286     ///ProcessedMap type.
     283    ///\c ProcessedMap type.
    287284    ///
    288285    ///\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.
    290288    template <class T>
    291289    struct SetProcessedMap : public Dfs< Digraph, SetProcessedMapTraits<T> > {
     
    301299    };
    302300    ///\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>.
    304302    ///
    305303    ///\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>.
    307305    ///If you don't set it explicitly, it will be automatically allocated.
    308306    struct SetStandardProcessedMap :
     
    339337
    340338    ///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.
    344343    ///\return <tt> (*this) </tt>
    345344    Dfs &predMap(PredMap &m)
     
    356355
    357356    ///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.
    361361    ///\return <tt> (*this) </tt>
    362362    Dfs &reachedMap(ReachedMap &m)
     
    373373
    374374    ///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.
    378379    ///\return <tt> (*this) </tt>
    379380    Dfs &processedMap(ProcessedMap &m)
     
    391392    ///Sets the map that stores the distances of the nodes calculated by
    392393    ///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.
    396398    ///\return <tt> (*this) </tt>
    397399    Dfs &distMap(DistMap &m)
     
    407409  public:
    408410
    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.
    418419
    419420    ///@{
    420421
     422    ///\brief Initializes the internal data structures.
     423    ///
    421424    ///Initializes the internal data structures.
    422 
    423     ///Initializes the internal data structures.
    424     ///
    425425    void init()
    426426    {
     
    439439    ///Adds a new source node to the set of nodes to be processed.
    440440    ///
    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.)
    446445    void addSource(Node s)
    447446    {
     
    507506    }
    508507
    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).
    514512    bool emptyQueue() const { return _stack_head<0; }
    515513
    516514    ///Returns the number of the nodes to be processed.
    517515
    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).
    519518    int queueSize() const { return _stack_head+1; }
    520519
     
    638637    ///
    639638    ///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.
    642641    ///
    643642    ///\note <tt>d.run()</tt> is just a shortcut of the following code.
     
    664663
    665664    ///\name Query Functions
    666     ///The result of the %DFS algorithm can be obtained using these
     665    ///The results of the DFS algorithm can be obtained using these
    667666    ///functions.\n
    668     ///Either \ref lemon::Dfs::run() "run()" or \ref lemon::Dfs::start()
    669     ///"start()" must be called before using them.
     667    ///Either \ref run(Node) "run()" or \ref start() should be called
     668    ///before using them.
    670669
    671670    ///@{
     
    675674    ///Returns the DFS path to a node.
    676675    ///
    677     ///\warning \c t should be reachable from the root.
    678     ///
    679     ///\pre Either \ref run() or \ref start() must be called before
    680     ///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.
    681680    Path path(Node t) const { return Path(*G, *_pred, t); }
    682681
    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 reachable from the root, then
     682    ///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
    688687    ///the return value of this function is undefined.
    689688    ///
    690     ///\pre Either \ref run() or \ref start() must be called before
    691     ///using this function.
     689    ///\pre Either \ref run(Node) "run()" or \ref init()
     690    ///must be called before using this function.
    692691    int dist(Node v) const { return (*_dist)[v]; }
    693692
     
    695694
    696695    ///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 the
    698     ///root to \c v. It is \c INVALID
    699     ///if \c v is not reachable from the root(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.
    700699    ///
    701700    ///The %DFS tree used here is equal to the %DFS tree used in
    702701    ///\ref predNode().
    703702    ///
    704     ///\pre Either \ref run() or \ref start() must be called before using
    705     ///this function.
     703    ///\pre Either \ref run(Node) "run()" or \ref init()
     704    ///must be called before using this function.
    706705    Arc predArc(Node v) const { return (*_pred)[v];}
    707706
     
    710709    ///This function returns the 'previous node' of the %DFS
    711710    ///tree for the node \c v, i.e. it returns the last but one node
    712     ///from a %DFS path from the root to \c v. It is \c INVALID
    713     ///if \c v is not reachable from 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.
    714713    ///
    715714    ///The %DFS tree used here is equal to the %DFS tree used in
    716715    ///\ref predArc().
    717716    ///
    718     ///\pre Either \ref run() or \ref start() must be called before
    719     ///using this function.
     717    ///\pre Either \ref run(Node) "run()" or \ref init()
     718    ///must be called before using this function.
    720719    Node predNode(Node v) const { return (*_pred)[v]==INVALID ? INVALID:
    721720                                  G->source((*_pred)[v]); }
     
    727726    ///distances of the nodes calculated by the algorithm.
    728727    ///
    729     ///\pre Either \ref run() or \ref init()
     728    ///\pre Either \ref run(Node) "run()" or \ref init()
    730729    ///must be called before using this function.
    731730    const DistMap &distMap() const { return *_dist;}
     
    737736    ///arcs, which form the DFS tree.
    738737    ///
    739     ///\pre Either \ref run() or \ref init()
     738    ///\pre Either \ref run(Node) "run()" or \ref init()
    740739    ///must be called before using this function.
    741740    const PredMap &predMap() const { return *_pred;}
    742741
    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()
    747747    ///must be called before using this function.
    748748    bool reached(Node v) const { return (*_reached)[v]; }
     
    890890  /// This auxiliary class is created to implement the
    891891  /// \ref dfs() "function-type interface" of \ref Dfs algorithm.
    892   /// It does not have own \ref run() method, it uses the functions
    893   /// 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.
    894894  ///
    895895  /// This class should only be used through the \ref dfs() function,
     
    11111111  ///  bool reached = dfs(g).path(p).dist(d).run(s,t);
    11121112  ///\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()"
    11151114  ///to the end of the parameter list.
    11161115  ///\sa DfsWizard
     
    11281127  /// This class defines the interface of the DfsVisit events, and
    11291128  /// it could be the base of a real visitor class.
    1130   template <typename _Digraph>
     1129  template <typename GR>
    11311130  struct DfsVisitor {
    1132     typedef _Digraph Digraph;
     1131    typedef GR Digraph;
    11331132    typedef typename Digraph::Arc Arc;
    11341133    typedef typename Digraph::Node Node;
     
    11661165  };
    11671166#else
    1168   template <typename _Digraph>
     1167  template <typename GR>
    11691168  struct DfsVisitor {
    1170     typedef _Digraph Digraph;
     1169    typedef GR Digraph;
    11711170    typedef typename Digraph::Arc Arc;
    11721171    typedef typename Digraph::Node Node;
     
    12011200  /// Default traits class of DfsVisit class.
    12021201  /// \tparam _Digraph The type of the digraph the algorithm runs on.
    1203   template<class _Digraph>
     1202  template<class GR>
    12041203  struct DfsVisitDefaultTraits {
    12051204
    12061205    /// \brief The type of the digraph the algorithm runs on.
    1207     typedef _Digraph Digraph;
     1206    typedef GR Digraph;
    12081207
    12091208    /// \brief The type of the map that indicates which nodes are reached.
     
    12261225  /// \ingroup search
    12271226  ///
    1228   /// \brief %DFS algorithm class with visitor interface.
     1227  /// \brief DFS algorithm class with visitor interface.
    12291228  ///
    1230   /// This class provides an efficient implementation of the %DFS algorithm
     1229  /// This class provides an efficient implementation of the DFS algorithm
    12311230  /// with visitor interface.
    12321231  ///
    1233   /// The %DfsVisit class provides an alternative interface to the Dfs
     1232  /// The DfsVisit class provides an alternative interface to the Dfs
    12341233  /// class. It works with callback mechanism, the DfsVisit object calls
    12351234  /// the member functions of the \c Visitor class on every DFS event.
     
    12401239  /// instead.
    12411240  ///
    1242   /// \tparam _Digraph The type of the digraph the algorithm runs on.
    1243   /// The default value is
    1244   /// \ref ListDigraph. The value of _Digraph is not used directly by
    1245   /// \ref DfsVisit, it is only passed to \ref DfsVisitDefaultTraits.
    1246   /// \tparam _Visitor The Visitor type that is used by the algorithm.
    1247   /// \ref DfsVisitor "DfsVisitor<_Digraph>" is an empty visitor, which
     1241  /// \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
    12481247  /// does not observe the DFS events. If you want to observe the DFS
    12491248  /// events, you should implement your own visitor class.
    1250   /// \tparam _Traits Traits class to set various data types used by the
     1249  /// \tparam TR Traits class to set various data types used by the
    12511250  /// algorithm. The default traits class is
    1252   /// \ref DfsVisitDefaultTraits "DfsVisitDefaultTraits<_Digraph>".
     1251  /// \ref DfsVisitDefaultTraits "DfsVisitDefaultTraits<GR>".
    12531252  /// See \ref DfsVisitDefaultTraits for the documentation of
    12541253  /// a DFS visit traits class.
    12551254#ifdef DOXYGEN
    1256   template <typename _Digraph, typename _Visitor, typename _Traits>
     1255  template <typename GR, typename VS, typename TR>
    12571256#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> >
    12611260#endif
    12621261  class DfsVisit {
     
    12641263
    12651264    ///The traits class.
    1266     typedef _Traits Traits;
     1265    typedef TR Traits;
    12671266
    12681267    ///The type of the digraph the algorithm runs on.
     
    12701269
    12711270    ///The visitor type used by the algorithm.
    1272     typedef _Visitor Visitor;
     1271    typedef VS Visitor;
    12731272
    12741273    ///The type of the map that indicates which nodes are reached.
     
    13101309    typedef DfsVisit Create;
    13111310
    1312     /// \name Named template parameters
     1311    /// \name Named Template Parameters
    13131312
    13141313    ///@{
     
    13521351    ///
    13531352    /// 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.
    13571357    /// \return <tt> (*this) </tt>
    13581358    DfsVisit &reachedMap(ReachedMap &m) {
     
    13671367  public:
    13681368
    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.
    13791377
    13801378    /// @{
     
    13921390    }
    13931391
    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.)
    14031400    void addSource(Node s)
    14041401    {
     
    14141411          } else {
    14151412            _visitor->leave(s);
     1413            _visitor->stop(s);
    14161414          }
    14171415        }
     
    15901588    ///
    15911589    /// 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.
    15941592    ///
    15951593    /// \note <tt>d.run()</tt> is just a shortcut of the following code.
     
    16161614
    16171615    /// \name Query Functions
    1618     /// The result of the %DFS algorithm can be obtained using these
     1616    /// The results of the DFS algorithm can be obtained using these
    16191617    /// functions.\n
    1620     /// Either \ref lemon::DfsVisit::run() "run()" or
    1621     /// \ref lemon::DfsVisit::start() "start()" must be called before
    1622     /// using them.
     1618    /// Either \ref run(Node) "run()" or \ref start() should be called
     1619    /// before using them.
     1620
    16231621    ///@{
    16241622
    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()
    16291628    /// must be called before using this function.
    1630     bool reached(Node v) { return (*_reached)[v]; }
     1629    bool reached(Node v) const { return (*_reached)[v]; }
    16311630
    16321631    ///@}
  • lemon/dijkstra.h

    r412 r631  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    3939  /// This operation traits class defines all computational operations and
    4040  /// constants which are used in the Dijkstra algorithm.
    41   template <typename Value>
     41  template <typename V>
    4242  struct DijkstraDefaultOperationTraits {
     43    /// \e
     44    typedef V Value;
    4345    /// \brief Gives back the zero value of the type.
    4446    static Value zero() {
     
    5961  ///Default traits class of Dijkstra class.
    6062  ///\tparam GR The type of the digraph.
    61   ///\tparam LM The 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>
    6365  struct DijkstraDefaultTraits
    6466  {
     
    7072    ///The type of the map that stores the arc lengths.
    7173    ///It must meet the \ref concepts::ReadMap "ReadMap" concept.
    72     typedef LM LengthMap;
     74    typedef LEN LengthMap;
    7375    ///The type of the length of the arcs.
    74     typedef typename LM::Value Value;
    75 
    76     /// Operation traits for Dijkstra algorithm.
     76    typedef typename LEN::Value Value;
     77
     78    /// Operation traits for %Dijkstra algorithm.
    7779
    7880    /// This class defines the operations that are used in the algorithm.
     
    8587    /// Usually it is \c Digraph::NodeMap<int>.
    8688    typedef typename Digraph::template NodeMap<int> HeapCrossRef;
    87     ///Instantiates a \ref HeapCrossRef.
     89    ///Instantiates a \c HeapCrossRef.
    8890
    8991    ///This function instantiates a \ref HeapCrossRef.
     
    9597    }
    9698
    97     ///The heap type used by the Dijkstra algorithm.
     99    ///The heap type used by the %Dijkstra algorithm.
    98100
    99101    ///The heap type used by the Dijkstra algorithm.
     
    101103    ///\sa BinHeap
    102104    ///\sa Dijkstra
    103     typedef BinHeap<typename LM::Value, HeapCrossRef, std::less<Value> > Heap;
    104     ///Instantiates a \ref Heap.
     105    typedef BinHeap<typename LEN::Value, HeapCrossRef, std::less<Value> > Heap;
     106    ///Instantiates a \c Heap.
    105107
    106108    ///This function instantiates a \ref Heap.
     
    117119    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
    118120    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.
    122124    ///\param g is the digraph, to which we would like to define the
    123     ///PredMap.
     125    ///\ref PredMap.
    124126    static PredMap *createPredMap(const Digraph &g)
    125127    {
     
    133135    ///By default it is a NullMap.
    134136    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.
    138140    ///\param g is the digraph, to which
    139     ///we would like to define the ProcessedMap
     141    ///we would like to define the \ref ProcessedMap.
    140142#ifdef DOXYGEN
    141143    static ProcessedMap *createProcessedMap(const Digraph &g)
     
    151153    ///The type of the map that stores the distances of the nodes.
    152154    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
    153     typedef typename Digraph::template NodeMap<typename LM::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.
    157159    ///\param g is the digraph, to which we would like to define
    158     ///the DistMap
     160    ///the \ref DistMap.
    159161    static DistMap *createDistMap(const Digraph &g)
    160162    {
     
    180182  ///
    181183  ///\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
    187188  ///relatively time consuming process to compute the arc lengths if
    188189  ///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>".
    196191#ifdef DOXYGEN
    197   template <typename GR, typename LM, typename TR>
     192  template <typename GR, typename LEN, typename TR>
    198193#else
    199194  template <typename GR=ListDigraph,
    200             typename LM=typename GR::template ArcMap<int>,
    201             typename TR=DijkstraDefaultTraits<GR,LM> >
     195            typename LEN=typename GR::template ArcMap<int>,
     196            typename TR=DijkstraDefaultTraits<GR,LEN> >
    202197#endif
    203198  class Dijkstra {
     
    224219    ///The heap type used by the algorithm.
    225220    typedef typename TR::Heap Heap;
    226     ///The operation traits class.
     221    ///\brief The \ref DijkstraDefaultOperationTraits "operation traits class"
     222    ///of the algorithm.
    227223    typedef typename TR::OperationTraits OperationTraits;
    228224
    229     ///The traits class.
     225    ///The \ref DijkstraDefaultTraits "traits class" of the algorithm.
    230226    typedef TR Traits;
    231227
     
    240236    const Digraph *G;
    241237    //Pointer to the length map.
    242     const LengthMap *length;
     238    const LengthMap *_length;
    243239    //Pointer to the map of predecessors arcs.
    244240    PredMap *_pred;
     
    291287    typedef Dijkstra Create;
    292288
    293     ///\name Named template parameters
     289    ///\name Named Template Parameters
    294290
    295291    ///@{
     
    305301    };
    306302    ///\brief \ref named-templ-param "Named parameter" for setting
    307     ///PredMap type.
     303    ///\c PredMap type.
    308304    ///
    309305    ///\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.
    311308    template <class T>
    312309    struct SetPredMap
     
    325322    };
    326323    ///\brief \ref named-templ-param "Named parameter" for setting
    327     ///DistMap type.
     324    ///\c DistMap type.
    328325    ///
    329326    ///\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.
    331329    template <class T>
    332330    struct SetDistMap
     
    345343    };
    346344    ///\brief \ref named-templ-param "Named parameter" for setting
    347     ///ProcessedMap type.
     345    ///\c ProcessedMap type.
    348346    ///
    349347    ///\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.
    351350    template <class T>
    352351    struct SetProcessedMap
     
    363362    };
    364363    ///\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>.
    366365    ///
    367366    ///\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>.
    369368    ///If you don't set it explicitly, it will be automatically allocated.
    370369    struct SetStandardProcessedMap
     
    389388    };
    390389    ///\brief \ref named-templ-param "Named parameter" for setting
    391     ///heap and cross reference type
     390    ///heap and cross reference types
    392391    ///
    393392    ///\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
    395398    template <class H, class CR = typename Digraph::template NodeMap<int> >
    396399    struct SetHeap
     
    412415    };
    413416    ///\brief \ref named-templ-param "Named parameter" for setting
    414     ///heap and cross reference type with automatic allocation
     417    ///heap and cross reference types with automatic allocation
    415418    ///
    416419    ///\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
    420429    template <class H, class CR = typename Digraph::template NodeMap<int> >
    421430    struct SetStandardHeap
     
    434443    ///
    435444    ///\ref named-templ-param "Named parameter" for setting
    436     ///\ref OperationTraits type.
     445    ///\c OperationTraits type.
    437446    template <class T>
    438447    struct SetOperationTraits
     
    453462
    454463    ///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),
    459468      _pred(NULL), local_pred(false),
    460469      _dist(NULL), local_dist(false),
     
    480489    Dijkstra &lengthMap(const LengthMap &m)
    481490    {
    482       length = &m;
     491      _length = &m;
    483492      return *this;
    484493    }
     
    487496
    488497    ///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.
    492502    ///\return <tt> (*this) </tt>
    493503    Dijkstra &predMap(PredMap &m)
     
    504514
    505515    ///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.
    509520    ///\return <tt> (*this) </tt>
    510521    Dijkstra &processedMap(ProcessedMap &m)
     
    522533    ///Sets the map that stores the distances of the nodes calculated by the
    523534    ///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.
    527539    ///\return <tt> (*this) </tt>
    528540    Dijkstra &distMap(DistMap &m)
     
    539551
    540552    ///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.
    544558    ///\return <tt> (*this) </tt>
    545559    Dijkstra &heap(Heap& hp, HeapCrossRef &cr)
     
    568582  public:
    569583
    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.
    579591
    580592    ///@{
    581593
     594    ///\brief Initializes the internal data structures.
     595    ///
    582596    ///Initializes the internal data structures.
    583 
    584     ///Initializes the internal data structures.
    585     ///
    586597    void init()
    587598    {
     
    631642        switch(_heap->state(w)) {
    632643        case Heap::PRE_HEAP:
    633           _heap->push(w,OperationTraits::plus(oldvalue, (*length)[e]));
     644          _heap->push(w,OperationTraits::plus(oldvalue, (*_length)[e]));
    634645          _pred->set(w,e);
    635646          break;
    636647        case Heap::IN_HEAP:
    637648          {
    638             Value newvalue = OperationTraits::plus(oldvalue, (*length)[e]);
     649            Value newvalue = OperationTraits::plus(oldvalue, (*_length)[e]);
    639650            if ( OperationTraits::less(newvalue, (*_heap)[w]) ) {
    640651              _heap->decrease(w, newvalue);
     
    659670    }
    660671
    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.
    666676    bool emptyQueue() const { return _heap->empty(); }
    667677
    668     ///Returns the number of the nodes to be processed in the priority heap
    669 
    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.
    672682    int queueSize() const { return _heap->size(); }
    673683
     
    790800
    791801    ///\name Query Functions
    792     ///The result of the %Dijkstra algorithm can be obtained using these
     802    ///The results of the %Dijkstra algorithm can be obtained using these
    793803    ///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.
    797806
    798807    ///@{
     
    802811    ///Returns the shortest path to a node.
    803812    ///
    804     ///\warning \c t should be reachable from the root(s).
    805     ///
    806     ///\pre Either \ref run() or \ref start() must be called before
    807     ///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.
    808817    Path path(Node t) const { return Path(*G, *_pred, t); }
    809818
     
    812821    ///Returns the distance of a node from the root(s).
    813822    ///
    814     ///\warning If node \c v is not reachable from the root(s), then
     823    ///\warning If node \c v is not reached from the root(s), then
    815824    ///the return value of this function is undefined.
    816825    ///
    817     ///\pre Either \ref run() or \ref start() must be called before
    818     ///using this function.
     826    ///\pre Either \ref run(Node) "run()" or \ref init()
     827    ///must be called before using this function.
    819828    Value dist(Node v) const { return (*_dist)[v]; }
    820829
     
    823832    ///This function returns the 'previous arc' of the shortest path
    824833    ///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 v
    826     ///is not reachable from 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.
    827836    ///
    828837    ///The shortest path tree used here is equal to the shortest path
    829838    ///tree used in \ref predNode().
    830839    ///
    831     ///\pre Either \ref run() or \ref start() must be called before
    832     ///using this function.
     840    ///\pre Either \ref run(Node) "run()" or \ref init()
     841    ///must be called before using this function.
    833842    Arc predArc(Node v) const { return (*_pred)[v]; }
    834843
     
    837846    ///This function returns the 'previous node' of the shortest path
    838847    ///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 INVALID
    840     ///if \c v is not reachable from 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.
    841850    ///
    842851    ///The shortest path tree used here is equal to the shortest path
    843852    ///tree used in \ref predArc().
    844853    ///
    845     ///\pre Either \ref run() or \ref start() must be called before
    846     ///using this function.
     854    ///\pre Either \ref run(Node) "run()" or \ref init()
     855    ///must be called before using this function.
    847856    Node predNode(Node v) const { return (*_pred)[v]==INVALID ? INVALID:
    848857                                  G->source((*_pred)[v]); }
     
    854863    ///of the nodes calculated by the algorithm.
    855864    ///
    856     ///\pre Either \ref run() or \ref init()
     865    ///\pre Either \ref run(Node) "run()" or \ref init()
    857866    ///must be called before using this function.
    858867    const DistMap &distMap() const { return *_dist;}
     
    864873    ///arcs, which form the shortest path tree.
    865874    ///
    866     ///\pre Either \ref run() or \ref init()
     875    ///\pre Either \ref run(Node) "run()" or \ref init()
    867876    ///must be called before using this function.
    868877    const PredMap &predMap() const { return *_pred;}
    869878
    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()
    874884    ///must be called before using this function.
    875885    bool reached(Node v) const { return (*_heap_cross_ref)[v] !=
     
    880890    ///Returns \c true if \c v is processed, i.e. the shortest
    881891    ///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()
    883894    ///must be called before using this function.
    884895    bool processed(Node v) const { return (*_heap_cross_ref)[v] ==
     
    889900    ///Returns the current distance of a node from the root(s).
    890901    ///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()
    892904    ///must be called before using this function and
    893905    ///node \c v must be reached but not necessarily processed.
     
    904916  ///Default traits class of dijkstra() function.
    905917  ///\tparam GR The type of the digraph.
    906   ///\tparam LM The type of the length map.
    907   template<class GR, class LM>
     918  ///\tparam LEN The type of the length map.
     919  template<class GR, class LEN>
    908920  struct DijkstraWizardDefaultTraits
    909921  {
     
    914926    ///The type of the map that stores the arc lengths.
    915927    ///It must meet the \ref concepts::ReadMap "ReadMap" concept.
    916     typedef LM LengthMap;
     928    typedef LEN LengthMap;
    917929    ///The type of the length of the arcs.
    918     typedef typename LM::Value Value;
     930    typedef typename LEN::Value Value;
    919931
    920932    /// Operation traits for Dijkstra algorithm.
     
    9981010    ///The type of the map that stores the distances of the nodes.
    9991011    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
    1000     typedef typename Digraph::template NodeMap<typename LM::Value> DistMap;
     1012    typedef typename Digraph::template NodeMap<typename LEN::Value> DistMap;
    10011013    ///Instantiates a DistMap.
    10021014
     
    10241036  /// The \ref DijkstraWizardBase is a class to be the default traits of the
    10251037  /// \ref DijkstraWizard class.
    1026   template<class GR,class LM>
    1027   class DijkstraWizardBase : public DijkstraWizardDefaultTraits<GR,LM>
     1038  template<typename GR, typename LEN>
     1039  class DijkstraWizardBase : public DijkstraWizardDefaultTraits<GR,LEN>
    10281040  {
    1029     typedef DijkstraWizardDefaultTraits<GR,LM> Base;
     1041    typedef DijkstraWizardDefaultTraits<GR,LEN> Base;
    10301042  protected:
    10311043    //The type of the nodes in the digraph.
     
    10611073    /// \param g The digraph the algorithm runs on.
    10621074    /// \param l The length map.
    1063     DijkstraWizardBase(const GR &g,const LM &l) :
     1075    DijkstraWizardBase(const GR &g,const LEN &l) :
    10641076      _g(reinterpret_cast<void*>(const_cast<GR*>(&g))),
    1065       _length(reinterpret_cast<void*>(const_cast<LM*>(&l))),
     1077      _length(reinterpret_cast<void*>(const_cast<LEN*>(&l))),
    10661078      _processed(0), _pred(0), _dist(0), _path(0), _di(0) {}
    10671079
     
    10721084  /// This auxiliary class is created to implement the
    10731085  /// \ref dijkstra() "function-type interface" of \ref Dijkstra algorithm.
    1074   /// It does not have own \ref run() method, it uses the functions
    1075   /// 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.
    10761088  ///
    10771089  /// This class should only be used through the \ref dijkstra() function,
     
    12681280  ///  bool reached = dijkstra(g,length).path(p).dist(d).run(s,t);
    12691281  ///\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()"
    12711283  ///to the end of the parameter list.
    12721284  ///\sa DijkstraWizard
    12731285  ///\sa Dijkstra
    1274   template<class GR, class LM>
    1275   DijkstraWizard<DijkstraWizardBase<GR,LM> >
    1276   dijkstra(const GR &digraph, const LM &length)
     1286  template<typename GR, typename LEN>
     1287  DijkstraWizard<DijkstraWizardBase<GR,LEN> >
     1288  dijkstra(const GR &digraph, const LEN &length)
    12771289  {
    1278     return DijkstraWizard<DijkstraWizardBase<GR,LM> >(digraph,length);
     1290    return DijkstraWizard<DijkstraWizardBase<GR,LEN> >(digraph,length);
    12791291  }
    12801292
  • lemon/dim2.h

    r314 r463  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
  • lemon/error.h

    r291 r463  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
  • lemon/graph_to_eps.h

    r511 r664  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    6565///Default traits class of \ref GraphToEps.
    6666///
    67 ///\c G is the type of the underlying graph.
    68 template<class G>
     67///\param GR is the type of the underlying graph.
     68template<class GR>
    6969struct DefaultGraphToEpsTraits
    7070{
    71   typedef G Graph;
     71  typedef GR Graph;
     72  typedef GR Digraph;
    7273  typedef typename Graph::Node Node;
    7374  typedef typename Graph::NodeIt NodeIt;
     
    140141
    141142  ///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.
    145145  ///By default it is <tt>std::cout</tt>.
    146   ///\param _pros If it is \c true, then the \c ostream referenced by \c _os
     146  ///\param pros If it is \c true, then the \c ostream referenced by \c os
    147147  ///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),
    151151    _coords(dim2::Point<double>(1,1)), _nodeSizes(1), _nodeShapes(0),
    152152    _nodeColors(WHITE), _arcColors(BLACK),
     
    159159    _showNodeText(false), _nodeTexts(false), _nodeTextSize(1),
    160160    _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),
    163163    _nodeTextColorType(SAME_COL), _nodeTextColors(BLACK),
    164164    _autoNodeScale(false),
     
    243243
    244244  typedef typename T::Graph Graph;
     245  typedef typename T::Digraph Digraph;
    245246  typedef typename Graph::Node Node;
    246247  typedef typename Graph::NodeIt NodeIt;
     
    270271    ///\image html nodeshape_1.png
    271272    ///\image latex nodeshape_1.eps "SQUARE shape (1)" width=2cm
    272     ///
    273273    SQUARE=1,
    274274    /// = 2
    275275    ///\image html nodeshape_2.png
    276276    ///\image latex nodeshape_2.eps "DIAMOND shape (2)" width=2cm
    277     ///
    278277    DIAMOND=2,
    279278    /// = 3
    280279    ///\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
    283281    MALE=3,
    284282    /// = 4
    285283    ///\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
    288285    FEMALE=4
    289286  };
     
    11351132///to the end of the parameter list.
    11361133///\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)
     1135template<class GR>
     1136GraphToEps<DefaultGraphToEpsTraits<GR> >
     1137graphToEps(GR &g, std::ostream& os=std::cout)
    11411138{
    11421139  return
    1143     GraphToEps<DefaultGraphToEpsTraits<G> >(DefaultGraphToEpsTraits<G>(g,os));
     1140    GraphToEps<DefaultGraphToEpsTraits<GR> >(DefaultGraphToEpsTraits<GR>(g,os));
    11441141}
    11451142
     
    11481145///\ingroup eps_io
    11491146///This function does the same as
    1150 ///\ref graphToEps(G &g,std::ostream& os)
     1147///\ref graphToEps(GR &g,std::ostream& os)
    11511148///but it writes its output into the file \c file_name
    11521149///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)
     1151template<class GR>
     1152GraphToEps<DefaultGraphToEpsTraits<GR> >
     1153graphToEps(GR &g,const char *file_name)
    11571154{
    11581155  std::ostream* os = new std::ofstream(file_name);
     
    11611158    throw IoError("Cannot write file", file_name);
    11621159  }
    1163   return GraphToEps<DefaultGraphToEpsTraits<G> >
    1164     (DefaultGraphToEpsTraits<G>(g,*os,true));
     1160  return GraphToEps<DefaultGraphToEpsTraits<GR> >
     1161    (DefaultGraphToEpsTraits<GR>(g,*os,true));
    11651162}
    11661163
     
    11691166///\ingroup eps_io
    11701167///This function does the same as
    1171 ///\ref graphToEps(G &g,std::ostream& os)
     1168///\ref graphToEps(GR &g,std::ostream& os)
    11721169///but it writes its output into the file \c file_name
    11731170///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)
     1172template<class GR>
     1173GraphToEps<DefaultGraphToEpsTraits<GR> >
     1174graphToEps(GR &g,const std::string& file_name)
    11781175{
    11791176  std::ostream* os = new std::ofstream(file_name.c_str());
     
    11821179    throw IoError("Cannot write file", file_name);
    11831180  }
    1184   return GraphToEps<DefaultGraphToEpsTraits<G> >
    1185     (DefaultGraphToEpsTraits<G>(g,*os,true));
     1181  return GraphToEps<DefaultGraphToEpsTraits<GR> >
     1182    (DefaultGraphToEpsTraits<GR>(g,*os,true));
    11861183}
    11871184
  • lemon/kruskal.h

    r220 r631  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    249249  /// \ingroup spantree
    250250  ///
    251   /// \brief Kruskal algorithm to find a minimum cost spanning tree of
     251  /// \brief Kruskal's algorithm for finding a minimum cost spanning tree of
    252252  /// a graph.
    253253  ///
    254254  /// This function runs Kruskal's algorithm to find a minimum cost
    255   /// spanning tree.
     255  /// spanning tree of a graph.
    256256  /// Due to some C++ hacking, it accepts various input and output types.
    257257  ///
     
    265265  /// It can be one of the following choices.
    266266  /// - An STL compatible 'Forward Container' with
    267   /// <tt>std::pair<GR::Arc,X></tt> or
    268   /// <tt>std::pair<GR::Edge,X></tt> as its <tt>value_type</tt>, where
    269   /// \c X is the type of the costs. The pairs indicates the arcs/edges
     267  /// <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
    270270  /// along with the assigned cost. <em>They must be in a
    271271  /// cost-ascending order.</em>
     
    274274  ///
    275275  /// \retval out Here we also have a choice.
    276   /// - It can be a writable \c bool arc/edge map. After running the
    277   /// algorithm it will contain the found minimum cost spanning
     276  /// - 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
    278278  /// tree: the value of an arc/edge will be set to \c true if it belongs
    279279  /// to the tree, otherwise it will be set to \c false. The value of
     
    302302
    303303#ifdef DOXYGEN
    304   template <class Graph, class In, class Out>
    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)
    306306#else
    307307  template <class Graph, class In, class Out>
     
    315315
    316316
    317 
    318 
    319317  template <class Graph, class In, class Out>
    320318  inline typename _kruskal_bits::KruskalValueSelector<In>::Value
  • lemon/lgf_reader.h

    r517 r646  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    102102    };
    103103
    104     template <typename _Graph, bool _dir, typename _Map,
     104    template <typename _GR, bool _dir, typename _Map,
    105105              typename _Converter = DefaultConverter<typename _Map::Value> >
    106     class GraphArcMapStorage : public MapStorageBase<typename _Graph::Edge> {
     106    class GraphArcMapStorage : public MapStorageBase<typename _GR::Edge> {
    107107    public:
    108108      typedef _Map Map;
    109109      typedef _Converter Converter;
    110       typedef _Graph Graph;
    111       typedef typename Graph::Edge Item;
     110      typedef _GR GR;
     111      typedef typename GR::Edge Item;
    112112      static const bool dir = _dir;
    113113
    114114    private:
    115       const Graph& _graph;
     115      const GR& _graph;
    116116      Map& _map;
    117117      Converter _converter;
    118118
    119119    public:
    120       GraphArcMapStorage(const Graph& graph, Map& map,
     120      GraphArcMapStorage(const GR& graph, Map& map,
    121121                         const Converter& converter = Converter())
    122122        : _graph(graph), _map(map), _converter(converter) {}
     
    174174    };
    175175
    176     template <typename Graph>
     176    template <typename GR>
    177177    struct GraphArcLookUpConverter {
    178       const Graph& _graph;
    179       const std::map<std::string, typename Graph::Edge>& _map;
    180 
    181       GraphArcLookUpConverter(const Graph& graph,
     178      const GR& _graph;
     179      const std::map<std::string, typename GR::Edge>& _map;
     180
     181      GraphArcLookUpConverter(const GR& graph,
    182182                              const std::map<std::string,
    183                                              typename Graph::Edge>& map)
     183                                             typename GR::Edge>& map)
    184184        : _graph(graph), _map(map) {}
    185185
    186       typename Graph::Arc operator()(const std::string& str) {
     186      typename GR::Arc operator()(const std::string& str) {
    187187        if (str.empty() || (str[0] != '+' && str[0] != '-')) {
    188188          throw FormatError("Item must start with '+' or '-'");
    189189        }
    190         typename std::map<std::string, typename Graph::Edge>
     190        typename std::map<std::string, typename GR::Edge>
    191191          ::const_iterator it = _map.find(str.substr(1));
    192192        if (it == _map.end()) {
     
    388388  }
    389389
    390   template <typename Digraph>
     390  template <typename DGR>
    391391  class DigraphReader;
    392392
    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);
    400399
    401400  /// \ingroup lemon_io
     
    420419  ///
    421420  ///\code
    422   /// DigraphReader<Digraph>(digraph, std::cin).
     421  /// DigraphReader<DGR>(digraph, std::cin).
    423422  ///   nodeMap("coordinates", coord_map).
    424423  ///   arcMap("capacity", cap_map).
     
    449448  /// a single pass, because the arcs are not constructed when the node
    450449  /// maps are read.
    451   template <typename _Digraph>
     450  template <typename DGR>
    452451  class DigraphReader {
    453452  public:
    454453
    455     typedef _Digraph Digraph;
    456     TEMPLATE_DIGRAPH_TYPEDEFS(Digraph);
     454    typedef DGR Digraph;
    457455
    458456  private:
    459457
     458    TEMPLATE_DIGRAPH_TYPEDEFS(DGR);
    460459
    461460    std::istream* _is;
     
    463462    std::string _filename;
    464463
    465     Digraph& _digraph;
     464    DGR& _digraph;
    466465
    467466    std::string _nodes_caption;
     
    501500    /// Construct a directed graph reader, which reads from the given
    502501    /// input stream.
    503     DigraphReader(Digraph& digraph, std::istream& is = std::cin)
     502    DigraphReader(DGR& digraph, std::istream& is = std::cin)
    504503      : _is(&is), local_is(false), _digraph(digraph),
    505504        _use_nodes(false), _use_arcs(false),
     
    510509    /// Construct a directed graph reader, which reads from the given
    511510    /// file.
    512     DigraphReader(Digraph& digraph, const std::string& fn)
     511    DigraphReader(DGR& digraph, const std::string& fn)
    513512      : _is(new std::ifstream(fn.c_str())), local_is(true),
    514513        _filename(fn), _digraph(digraph),
     
    525524    /// Construct a directed graph reader, which reads from the given
    526525    /// file.
    527     DigraphReader(Digraph& digraph, const char* fn)
     526    DigraphReader(DGR& digraph, const char* fn)
    528527      : _is(new std::ifstream(fn)), local_is(true),
    529528        _filename(fn), _digraph(digraph),
     
    561560  private:
    562561
    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);
    570569
    571570    DigraphReader(DigraphReader& other)
     
    594593  public:
    595594
    596     /// \name Reading rules
     595    /// \name Reading Rules
    597596    /// @{
    598597
     
    699698    /// @}
    700699
    701     /// \name Select section by name
     700    /// \name Select Section by Name
    702701    /// @{
    703702
     
    728727    /// @}
    729728
    730     /// \name Using previously constructed node or arc set
     729    /// \name Using Previously Constructed Node or Arc Set
    731730    /// @{
    732731
     
    848847        readLine();
    849848      }
    850       line.putback(c);
     849      if (readSuccess()) {
     850        line.putback(c);
     851      }
    851852    }
    852853
     
    11151116  public:
    11161117
    1117     /// \name Execution of the reader
     1118    /// \name Execution of the Reader
    11181119    /// @{
    11191120
     
    11871188
    11881189  };
     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  }
    11891227
    11901228  /// \brief Return a \ref DigraphReader class
     
    11921230  /// This function just returns a \ref DigraphReader class.
    11931231  /// \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);
    11971236    return tmp;
    11981237  }
     
    12021241  /// This function just returns a \ref DigraphReader class.
    12031242  /// \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);
    12081247    return tmp;
    12091248  }
    12101249
    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>
    12221251  class GraphReader;
    12231252 
    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);
    12311259
    12321260  /// \ingroup lemon_io
     
    12451273  /// arc map.  Similarly, an attribute can be read into an arc, if
    12461274  /// it's value is an edge label prefixed with \c '+' or \c '-'.
    1247   template <typename _Graph>
     1275  template <typename GR>
    12481276  class GraphReader {
    12491277  public:
    12501278
    1251     typedef _Graph Graph;
    1252     TEMPLATE_GRAPH_TYPEDEFS(Graph);
     1279    typedef GR Graph;
    12531280
    12541281  private:
     1282
     1283    TEMPLATE_GRAPH_TYPEDEFS(GR);
    12551284
    12561285    std::istream* _is;
     
    12581287    std::string _filename;
    12591288
    1260     Graph& _graph;
     1289    GR& _graph;
    12611290
    12621291    std::string _nodes_caption;
     
    12961325    /// Construct an undirected graph reader, which reads from the given
    12971326    /// input stream.
    1298     GraphReader(Graph& graph, std::istream& is = std::cin)
     1327    GraphReader(GR& graph, std::istream& is = std::cin)
    12991328      : _is(&is), local_is(false), _graph(graph),
    13001329        _use_nodes(false), _use_edges(false),
     
    13051334    /// Construct an undirected graph reader, which reads from the given
    13061335    /// file.
    1307     GraphReader(Graph& graph, const std::string& fn)
     1336    GraphReader(GR& graph, const std::string& fn)
    13081337      : _is(new std::ifstream(fn.c_str())), local_is(true),
    13091338        _filename(fn), _graph(graph),
     
    13201349    /// Construct an undirected graph reader, which reads from the given
    13211350    /// file.
    1322     GraphReader(Graph& graph, const char* fn)
     1351    GraphReader(GR& graph, const char* fn)
    13231352      : _is(new std::ifstream(fn)), local_is(true),
    13241353        _filename(fn), _graph(graph),
     
    13551384
    13561385  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);
    13631392
    13641393    GraphReader(GraphReader& other)
     
    13871416  public:
    13881417
    1389     /// \name Reading rules
     1418    /// \name Reading Rules
    13901419    /// @{
    13911420
     
    14521481      _edge_maps.push_back(std::make_pair('+' + caption, forward_storage));
    14531482      _reader_bits::MapStorageBase<Edge>* backward_storage =
    1454         new _reader_bits::GraphArcMapStorage<Graph, false, Map>(_graph, map);
     1483        new _reader_bits::GraphArcMapStorage<GR, false, Map>(_graph, map);
    14551484      _edge_maps.push_back(std::make_pair('-' + caption, backward_storage));
    14561485      return *this;
     
    14661495      checkConcept<concepts::WriteMap<Arc, typename Map::Value>, Map>();
    14671496      _reader_bits::MapStorageBase<Edge>* forward_storage =
    1468         new _reader_bits::GraphArcMapStorage<Graph, true, Map, Converter>
     1497        new _reader_bits::GraphArcMapStorage<GR, true, Map, Converter>
    14691498        (_graph, map, converter);
    14701499      _edge_maps.push_back(std::make_pair('+' + caption, forward_storage));
    14711500      _reader_bits::MapStorageBase<Edge>* backward_storage =
    1472         new _reader_bits::GraphArcMapStorage<Graph, false, Map, Converter>
     1501        new _reader_bits::GraphArcMapStorage<GR, false, Map, Converter>
    14731502        (_graph, map, converter);
    14741503      _edge_maps.push_back(std::make_pair('-' + caption, backward_storage));
     
    15281557    /// Add an arc reading rule to reader.
    15291558    GraphReader& arc(const std::string& caption, Arc& arc) {
    1530       typedef _reader_bits::GraphArcLookUpConverter<Graph> Converter;
     1559      typedef _reader_bits::GraphArcLookUpConverter<GR> Converter;
    15311560      Converter converter(_graph, _edge_index);
    15321561      _reader_bits::ValueStorageBase* storage =
     
    15381567    /// @}
    15391568
    1540     /// \name Select section by name
     1569    /// \name Select Section by Name
    15411570    /// @{
    15421571
     
    15671596    /// @}
    15681597
    1569     /// \name Using previously constructed node or edge set
     1598    /// \name Using Previously Constructed Node or Edge Set
    15701599    /// @{
    15711600
     
    16881717        readLine();
    16891718      }
    1690       line.putback(c);
     1719      if (readSuccess()) {
     1720        line.putback(c);
     1721      }
    16911722    }
    16921723
     
    19551986  public:
    19561987
    1957     /// \name Execution of the reader
     1988    /// \name Execution of the Reader
    19581989    /// @{
    19591990
     
    20292060  };
    20302061
     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
    20312095  /// \brief Return a \ref GraphReader class
    20322096  ///
    20332097  /// This function just returns a \ref GraphReader class.
    20342098  /// \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);
    20382103    return tmp;
    20392104  }
     
    20432108  /// This function just returns a \ref GraphReader class.
    20442109  /// \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);
    20582114    return tmp;
    20592115  }
     
    21542210  public:
    21552211
    2156     /// \name Section readers
     2212    /// \name Section Readers
    21572213    /// @{
    21582214
     
    22452301        readLine();
    22462302      }
    2247       line.putback(c);
     2303      if (readSuccess()) {
     2304        line.putback(c);
     2305      }
    22482306    }
    22492307
     
    22512309
    22522310
    2253     /// \name Execution of the reader
     2311    /// \name Execution of the Reader
    22542312    /// @{
    22552313
     
    23102368  };
    23112369
     2370  /// \ingroup lemon_io
     2371  ///
    23122372  /// \brief Return a \ref SectionReader class
    23132373  ///
    23142374  /// This function just returns a \ref SectionReader class.
     2375  ///
     2376  /// Please see SectionReader documentation about the custom section
     2377  /// input.
     2378  ///
    23152379  /// \relates SectionReader
     2380  /// \sa sectionReader(const std::string& fn)
     2381  /// \sa sectionReader(const char *fn)
    23162382  inline SectionReader sectionReader(std::istream& is) {
    23172383    SectionReader tmp(is);
     
    23232389  /// This function just returns a \ref SectionReader class.
    23242390  /// \relates SectionReader
     2391  /// \sa sectionReader(std::istream& is)
    23252392  inline SectionReader sectionReader(const std::string& fn) {
    23262393    SectionReader tmp(fn);
     
    23322399  /// This function just returns a \ref SectionReader class.
    23332400  /// \relates SectionReader
     2401  /// \sa sectionReader(std::istream& is)
    23342402  inline SectionReader sectionReader(const char* fn) {
    23352403    SectionReader tmp(fn);
     
    24332501
    24342502
    2435     /// \name Node sections
     2503    /// \name Node Sections
    24362504    /// @{
    24372505
     
    24592527    /// @}
    24602528
    2461     /// \name Arc/Edge sections
     2529    /// \name Arc/Edge Sections
    24622530    /// @{
    24632531
     
    25172585    /// @}
    25182586
    2519     /// \name Attribute sections
     2587    /// \name Attribute Sections
    25202588    /// @{
    25212589
     
    25432611    /// @}
    25442612
    2545     /// \name Extra sections
     2613    /// \name Extra Sections
    25462614    /// @{
    25472615
     
    25862654        readLine();
    25872655      }
    2588       line.putback(c);
     2656      if (readSuccess()) {
     2657        line.putback(c);
     2658      }
    25892659    }
    25902660
     
    26172687  public:
    26182688
    2619     /// \name Execution of the contents reader
     2689    /// \name Execution of the Contents Reader
    26202690    /// @{
    26212691
  • lemon/lgf_writer.h

    r517 r646  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    348348  }
    349349
    350   template <typename Digraph>
     350  template <typename DGR>
    351351  class DigraphWriter;
    352352
    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);
    363361
    364362
     
    382380  ///
    383381  ///\code
    384   /// DigraphWriter<Digraph>(digraph, std::cout).
     382  /// DigraphWriter<DGR>(digraph, std::cout).
    385383  ///   nodeMap("coordinates", coord_map).
    386384  ///   nodeMap("size", size).
     
    407405  /// the \c ostream() function, hence the second pass can append its
    408406  /// output to the output of the first pass.
    409   template <typename _Digraph>
     407  template <typename DGR>
    410408  class DigraphWriter {
    411409  public:
    412410
    413     typedef _Digraph Digraph;
    414     TEMPLATE_DIGRAPH_TYPEDEFS(Digraph);
     411    typedef DGR Digraph;
     412    TEMPLATE_DIGRAPH_TYPEDEFS(DGR);
    415413
    416414  private:
     
    420418    bool local_os;
    421419
    422     const Digraph& _digraph;
     420    const DGR& _digraph;
    423421
    424422    std::string _nodes_caption;
     
    452450    /// Construct a directed graph writer, which writes to the given
    453451    /// output stream.
    454     DigraphWriter(const Digraph& digraph, std::ostream& os = std::cout)
     452    DigraphWriter(const DGR& digraph, std::ostream& os = std::cout)
    455453      : _os(&os), local_os(false), _digraph(digraph),
    456454        _skip_nodes(false), _skip_arcs(false) {}
     
    460458    /// Construct a directed graph writer, which writes to the given
    461459    /// output file.
    462     DigraphWriter(const Digraph& digraph, const std::string& fn)
     460    DigraphWriter(const DGR& digraph, const std::string& fn)
    463461      : _os(new std::ofstream(fn.c_str())), local_os(true), _digraph(digraph),
    464462        _skip_nodes(false), _skip_arcs(false) {
     
    473471    /// Construct a directed graph writer, which writes to the given
    474472    /// output file.
    475     DigraphWriter(const Digraph& digraph, const char* fn)
     473    DigraphWriter(const DGR& digraph, const char* fn)
    476474      : _os(new std::ofstream(fn)), local_os(true), _digraph(digraph),
    477475        _skip_nodes(false), _skip_arcs(false) {
     
    506504  private:
    507505
    508     template <typename DGR>
    509     friend DigraphWriter<DGR> digraphWriter(const DGR& digraph,
    510                                             std::ostream& os);
    511     template <typename DGR>
    512     friend DigraphWriter<DGR> digraphWriter(const DGR& digraph,
    513                                             const std::string& fn);
    514     template <typename DGR>
    515     friend DigraphWriter<DGR> digraphWriter(const DGR& 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);
    517515
    518516    DigraphWriter(DigraphWriter& other)
     
    539537  public:
    540538
    541     /// \name Writing rules
     539    /// \name Writing Rules
    542540    /// @{
    543541
     
    642640    }
    643641
    644     /// \name Section captions
     642    /// \name Section Captions
    645643    /// @{
    646644
     
    669667    }
    670668
    671     /// \name Skipping section
     669    /// \name Skipping Section
    672670    /// @{
    673671
     
    725723
    726724      if (label == 0) {
    727         IdMap<Digraph, Node> id_map(_digraph);
    728         _writer_bits::MapLess<IdMap<Digraph, Node> > id_less(id_map);
     725        IdMap<DGR, Node> id_map(_digraph);
     726        _writer_bits::MapLess<IdMap<DGR, Node> > id_less(id_map);
    729727        std::sort(nodes.begin(), nodes.end(), id_less);
    730728      } else {
     
    810808
    811809      if (label == 0) {
    812         IdMap<Digraph, Arc> id_map(_digraph);
    813         _writer_bits::MapLess<IdMap<Digraph, Arc> > id_less(id_map);
     810        IdMap<DGR, Arc> id_map(_digraph);
     811        _writer_bits::MapLess<IdMap<DGR, Arc> > id_less(id_map);
    814812        std::sort(arcs.begin(), arcs.end(), id_less);
    815813      } else {
     
    886884  public:
    887885
    888     /// \name Execution of the writer
     886    /// \name Execution of the Writer
    889887    /// @{
    890888
     
    916914  };
    917915
     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
    918954  /// \brief Return a \ref DigraphWriter class
    919955  ///
    920956  /// This function just returns a \ref DigraphWriter class.
    921957  /// \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);
    926963    return tmp;
    927964  }
     
    931968  /// This function just returns a \ref DigraphWriter class.
    932969  /// \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);
    937974    return tmp;
    938975  }
    939976
    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>
    952978  class GraphWriter;
    953979
    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);
    961986
    962987  /// \ingroup lemon_io
     
    9751000  /// section as a \c '+' or a \c '-' prefix (depends on the direction
    9761001  /// of the arc) and the label of corresponding edge.
    977   template <typename _Graph>
     1002  template <typename GR>
    9781003  class GraphWriter {
    9791004  public:
    9801005
    981     typedef _Graph Graph;
    982     TEMPLATE_GRAPH_TYPEDEFS(Graph);
     1006    typedef GR Graph;
     1007    TEMPLATE_GRAPH_TYPEDEFS(GR);
    9831008
    9841009  private:
     
    9881013    bool local_os;
    9891014
    990     const Graph& _graph;
     1015    const GR& _graph;
    9911016
    9921017    std::string _nodes_caption;
     
    10201045    /// Construct a directed graph writer, which writes to the given
    10211046    /// output stream.
    1022     GraphWriter(const Graph& graph, std::ostream& os = std::cout)
     1047    GraphWriter(const GR& graph, std::ostream& os = std::cout)
    10231048      : _os(&os), local_os(false), _graph(graph),
    10241049        _skip_nodes(false), _skip_edges(false) {}
     
    10281053    /// Construct a directed graph writer, which writes to the given
    10291054    /// output file.
    1030     GraphWriter(const Graph& graph, const std::string& fn)
     1055    GraphWriter(const GR& graph, const std::string& fn)
    10311056      : _os(new std::ofstream(fn.c_str())), local_os(true), _graph(graph),
    10321057        _skip_nodes(false), _skip_edges(false) {
     
    10411066    /// Construct a directed graph writer, which writes to the given
    10421067    /// output file.
    1043     GraphWriter(const Graph& graph, const char* fn)
     1068    GraphWriter(const GR& graph, const char* fn)
    10441069      : _os(new std::ofstream(fn)), local_os(true), _graph(graph),
    10451070        _skip_nodes(false), _skip_edges(false) {
     
    10741099  private:
    10751100
    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);
    10851108   
    10861109    GraphWriter(GraphWriter& other)
     
    11071130  public:
    11081131
    1109     /// \name Writing rules
     1132    /// \name Writing Rules
    11101133    /// @{
    11111134
     
    11691192      checkConcept<concepts::ReadMap<Arc, typename Map::Value>, Map>();
    11701193      _writer_bits::MapStorageBase<Edge>* forward_storage =
    1171         new _writer_bits::GraphArcMapStorage<Graph, true, Map>(_graph, map);
     1194        new _writer_bits::GraphArcMapStorage<GR, true, Map>(_graph, map);
    11721195      _edge_maps.push_back(std::make_pair('+' + caption, forward_storage));
    11731196      _writer_bits::MapStorageBase<Edge>* backward_storage =
    1174         new _writer_bits::GraphArcMapStorage<Graph, false, Map>(_graph, map);
     1197        new _writer_bits::GraphArcMapStorage<GR, false, Map>(_graph, map);
    11751198      _edge_maps.push_back(std::make_pair('-' + caption, backward_storage));
    11761199      return *this;
     
    11861209      checkConcept<concepts::ReadMap<Arc, typename Map::Value>, Map>();
    11871210      _writer_bits::MapStorageBase<Edge>* forward_storage =
    1188         new _writer_bits::GraphArcMapStorage<Graph, true, Map, Converter>
     1211        new _writer_bits::GraphArcMapStorage<GR, true, Map, Converter>
    11891212        (_graph, map, converter);
    11901213      _edge_maps.push_back(std::make_pair('+' + caption, forward_storage));
    11911214      _writer_bits::MapStorageBase<Edge>* backward_storage =
    1192         new _writer_bits::GraphArcMapStorage<Graph, false, Map, Converter>
     1215        new _writer_bits::GraphArcMapStorage<GR, false, Map, Converter>
    11931216        (_graph, map, converter);
    11941217      _edge_maps.push_back(std::make_pair('-' + caption, backward_storage));
     
    12481271    /// Add an arc writing rule to writer.
    12491272    GraphWriter& arc(const std::string& caption, const Arc& arc) {
    1250       typedef _writer_bits::GraphArcLookUpConverter<Graph> Converter;
     1273      typedef _writer_bits::GraphArcLookUpConverter<GR> Converter;
    12511274      Converter converter(_graph, _edge_index);
    12521275      _writer_bits::ValueStorageBase* storage =
     
    12561279    }
    12571280
    1258     /// \name Section captions
     1281    /// \name Section Captions
    12591282    /// @{
    12601283
     
    12831306    }
    12841307
    1285     /// \name Skipping section
     1308    /// \name Skipping Section
    12861309    /// @{
    12871310
     
    13391362
    13401363      if (label == 0) {
    1341         IdMap<Graph, Node> id_map(_graph);
    1342         _writer_bits::MapLess<IdMap<Graph, Node> > id_less(id_map);
     1364        IdMap<GR, Node> id_map(_graph);
     1365        _writer_bits::MapLess<IdMap<GR, Node> > id_less(id_map);
    13431366        std::sort(nodes.begin(), nodes.end(), id_less);
    13441367      } else {
     
    14241447
    14251448      if (label == 0) {
    1426         IdMap<Graph, Edge> id_map(_graph);
    1427         _writer_bits::MapLess<IdMap<Graph, Edge> > id_less(id_map);
     1449        IdMap<GR, Edge> id_map(_graph);
     1450        _writer_bits::MapLess<IdMap<GR, Edge> > id_less(id_map);
    14281451        std::sort(edges.begin(), edges.end(), id_less);
    14291452      } else {
     
    15001523  public:
    15011524
    1502     /// \name Execution of the writer
     1525    /// \name Execution of the Writer
    15031526    /// @{
    15041527
     
    15301553  };
    15311554
     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
    15321589  /// \brief Return a \ref GraphWriter class
    15331590  ///
    15341591  /// This function just returns a \ref GraphWriter class.
    15351592  /// \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);
    15401597    return tmp;
    15411598  }
     
    15451602  /// This function just returns a \ref GraphWriter class.
    15461603  /// \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);
    15601608    return tmp;
    15611609  }
     
    16521700  public:
    16531701
    1654     /// \name Section writers
     1702    /// \name Section Writers
    16551703    /// @{
    16561704
     
    17191767
    17201768
    1721     /// \name Execution of the writer
     1769    /// \name Execution of the Writer
    17221770    /// @{
    17231771
     
    17471795  };
    17481796
     1797  /// \ingroup lemon_io
     1798  ///
    17491799  /// \brief Return a \ref SectionWriter class
    17501800  ///
    17511801  /// This function just returns a \ref SectionWriter class.
     1802  ///
     1803  /// Please see SectionWriter documentation about the custom section
     1804  /// output.
     1805  ///
    17521806  /// \relates SectionWriter
     1807  /// \sa sectionWriter(const std::string& fn)
     1808  /// \sa sectionWriter(const char *fn)
    17531809  inline SectionWriter sectionWriter(std::ostream& os) {
    17541810    SectionWriter tmp(os);
     
    17601816  /// This function just returns a \ref SectionWriter class.
    17611817  /// \relates SectionWriter
     1818  /// \sa sectionWriter(std::ostream& os)
    17621819  inline SectionWriter sectionWriter(const std::string& fn) {
    17631820    SectionWriter tmp(fn);
     
    17691826  /// This function just returns a \ref SectionWriter class.
    17701827  /// \relates SectionWriter
     1828  /// \sa sectionWriter(std::ostream& os)
    17711829  inline SectionWriter sectionWriter(const char* fn) {
    17721830    SectionWriter tmp(fn);
  • lemon/list_graph.h

    r313 r664  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    321321  ///only in the concept class.
    322322  ///
    323   ///An important extra feature of this digraph implementation is that
    324   ///its maps are real \ref concepts::ReferenceMap "reference map"s.
    325   ///
    326323  ///\sa concepts::Digraph
    327324
    328325  class ListDigraph : public ExtendedListDigraphBase {
     326    typedef ExtendedListDigraphBase Parent;
     327
    329328  private:
    330329    ///ListDigraph is \e not copy constructible. Use copyDigraph() instead.
     
    341340  public:
    342341
    343     typedef ExtendedListDigraphBase Parent;
    344 
    345342    /// Constructor
    346343
     
    352349
    353350    ///Add a new node to the digraph.
    354     ///\return the new node.
     351    ///\return The new node.
    355352    Node addNode() { return Parent::addNode(); }
    356353
     
    359356    ///Add a new arc to the digraph with source node \c s
    360357    ///and target node \c t.
    361     ///\return the new arc.
     358    ///\return The new arc.
    362359    Arc addArc(const Node& s, const Node& t) {
    363360      return Parent::addArc(s, t);
     
    797794  public:
    798795
    799     typedef ListGraphBase Digraph;
     796    typedef ListGraphBase Graph;
    800797
    801798    class Node;
     
    841838
    842839    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;
    845842      }
    846843
     
    11771174  ///only in the concept class.
    11781175  ///
    1179   ///An important extra feature of this graph implementation is that
    1180   ///its maps are real \ref concepts::ReferenceMap "reference map"s.
    1181   ///
    11821176  ///\sa concepts::Graph
    11831177
    11841178  class ListGraph : public ExtendedListGraphBase {
     1179    typedef ExtendedListGraphBase Parent;
     1180
    11851181  private:
    11861182    ///ListGraph is \e not copy constructible. Use copyGraph() instead.
     
    12021198    ListGraph() {}
    12031199
    1204     typedef ExtendedListGraphBase Parent;
    1205 
    12061200    typedef Parent::OutArcIt IncEdgeIt;
    12071201
     
    12091203    ///
    12101204    /// Add a new node to the graph.
    1211     /// \return the new node.
     1205    /// \return The new node.
    12121206    Node addNode() { return Parent::addNode(); }
    12131207
     
    12161210    /// Add a new edge to the graph with source node \c s
    12171211    /// and target node \c t.
    1218     /// \return the new edge.
     1212    /// \return The new edge.
    12191213    Edge addEdge(const Node& s, const Node& t) {
    12201214      return Parent::addEdge(s, t);
  • lemon/maps.h

    r314 r664  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    6464  class NullMap : public MapBase<K, V> {
    6565  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;
    6970
    7071    /// Gives back a default constructed element.
     
    103104    V _value;
    104105  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;
    108110
    109111    /// Default constructor
     
    169171  class ConstMap<K, Const<V, v> > : public MapBase<K, V> {
    170172  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;
    174177
    175178    /// Constructor.
     
    203206  class IdentityMap : public MapBase<T, T> {
    204207  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;
    208212
    209213    /// Gives back the given value without any modification.
     
    246250  public:
    247251
    248     typedef MapBase<int, V> Parent;
    249252    /// Key type
    250     typedef typename Parent::Key Key;
     253    typedef int Key;
    251254    /// Value type
    252     typedef typename Parent::Value Value;
     255    typedef V Value;
    253256    /// Reference type
    254257    typedef typename Vector::reference Reference;
     
    354357  /// The simplest way of using this map is through the sparseMap()
    355358  /// function.
    356   template <typename K, typename V, typename Compare = std::less<K> >
     359  template <typename K, typename V, typename Comp = std::less<K> >
    357360  class SparseMap : public MapBase<K, V> {
    358361    template <typename K1, typename V1, typename C1>
     
    360363  public:
    361364
    362     typedef MapBase<K, V> Parent;
    363365    /// Key type
    364     typedef typename Parent::Key Key;
     366    typedef K Key;
    365367    /// Value type
    366     typedef typename Parent::Value Value;
     368    typedef V Value;
    367369    /// Reference type
    368370    typedef Value& Reference;
     
    374376  private:
    375377
    376     typedef std::map<K, V, Compare> Map;
     378    typedef std::map<K, V, Comp> Map;
    377379    Map _map;
    378380    Value _value;
     
    490492    const M2 &_m2;
    491493  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;
    495498
    496499    /// Constructor
    497500    ComposeMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {}
    498501
    499     /// \e
     502    ///\e
    500503    typename MapTraits<M1>::ConstReturnValue
    501504    operator[](const Key &k) const { return _m1[_m2[k]]; }
     
    546549    F _f;
    547550  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;
    551555
    552556    /// Constructor
    553557    CombineMap(const M1 &m1, const M2 &m2, const F &f = F())
    554558      : _m1(m1), _m2(m2), _f(f) {}
    555     /// \e
     559    ///\e
    556560    Value operator[](const Key &k) const { return _f(_m1[k],_m2[k]); }
    557561  };
     
    616620    F _f;
    617621  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;
    621626
    622627    /// Constructor
    623628    FunctorToMap(const F &f = F()) : _f(f) {}
    624     /// \e
     629    ///\e
    625630    Value operator[](const Key &k) const { return _f(k); }
    626631  };
     
    670675    const M &_m;
    671676  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;
    678684
    679685    /// Constructor
    680686    MapToFunctor(const M &m) : _m(m) {}
    681     /// \e
     687    ///\e
    682688    Value operator()(const Key &k) const { return _m[k]; }
    683     /// \e
     689    ///\e
    684690    Value operator[](const Key &k) const { return _m[k]; }
    685691  };
     
    710716    const M &_m;
    711717  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;
    715722
    716723    /// Constructor
     
    720727    ConvertMap(const M &m) : _m(m) {}
    721728
    722     /// \e
     729    ///\e
    723730    Value operator[](const Key &k) const { return _m[k]; }
    724731  };
     
    752759    M2 &_m2;
    753760  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;
    757765
    758766    /// Constructor
     
    798806    const M2 &_m2;
    799807  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;
    803812
    804813    /// Constructor
    805814    AddMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {}
    806     /// \e
     815    ///\e
    807816    Value operator[](const Key &k) const { return _m1[k]+_m2[k]; }
    808817  };
     
    846855    const M2 &_m2;
    847856  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;
    851861
    852862    /// Constructor
    853863    SubMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {}
    854     /// \e
     864    ///\e
    855865    Value operator[](const Key &k) const { return _m1[k]-_m2[k]; }
    856866  };
     
    895905    const M2 &_m2;
    896906  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;
    900911
    901912    /// Constructor
    902913    MulMap(const M1 &m1,const M2 &m2) : _m1(m1), _m2(m2) {}
    903     /// \e
     914    ///\e
    904915    Value operator[](const Key &k) const { return _m1[k]*_m2[k]; }
    905916  };
     
    943954    const M2 &_m2;
    944955  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;
    948960
    949961    /// Constructor
    950962    DivMap(const M1 &m1,const M2 &m2) : _m1(m1), _m2(m2) {}
    951     /// \e
     963    ///\e
    952964    Value operator[](const Key &k) const { return _m1[k]/_m2[k]; }
    953965  };
     
    9931005    C _v;
    9941006  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;
    9981011
    9991012    /// Constructor
     
    10031016    /// \param v The constant value.
    10041017    ShiftMap(const M &m, const C &v) : _m(m), _v(v) {}
    1005     /// \e
     1018    ///\e
    10061019    Value operator[](const Key &k) const { return _m[k]+_v; }
    10071020  };
     
    10231036    C _v;
    10241037  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;
    10281042
    10291043    /// Constructor
     
    10331047    /// \param v The constant value.
    10341048    ShiftWriteMap(M &m, const C &v) : _m(m), _v(v) {}
    1035     /// \e
     1049    ///\e
    10361050    Value operator[](const Key &k) const { return _m[k]+_v; }
    1037     /// \e
     1051    ///\e
    10381052    void set(const Key &k, const Value &v) { _m.set(k, v-_v); }
    10391053  };
     
    10941108    C _v;
    10951109  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;
    10991114
    11001115    /// Constructor
     
    11041119    /// \param v The constant value.
    11051120    ScaleMap(const M &m, const C &v) : _m(m), _v(v) {}
    1106     /// \e
     1121    ///\e
    11071122    Value operator[](const Key &k) const { return _v*_m[k]; }
    11081123  };
     
    11251140    C _v;
    11261141  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;
    11301146
    11311147    /// Constructor
     
    11351151    /// \param v The constant value.
    11361152    ScaleWriteMap(M &m, const C &v) : _m(m), _v(v) {}
    1137     /// \e
     1153    ///\e
    11381154    Value operator[](const Key &k) const { return _v*_m[k]; }
    1139     /// \e
     1155    ///\e
    11401156    void set(const Key &k, const Value &v) { _m.set(k, v/_v); }
    11411157  };
     
    11941210    const M& _m;
    11951211  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;
    11991216
    12001217    /// Constructor
    12011218    NegMap(const M &m) : _m(m) {}
    1202     /// \e
     1219    ///\e
    12031220    Value operator[](const Key &k) const { return -_m[k]; }
    12041221  };
     
    12291246    M &_m;
    12301247  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;
    12341252
    12351253    /// Constructor
    12361254    NegWriteMap(M &m) : _m(m) {}
    1237     /// \e
     1255    ///\e
    12381256    Value operator[](const Key &k) const { return -_m[k]; }
    1239     /// \e
     1257    ///\e
    12401258    void set(const Key &k, const Value &v) { _m.set(k, -v); }
    12411259  };
     
    12831301    const M &_m;
    12841302  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;
    12881307
    12891308    /// Constructor
    12901309    AbsMap(const M &m) : _m(m) {}
    1291     /// \e
     1310    ///\e
    12921311    Value operator[](const Key &k) const {
    12931312      Value tmp = _m[k];
     
    13381357  class TrueMap : public MapBase<K, bool> {
    13391358  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;
    13431363
    13441364    /// Gives back \c true.
     
    13751395  class FalseMap : public MapBase<K, bool> {
    13761396  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;
    13801401
    13811402    /// Gives back \c false.
     
    14201441    const M2 &_m2;
    14211442  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;
    14251447
    14261448    /// Constructor
    14271449    AndMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {}
    1428     /// \e
     1450    ///\e
    14291451    Value operator[](const Key &k) const { return _m1[k]&&_m2[k]; }
    14301452  };
     
    14681490    const M2 &_m2;
    14691491  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;
    14731496
    14741497    /// Constructor
    14751498    OrMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {}
    1476     /// \e
     1499    ///\e
    14771500    Value operator[](const Key &k) const { return _m1[k]||_m2[k]; }
    14781501  };
     
    15071530    const M &_m;
    15081531  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;
    15121536
    15131537    /// Constructor
    15141538    NotMap(const M &m) : _m(m) {}
    1515     /// \e
     1539    ///\e
    15161540    Value operator[](const Key &k) const { return !_m[k]; }
    15171541  };
     
    15331557    M &_m;
    15341558  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;
    15381563
    15391564    /// Constructor
    15401565    NotWriteMap(M &m) : _m(m) {}
    1541     /// \e
     1566    ///\e
    15421567    Value operator[](const Key &k) const { return !_m[k]; }
    1543     /// \e
     1568    ///\e
    15441569    void set(const Key &k, bool v) { _m.set(k, !v); }
    15451570  };
     
    15961621    const M2 &_m2;
    15971622  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;
    16011627
    16021628    /// Constructor
    16031629    EqualMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {}
    1604     /// \e
     1630    ///\e
    16051631    Value operator[](const Key &k) const { return _m1[k]==_m2[k]; }
    16061632  };
     
    16441670    const M2 &_m2;
    16451671  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;
    16491676
    16501677    /// Constructor
    16511678    LessMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {}
    1652     /// \e
     1679    ///\e
    16531680    Value operator[](const Key &k) const { return _m1[k]<_m2[k]; }
    16541681  };
     
    17061733  /// function.
    17071734  ///
    1708   /// \tparam It The type of the iterator.
    1709   /// \tparam Ke The key type of the map. The default value set
     1735  /// \tparam IT The type of the iterator.
     1736  /// \tparam KEY The key type of the map. The default value set
    17101737  /// according to the iterator type should work in most cases.
    17111738  ///
     
    17131740  /// for the elements or the iterator should be an inserter iterator.
    17141741#ifdef DOXYGEN
    1715   template <typename It, typename Ke>
     1742  template <typename IT, typename KEY>
    17161743#else
    1717   template <typename It,
    1718             typename Ke=typename _maps_bits::IteratorTraits<It>::Value>
     1744  template <typename IT,
     1745            typename KEY = typename _maps_bits::IteratorTraits<IT>::Value>
    17191746#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
    17251753    typedef bool Value;
     1754    ///\e
     1755    typedef IT Iterator;
    17261756
    17271757    /// Constructor
     
    17861816  /// @{
    17871817
    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
    17961829  /// class \c InverseMap or with the \c operator() member.
    17971830  ///
    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.
    18021847    typedef int Value;
    1803     typedef _Item Item;
    1804     typedef _Item Key;
    18051848
    18061849    /// \brief Constructor.
     
    18141857    int operator[](const Item& item) const { return _graph->id(item);}
    18151858
    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.
    18191862    Item operator()(int id) { return _graph->fromId(id, Item()); }
    18201863
     
    18241867  public:
    18251868
    1826     /// \brief The class represents the inverse of its owner (IdMap).
    1827     ///
    1828     /// The class 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).
    18291872    /// \see inverse()
    18301873    class InverseMap {
     
    18441887      ///
    18451888      /// Gives back the given item from its id.
    1846       ///
    18471889      Item operator[](int id) const { return _graph->fromId(id, Item());}
    18481890
     
    18551897    /// Gives back the inverse of the IdMap.
    18561898    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"
    18651906  /// and if a key is set to a new value then store it
    18661907  /// in the inverse map.
     
    18691910  /// with stl compatible forward iterator.
    18701911  ///
    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.
    18741916  ///
    18751917  /// \see IterableValueMap
    1876   template <typename _Graph, typename _Item, typename _Value>
    1877   class InvertableMap
    1878     : 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 {
    18791921  private:
    18801922
    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;
    18861927    Container _inv_map;
    18871928
    18881929  public:
    18891930
    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;
    18941940
    18951941    /// \brief Constructor.
    18961942    ///
    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) {}
    19001945
    19011946    /// \brief Forward iterator for values.
     
    19031948    /// This iterator is an stl compatible forward
    19041949    /// 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.
    19071951    class ValueIterator
    19081952      : public std::iterator<std::forward_iterator_tag, Value> {
    1909       friend class InvertableMap;
     1953      friend class CrossRefMap;
    19101954    private:
    19111955      ValueIterator(typename Container::const_iterator _it)
     
    19361980    /// Returns an stl compatible iterator to the
    19371981    /// 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>
    19391983    /// range.
    19401984    ValueIterator beginValue() const {
     
    19461990    /// Returns an stl compatible iterator after the
    19471991    /// 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>
    19491993    /// range.
    19501994    ValueIterator endValue() const {
     
    19521996    }
    19531997
    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.
    19572001    void set(const Key& key, const Value& val) {
    19582002      Value oldval = Map::operator[](key);
     
    19652009    }
    19662010
    1967     /// \brief The getter function of the map.
    1968     ///
    1969     /// It gives back the value associated with the key.
     2011    /// \brief Returns the value associated with the given key.
     2012    ///
     2013    /// Returns the value associated with the given key.
    19702014    typename MapTraits<Map>::ConstReturnValue
    19712015    operator[](const Key& key) const {
     
    19832027  protected:
    19842028
    1985     /// \brief Erase the key from the map.
    1986     ///
    1987     /// Erase the key to the map. It is called by the
     2029    /// \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
    19882032    /// \c AlterationNotifier.
    19892033    virtual void erase(const Key& key) {
     
    19962040    }
    19972041
    1998     /// \brief Erase more keys from the map.
    1999     ///
    2000     /// Erase more keys from the map. It is called by the
     2042    /// \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
    20012045    /// \c AlterationNotifier.
    20022046    virtual void erase(const std::vector<Key>& keys) {
     
    20112055    }
    20122056
    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 the
     2057    /// \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
    20162060    /// \c AlterationNotifier.
    20172061    virtual void clear() {
     
    20252069    ///
    20262070    /// 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.
    20282072    class InverseMap {
    20292073    public:
    2030       /// \brief Constructor of the InverseMap.
     2074      /// \brief Constructor
    20312075      ///
    20322076      /// Constructor of the InverseMap.
    2033       explicit InverseMap(const InvertableMap& inverted)
     2077      explicit InverseMap(const CrossRefMap& inverted)
    20342078        : _inverted(inverted) {}
    20352079
    20362080      /// The value type of the InverseMap.
    2037       typedef typename InvertableMap::Key Value;
     2081      typedef typename CrossRefMap::Key Value;
    20382082      /// The key type of the InverseMap.
    2039       typedef typename InvertableMap::Value Key;
     2083      typedef typename CrossRefMap::Value Key;
    20402084
    20412085      /// \brief Subscript operator.
    20422086      ///
    2043       /// Subscript operator. It gives back always the item
    2044       /// what was last assigned to the value.
     2087      /// Subscript operator. It gives back the item
     2088      /// that was last assigned to the given value.
    20452089      Value operator[](const Key& key) const {
    20462090        return _inverted(key);
     
    20482092
    20492093    private:
    2050       const InvertableMap& _inverted;
     2094      const CrossRefMap& _inverted;
    20512095    };
    20522096
    2053     /// \brief It gives back the just readable inverse map.
    2054     ///
    2055     /// It gives back the just readable inverse map.
     2097    /// \brief It gives back the read-only inverse map.
     2098    ///
     2099    /// It gives back the read-only inverse map.
    20562100    InverseMap inverse() const {
    20572101      return InverseMap(*this);
     
    20602104  };
    20612105
    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;
    20922144
    20932145    /// \brief Constructor.
    20942146    ///
    2095     /// Constructor for descriptor map.
    2096     explicit DescriptorMap(const Graph& _graph) : Map(_graph) {
     2147    /// Constructor.
     2148    explicit RangeIdMap(const Graph& gr) : Map(gr) {
    20972149      Item it;
    20982150      const typename Map::Notifier* nf = Map::notifier();
     
    21052157  protected:
    21062158
    2107     /// \brief Add a new key to the map.
     2159    /// \brief Adds a new key to the map.
    21082160    ///
    21092161    /// Add a new key to the map. It is called by the
     
    21952247    }
    21962248
    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.
    22002252    int operator[](const Item& item) const {
    22012253      return Map::operator[](item);
    22022254    }
    22032255
    2204     /// \brief Gives back the item by 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.
    22072259    Item operator()(int id) const {
    22082260      return _inv_map[id];
     
    22152267
    22162268  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.
    22202273    class InverseMap {
    22212274    public:
    2222       /// \brief Constructor of the InverseMap.
     2275      /// \brief Constructor
    22232276      ///
    22242277      /// Constructor of the InverseMap.
    2225       explicit InverseMap(const DescriptorMap& inverted)
     2278      explicit InverseMap(const RangeIdMap& inverted)
    22262279        : _inverted(inverted) {}
    22272280
    22282281
    22292282      /// The value type of the InverseMap.
    2230       typedef typename DescriptorMap::Key Value;
     2283      typedef typename RangeIdMap::Key Value;
    22312284      /// The key type of the InverseMap.
    2232       typedef typename DescriptorMap::Value Key;
     2285      typedef typename RangeIdMap::Value Key;
    22332286
    22342287      /// \brief Subscript operator.
    22352288      ///
    22362289      /// Subscript operator. It gives back the item
    2237       /// that the descriptor belongs to currently.
     2290      /// that the descriptor currently belongs to.
    22382291      Value operator[](const Key& key) const {
    22392292        return _inverted(key);
     
    22482301
    22492302    private:
    2250       const DescriptorMap& _inverted;
     2303      const RangeIdMap& _inverted;
    22512304    };
    22522305
     
    22592312  };
    22602313
    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.
    22642319  /// \see TargetMap
    2265   template <typename Digraph>
     2320  template <typename GR>
    22662321  class SourceMap {
    22672322  public:
    22682323
    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;
    22712328
    22722329    /// \brief Constructor
    22732330    ///
    2274     /// Constructor
     2331    /// Constructor.
    22752332    /// \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.
    22832338    Value operator[](const Key& arc) const {
    2284       return _digraph.source(arc);
     2339      return _graph.source(arc);
    22852340    }
    22862341
    22872342  private:
    2288     const Digraph& _digraph;
     2343    const GR& _graph;
    22892344  };
    22902345
     
    22932348  /// This function just returns an \c SourceMap class.
    22942349  /// \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.
    23032360  /// \see SourceMap
    2304   template <typename Digraph>
     2361  template <typename GR>
    23052362  class TargetMap {
    23062363  public:
    23072364
    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;
    23102369
    23112370    /// \brief Constructor
    23122371    ///
    2313     /// Constructor
     2372    /// Constructor.
    23142373    /// \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.
    23222379    Value operator[](const Key& e) const {
    2323       return _digraph.target(e);
     2380      return _graph.target(e);
    23242381    }
    23252382
    23262383  private:
    2327     const Digraph& _digraph;
     2384    const GR& _graph;
    23282385  };
    23292386
     
    23322389  /// This function just returns a \c TargetMap class.
    23332390  /// \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.
    23422402  /// \see BackwardMap
    2343   template <typename Graph>
     2403  template <typename GR>
    23442404  class ForwardMap {
    23452405  public:
    23462406
    2347     typedef typename Graph::Arc Value;
    2348     typedef typename Graph::Edge Key;
     2407    typedef typename GR::Arc Value;
     2408    typedef typename GR::Edge Key;
    23492409
    23502410    /// \brief Constructor
    23512411    ///
    2352     /// Constructor
     2412    /// Constructor.
    23532413    /// \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.
    23612419    Value operator[](const Key& key) const {
    23622420      return _graph.direct(key, true);
     
    23642422
    23652423  private:
    2366     const Graph& _graph;
     2424    const GR& _graph;
    23672425  };
    23682426
     
    23712429  /// This function just returns an \c ForwardMap class.
    23722430  /// \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.
    23812442  /// \see ForwardMap
    2382   template <typename Graph>
     2443  template <typename GR>
    23832444  class BackwardMap {
    23842445  public:
    23852446
    2386     typedef typename Graph::Arc Value;
    2387     typedef typename Graph::Edge Key;
     2447    typedef typename GR::Arc Value;
     2448    typedef typename GR::Edge Key;
    23882449
    23892450    /// \brief Constructor
    23902451    ///
    2391     /// Constructor
     2452    /// Constructor.
    23922453    /// \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.
    24002459    Value operator[](const Key& key) const {
    24012460      return _graph.direct(key, false);
     
    24032462
    24042463  private:
    2405     const Graph& _graph;
     2464    const GR& _graph;
    24062465  };
    24072466
     
    24102469  /// This function just returns a \c BackwardMap class.
    24112470  /// \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.
    24592477  ///
    24602478  /// 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 done
     2479  /// the degrees are stored in a standard \c NodeMap, so each query is done
    24622480  /// in constant time. On the other hand, the values are updated automatically
    24632481  /// whenever the digraph changes.
    24642482  ///
    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()",
    24692488  /// \ref ListDigraph::changeTarget() "changeTarget()" and
    24702489  /// \ref ListDigraph::reverseArc() "reverseArc()"
     
    24722491  ///
    24732492  /// \sa OutDegMap
    2474 
    2475   template <typename _Digraph>
     2493  template <typename GR>
    24762494  class InDegMap
    2477     : protected ItemSetTraits<_Digraph, typename _Digraph::Arc>
     2495    : protected ItemSetTraits<GR, typename GR::Arc>
    24782496      ::ItemNotifier::ObserverBase {
    24792497
    24802498  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
    24832506    typedef int Value;
    2484     typedef typename Digraph::Node Key;
    24852507
    24862508    typedef typename ItemSetTraits<Digraph, typename Digraph::Arc>
     
    25242546    /// \brief Constructor.
    25252547    ///
    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) {
    25292551      Parent::attach(_digraph.notifier(typename Digraph::Arc()));
    25302552
     
    25342556    }
    25352557
     2558    /// \brief Gives back the in-degree of a Node.
     2559    ///
    25362560    /// Gives back the in-degree of a Node.
    25372561    int operator[](const Key& key) const {
     
    25802604  };
    25812605
    2582   /// \brief Map of the node out-degrees.
     2606  /// \brief Map of the out-degrees of nodes in a digraph.
    25832607  ///
    25842608  /// 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 done
     2609  /// the degrees are stored in a standard \c NodeMap, so each query is done
    25862610  /// in constant time. On the other hand, the values are updated automatically
    25872611  /// whenever the digraph changes.
    25882612  ///
    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()",
    25932618  /// \ref ListDigraph::changeTarget() "changeTarget()" and
    25942619  /// \ref ListDigraph::reverseArc() "reverseArc()"
     
    25962621  ///
    25972622  /// \sa InDegMap
    2598 
    2599   template <typename _Digraph>
     2623  template <typename GR>
    26002624  class OutDegMap
    2601     : protected ItemSetTraits<_Digraph, typename _Digraph::Arc>
     2625    : protected ItemSetTraits<GR, typename GR::Arc>
    26022626      ::ItemNotifier::ObserverBase {
    26032627
    26042628  public:
    26052629
    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
    26072636    typedef int Value;
    2608     typedef typename Digraph::Node Key;
    26092637
    26102638    typedef typename ItemSetTraits<Digraph, typename Digraph::Arc>
     
    26462674    /// \brief Constructor.
    26472675    ///
    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) {
    26512679      Parent::attach(_digraph.notifier(typename Digraph::Arc()));
    26522680
     
    26562684    }
    26572685
     2686    /// \brief Gives back the out-degree of a Node.
     2687    ///
    26582688    /// Gives back the out-degree of a Node.
    26592689    int operator[](const Key& key) const {
     
    27022732  };
    27032733
     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
    27042784  /// @}
    27052785}
  • lemon/math.h

    r209 r558  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    5656  const long double SQRT1_2 = 0.7071067811865475244008443621048490L;
    5757
     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    }
    5867
    5968  /// @}
  • lemon/path.h

    r517 r606  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    4141  ///
    4242  /// A structure for representing directed path in a digraph.
    43   /// \tparam _Digraph The digraph type in which the path is.
     43  /// \tparam GR The digraph type in which the path is.
    4444  ///
    4545  /// In a sense, the path can be treated as a list of arcs. The
     
    5353  /// implementation uses two vectors for storing the front and back
    5454  /// insertions.
    55   template <typename _Digraph>
     55  template <typename GR>
    5656  class Path {
    5757  public:
    5858
    59     typedef _Digraph Digraph;
     59    typedef GR Digraph;
    6060    typedef typename Digraph::Arc Arc;
    6161
     
    138138    /// \brief The nth arc.
    139139    ///
    140     /// \pre n is in the [0..length() - 1] range
     140    /// \pre \c n is in the <tt>[0..length() - 1]</tt> range.
    141141    const Arc& nth(int n) const {
    142142      return n < int(head.size()) ? *(head.rbegin() + n) :
     
    146146    /// \brief Initialize arc iterator to point to the nth arc
    147147    ///
    148     /// \pre n is in the [0..length() - 1] range
     148    /// \pre \c n is in the <tt>[0..length() - 1]</tt> range.
    149149    ArcIt nthIt(int n) const {
    150150      return ArcIt(*this, n);
     
    229229  ///
    230230  /// A structure for representing directed path in a digraph.
    231   /// \tparam _Digraph The digraph type in which the path is.
     231  /// \tparam GR The digraph type in which the path is.
    232232  ///
    233233  /// In a sense, the path can be treated as a list of arcs. The
     
    241241  /// then the \c Path type because it use just one vector for the
    242242  /// arcs.
    243   template <typename _Digraph>
     243  template <typename GR>
    244244  class SimplePath {
    245245  public:
    246246
    247     typedef _Digraph Digraph;
     247    typedef GR Digraph;
    248248    typedef typename Digraph::Arc Arc;
    249249
     
    330330    /// \brief The nth arc.
    331331    ///
    332     /// \pre n is in the [0..length() - 1] range
     332    /// \pre \c n is in the <tt>[0..length() - 1]</tt> range.
    333333    const Arc& nth(int n) const {
    334334      return data[n];
     
    393393  ///
    394394  /// A structure for representing directed path in a digraph.
    395   /// \tparam _Digraph The digraph type in which the path is.
     395  /// \tparam GR The digraph type in which the path is.
    396396  ///
    397397  /// In a sense, the path can be treated as a list of arcs. The
     
    405405  /// time. The front and back insertion and erasure is O(1) time
    406406  /// and it can be splited and spliced in O(1) time.
    407   template <typename _Digraph>
     407  template <typename GR>
    408408  class ListPath {
    409409  public:
    410410
    411     typedef _Digraph Digraph;
     411    typedef GR Digraph;
    412412    typedef typename Digraph::Arc Arc;
    413413
     
    508508    ///
    509509    /// This function looks for the nth arc in O(n) time.
    510     /// \pre n is in the [0..length() - 1] range
     510    /// \pre \c n is in the <tt>[0..length() - 1]</tt> range.
    511511    const Arc& nth(int n) const {
    512512      Node *node = first;
     
    733733  ///
    734734  /// A structure for representing directed path in a digraph.
    735   /// \tparam _Digraph The digraph type in which the path is.
     735  /// \tparam GR The digraph type in which the path is.
    736736  ///
    737737  /// In a sense, the path can be treated as a list of arcs. The
     
    747747  /// it is intented to be
    748748  /// used when you want to store a large number of paths.
    749   template <typename _Digraph>
     749  template <typename GR>
    750750  class StaticPath {
    751751  public:
    752752
    753     typedef _Digraph Digraph;
     753    typedef GR Digraph;
    754754    typedef typename Digraph::Arc Arc;
    755755
     
    834834    /// \brief The nth arc.
    835835    ///
    836     /// \pre n is in the [0..length() - 1] range
     836    /// \pre \c n is in the <tt>[0..length() - 1]</tt> range.
    837837    const Arc& nth(int n) const {
    838838      return arcs[n];
  • lemon/random.cc

    r209 r463  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
  • lemon/random.h

    r517 r631  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    531531    /// @{
    532532
    533     ///\name Initialization
    534     ///
    535     /// @{
    536 
    537533    /// \brief Default constructor
    538534    ///
     
    608604    /// function with the <tt>/dev/urandom</tt> file. If it does not success,
    609605    /// it uses the \c seedFromTime().
    610     /// \return Currently always true.
     606    /// \return Currently always \c true.
    611607    bool seed() {
    612608#ifndef WIN32
     
    629625    /// \param file The source file
    630626    /// \param offset The offset, from the file read.
    631     /// \return True when the seeding successes.
     627    /// \return \c true when the seeding successes.
    632628#ifndef WIN32
    633629    bool seedFromFile(const std::string& file = "/dev/urandom", int offset = 0)
     
    650646    /// current process id and the current time for initialize the
    651647    /// random sequence.
    652     /// \return Currently always true.
     648    /// \return Currently always \c true.
    653649    bool seedFromTime() {
    654650#ifndef WIN32
     
    664660    /// @}
    665661
    666     ///\name Uniform distributions
     662    ///\name Uniform Distributions
    667663    ///
    668664    /// @{
     
    680676      return real<double>();
    681677    }
    682 
    683     /// @}
    684 
    685     ///\name Uniform distributions
    686     ///
    687     /// @{
    688678
    689679    /// \brief Returns a random real number from the range [0, 1)
     
    741731      return _random_bits::IntConversion<Number, Word>::convert(core);
    742732    }
    743 
    744     /// @}
    745733
    746734    unsigned int uinteger() {
     
    775763    /// @}
    776764
    777     ///\name Non-uniform distributions
    778     ///
    779 
     765    ///\name Non-uniform Distributions
     766    ///
    780767    ///@{
    781768
    782     /// \brief Returns a random bool
     769    /// \brief Returns a random bool with given probability of true result.
    783770    ///
    784771    /// It returns a random bool with given probability of true result.
     
    787774    }
    788775
    789     /// Standard Gauss distribution
    790 
    791     /// Standard Gauss distribution.
     776    /// Standard normal (Gauss) distribution
     777
     778    /// Standard normal (Gauss) distribution.
    792779    /// \note The Cartesian form of the Box-Muller
    793780    /// transformation is used to generate a random normal distribution.
     
    802789      return std::sqrt(-2*std::log(S)/S)*V1;
    803790    }
    804     /// Gauss distribution with given mean and standard deviation
    805 
    806     /// Gauss distribution 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.
    807794    /// \sa gauss()
    808795    double gauss(double mean,double std_dev)
    809796    {
    810797      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> &params)
     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));
    811838    }
    812839
     
    912939    ///@}
    913940
    914     ///\name Two dimensional distributions
    915     ///
    916 
     941    ///\name Two Dimensional Distributions
     942    ///
    917943    ///@{
    918944
     
    931957      return dim2::Point<double>(V1,V2);
    932958    }
    933     /// A kind of two dimensional Gauss distribution
     959    /// A kind of two dimensional normal (Gauss) distribution
    934960
    935961    /// This function provides a turning symmetric two-dimensional distribution.
  • lemon/smart_graph.h

    r313 r664  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    5656  public:
    5757
    58     typedef SmartDigraphBase Graph;
     58    typedef SmartDigraphBase Digraph;
    5959
    6060    class Node;
     
    6868
    6969    typedef True NodeNumTag;
    70     typedef True EdgeNumTag;
     70    typedef True ArcNumTag;
    7171
    7272    int nodeNum() const { return nodes.size(); }
     
    192192  ///that <b> it does support only limited (only stack-like)
    193193  ///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".
    197195  ///
    198196  ///\sa concepts::Digraph.
    199197  class SmartDigraph : public ExtendedSmartDigraphBase {
    200   public:
    201 
    202198    typedef ExtendedSmartDigraphBase Parent;
    203199
     
    226222    ///Add a new node to the digraph.
    227223
    228     /// \return the new node.
    229     ///
     224    /// Add a new node to the digraph.
     225    /// \return The new node.
    230226    Node addNode() { return Parent::addNode(); }
    231227
     
    234230    ///Add a new arc to the digraph with source node \c s
    235231    ///and target node \c t.
    236     ///\return the new arc.
     232    ///\return The new arc.
    237233    Arc addArc(const Node& s, const Node& t) {
    238234      return Parent::addArc(s, t);
     
    306302      nodes[b._id].first_out=nodes[n._id].first_out;
    307303      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      }
    309307      if(connect) addArc(n,b);
    310308      return b;
     
    421419  public:
    422420
    423     typedef SmartGraphBase Digraph;
     421    typedef SmartGraphBase Graph;
    424422
    425423    class Node;
     
    465463
    466464    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;
    469467      }
    470468
     
    481479      : nodes(), arcs() {}
    482480
     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(); }
    483488
    484489    int maxNodeId() const { return nodes.size()-1; }
     
    621626  /// that <b> it does support only limited (only stack-like)
    622627  /// 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".
    629629  ///
    630630  /// \sa concepts::Graph.
    631   ///
    632631  class SmartGraph : public ExtendedSmartGraphBase {
     632    typedef ExtendedSmartGraphBase Parent;
     633
    633634  private:
    634635
     
    648649  public:
    649650
    650     typedef ExtendedSmartGraphBase Parent;
    651 
    652651    /// Constructor
    653652
     
    658657    ///Add a new node to the graph.
    659658
    660     /// \return the new node.
    661     ///
     659    /// Add a new node to the graph.
     660    /// \return The new node.
    662661    Node addNode() { return Parent::addNode(); }
    663662
     
    666665    ///Add a new edge to the graph with node \c s
    667666    ///and \c t.
    668     ///\return the new edge.
     667    ///\return The new edge.
    669668    Edge addEdge(const Node& s, const Node& t) {
    670669      return Parent::addEdge(s, t);
     
    729728        dir.push_back(arcFromId(n-1));
    730729        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;
    733732        arcs.pop_back();
    734733        arcs.pop_back();
  • lemon/time_measure.h

    r528 r631  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    288288    Timer(bool run=true) :_running(run) {_reset();}
    289289
    290     ///\name Control the state of the timer
     290    ///\name Control the State of the Timer
    291291    ///Basically a Timer can be either running or stopped,
    292292    ///but it provides a bit finer control on the execution.
     
    396396    ///@}
    397397
    398     ///\name Query Functions for the ellapsed time
     398    ///\name Query Functions for the Ellapsed Time
    399399
    400400    ///@{
  • lemon/tolerance.h

    r516 r564  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
  • lemon/unionfind.h

    r460 r606  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    5252  /// \pre You need to add all the elements by the \ref insert()
    5353  /// method.
    54   template <typename _ItemIntMap>
     54  template <typename IM>
    5555  class UnionFind {
    5656  public:
    5757
    58     typedef _ItemIntMap ItemIntMap;
     58    ///\e
     59    typedef IM ItemIntMap;
     60    ///\e
    5961    typedef typename ItemIntMap::Key Item;
    6062
     
    171173  /// method.
    172174  ///
    173   template <typename _ItemIntMap>
     175  template <typename IM>
    174176  class UnionFindEnum {
    175177  public:
    176178
    177     typedef _ItemIntMap ItemIntMap;
     179    ///\e
     180    typedef IM ItemIntMap;
     181    ///\e
    178182    typedef typename ItemIntMap::Key Item;
    179183
     
    628632  /// \pre You need to add all the elements by the \ref insert()
    629633  /// method.
    630   template <typename _ItemIntMap>
     634  template <typename IM>
    631635  class ExtendFindEnum {
    632636  public:
    633637
    634     typedef _ItemIntMap ItemIntMap;
     638    ///\e
     639    typedef IM ItemIntMap;
     640    ///\e
    635641    typedef typename ItemIntMap::Key Item;
    636642
     
    949955  /// \pre You need to add all the elements by the \ref insert()
    950956  /// 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> >
    954958  class HeapUnionFind {
    955959  public:
    956960
    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;
    963969
    964970  private:
     
    11901196              popLeft(nodes[jd].next);
    11911197              pushRight(jd, ld);
    1192               if (less(ld, nodes[jd].left) || 
     1198              if (less(ld, nodes[jd].left) ||
    11931199                  nodes[ld].item == nodes[pd].item) {
    11941200                nodes[jd].item = nodes[ld].item;
     
    16021608    /// \brief Gives back the priority of the current item.
    16031609    ///
    1604     /// \return Gives back the priority of the current item.
     1610    /// Gives back the priority of the current item.
    16051611    const Value& operator[](const Item& item) const {
    16061612      return nodes[index[item]].prio;
     
    16471653    /// \brief Gives back the minimum priority of the class.
    16481654    ///
    1649     /// \return Gives back the minimum priority of the class.
     1655    /// Gives back the minimum priority of the class.
    16501656    const Value& classPrio(int cls) const {
    16511657      return nodes[~(classes[cls].parent)].prio;
     
    16611667    /// \brief Gives back a representant item of the class.
    16621668    ///
     1669    /// Gives back a representant item of the class.
    16631670    /// The representant is indpendent from the priorities of the
    16641671    /// items.
    1665     /// \return Gives back a representant item of the class.
    16661672    const Item& classRep(int id) const {
    16671673      int parent = classes[id].parent;
  • m4/lx_check_cplex.m4

    r187 r674  
    6262
    6363    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.])
    6569      AC_MSG_RESULT([yes])
    6670    else
  • m4/lx_check_glpk.m4

    r187 r674  
    4343      }
    4444
     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
    4550      int main(int argc, char** argv)
    4651      {
     
    6065
    6166    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.])
    6372      AC_MSG_RESULT([yes])
    6473    else
  • m4/lx_check_soplex.m4

    r187 r674  
    2121      SOPLEX_CXXFLAGS="-I$with_soplex_includedir"
    2222    elif test x"$with_soplex" != x"yes"; then
    23       SOPLEX_CXXFLAGS="-I$with_soplex/include"
     23      SOPLEX_CXXFLAGS="-I$with_soplex/src"
    2424    fi
    2525
     
    3939
    4040    lx_soplex_test_prog='
    41       #include <soplex/soplex.h>
     41      #include <soplex.h>
    4242
    4343      int main(int argc, char** argv)
     
    5656
    5757    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.])
    5961      AC_MSG_RESULT([yes])
    6062    else
  • scripts/chg-len.py

    r284 r439  
    22
    33import sys
    4 import os
     4
     5from mercurial import ui, hg
     6from mercurial import util
     7
     8util.rcpath = lambda : []
    59
    610if len(sys.argv)>1 and sys.argv[1] in ["-h","--help"]:
     
    1014"""
    1115    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])
    1716
    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])
     17u = ui.ui()
     18r = hg.repository(u, ".")
     19N = r.changectx(".").rev()
     20lengths=[0]*(N+1)
     21for i in range(N+1):
     22    p=r.changectx(i).parents()
     23    if p[0]:
     24        p0=lengths[p[0].rev()]
    3325    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()]
    3829    else:
    39         lengths.append(max(lengths[par1],lengths[par2])+1)
    40 print lengths[PAR]
     30        p1=-1
     31    lengths[i]=max(p0,p1)+1
     32print lengths[N]
  • scripts/mk-release.sh

    r536 r611  
    1515
    1616autoreconf -vif
    17 ./configure --enable-demo
     17./configure
    1818
    1919make
  • scripts/unify-sources.sh

    r538 r675  
    77    if [ -n "$(hg st $1)" ]; then
    88        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
     13function 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
     19function 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
     25function 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
     40function given_files() {
     41    for file in $GIVEN_FILES
     42    do
     43        echo $file
     44    done
     45}
     46
     47# actions
     48
     49function 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
     59function update_warning() {
     60    echo -n " [$2 warning]"
     61    WARNED=YES
     62}
     63
     64function update_init() {
     65    echo Update source files...
     66    TOTAL_FILES=0
     67    CHANGED_FILES=0
     68    WARNED_FILES=0
     69}
     70
     71function 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
     76function update_begin() {
     77    ((TOTAL_FILES++))
     78    CHANGED=NO
     79    WARNED=NO
     80}
     81
     82function 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
     93function 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
     122function 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
     132function check_init() {
     133    echo Check source files...
     134    FAILED_FILES=0
     135    WARNED_FILES=0
     136    TOTAL_FILES=0
     137}
     138
     139function 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
     166function check_begin() {
     167    ((TOTAL_FILES++))
     168    FAILED=NO
     169    WARNED=NO
     170}
     171
     172function 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
     187function header_check() {
     188    if echo $1 | grep -q -E 'Makefile\.am$'
     189    then
     190        return
     191    fi
     192
    16193    TMP_FILE=`mktemp`
    17     FILE_NAME=$1
    18194
    19195    (echo "/* -*- mode: C++; indent-tabs-mode: nil; -*-
     
    35211 */
    36212"
    37         awk 'BEGIN { pm=0; }
     213    awk 'BEGIN { pm=0; }
    38214     pm==3 { print }
    39215     /\/\* / && pm==0 { pm=1;}
     
    41217     /\*\// && pm==1 { pm=2;}
    42218    ' $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
     224function 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
    52233    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
     239function spaces_check() {
    65240    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
     246function 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
     255function 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
    122267    do
    123         update_file $HGROOT/$i
    124         ((TOTAL_FILES++))
     268        "$check"_check $1
    125269    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
     277function process_all {
     278    "$ACTION"_init
     279    while read file
    129280    do
    130         update_file $i
    131         ((TOTAL_FILES++))
    132     done
     281        process_file $file
     282    done < <($FILES)
     283    "$ACTION"_done
     284}
     285
     286while [ $# -gt 0 ]
     287do
     288   
     289    if [ "$1" == '--help' ] || [ "$1" == '-h' ]
     290    then
     291        echo -n \
     292"Usage:
     293  $0 [OPTIONS] [files]
     294Options:
     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
     360done
     361
     362if [ -z $FILES ]
     363then
     364    FILES=modified_files
    133365fi
    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
     367if [ -z $ACTION ]
     368then
     369    ACTION=update
    143370fi
     371
     372process_all
  • test/CMakeLists.txt

    r225 r674  
    1 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
     1INCLUDE_DIRECTORIES(
     2  ${PROJECT_SOURCE_DIR}
     3  ${PROJECT_BINARY_DIR}
     4)
    25
    3 LINK_DIRECTORIES(${CMAKE_BINARY_DIR}/lemon)
     6LINK_DIRECTORIES(${PROJECT_BINARY_DIR}/lemon)
    47
    58SET(TESTS
     9  adaptors_test
    610  bfs_test
     11  circulation_test
    712  counter_test
    813  dfs_test
     
    1015  dijkstra_test
    1116  dim_test
     17  edge_set_test
    1218  error_test
     19  euler_test
     20  gomory_hu_test
    1321  graph_copy_test
    1422  graph_test
    1523  graph_utils_test
     24  hao_orlin_test
    1625  heap_test
    1726  kruskal_test
    1827  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
    1934  random_test
    20   path_test
     35  suurballe_test
    2136  time_measure_test
    2237  unionfind_test)
     38
     39IF(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)
     70ENDIF(LEMON_HAVE_LP)
     71
     72IF(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)
     103ENDIF(LEMON_HAVE_MIP)
    23104
    24105FOREACH(TEST_NAME ${TESTS})
  • test/Makefile.am

    r228 r658  
    44noinst_HEADERS += \
    55        test/graph_test.h \
    6         test/test_tools.h
     6        test/test_tools.h
    77
    88check_PROGRAMS += \
     9        test/adaptors_test \
    910        test/bfs_test \
    10         test/counter_test \
     11        test/circulation_test \
     12        test/counter_test \
    1113        test/dfs_test \
    1214        test/digraph_test \
    1315        test/dijkstra_test \
    14         test/dim_test \
     16        test/dim_test \
     17        test/edge_set_test \
    1518        test/error_test \
     19        test/euler_test \
     20        test/gomory_hu_test \
    1621        test/graph_copy_test \
    1722        test/graph_test \
    1823        test/graph_utils_test \
     24        test/hao_orlin_test \
    1925        test/heap_test \
    2026        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 \
    2739        test/unionfind_test
     40
     41test_test_tools_pass_DEPENDENCIES = demo
     42
     43if HAVE_LP
     44check_PROGRAMS += test/lp_test
     45endif HAVE_LP
     46if HAVE_MIP
     47check_PROGRAMS += test/mip_test
     48endif HAVE_MIP
    2849
    2950TESTS += $(check_PROGRAMS)
    3051XFAIL_TESTS += test/test_tools_fail$(EXEEXT)
    3152
     53test_adaptors_test_SOURCES = test/adaptors_test.cc
    3254test_bfs_test_SOURCES = test/bfs_test.cc
     55test_circulation_test_SOURCES = test/circulation_test.cc
    3356test_counter_test_SOURCES = test/counter_test.cc
    3457test_dfs_test_SOURCES = test/dfs_test.cc
     
    3659test_dijkstra_test_SOURCES = test/dijkstra_test.cc
    3760test_dim_test_SOURCES = test/dim_test.cc
     61test_edge_set_test_SOURCES = test/edge_set_test.cc
    3862test_error_test_SOURCES = test/error_test.cc
     63test_euler_test_SOURCES = test/euler_test.cc
     64test_gomory_hu_test_SOURCES = test/gomory_hu_test.cc
    3965test_graph_copy_test_SOURCES = test/graph_copy_test.cc
    4066test_graph_test_SOURCES = test/graph_test.cc
     
    4268test_heap_test_SOURCES = test/heap_test.cc
    4369test_kruskal_test_SOURCES = test/kruskal_test.cc
     70test_hao_orlin_test_SOURCES = test/hao_orlin_test.cc
     71test_lp_test_SOURCES = test/lp_test.cc
    4472test_maps_test_SOURCES = test/maps_test.cc
     73test_mip_test_SOURCES = test/mip_test.cc
     74test_matching_test_SOURCES = test/matching_test.cc
     75test_min_cost_arborescence_test_SOURCES = test/min_cost_arborescence_test.cc
     76test_min_cost_flow_test_SOURCES = test/min_cost_flow_test.cc
    4577test_path_test_SOURCES = test/path_test.cc
     78test_preflow_test_SOURCES = test/preflow_test.cc
     79test_radix_sort_test_SOURCES = test/radix_sort_test.cc
     80test_suurballe_test_SOURCES = test/suurballe_test.cc
    4681test_random_test_SOURCES = test/random_test.cc
    4782test_test_tools_fail_SOURCES = test/test_tools_fail.cc
  • test/bfs_test.cc

    r293 r632  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    5959
    6060  Digraph G;
    61   Node s, t;
     61  Node s, t, n;
    6262  Arc e;
    63   int l;
     63  int l, i;
    6464  bool b;
    6565  BType::DistMap d(G);
    6666  BType::PredMap p(G);
    6767  Path<Digraph> pp;
     68  concepts::ReadMap<Node,bool> nm;
    6869
    6970  {
    7071    BType bfs_test(G);
     72    const BType& const_bfs_test = bfs_test;
    7173
    7274    bfs_test.run(s);
     
    7476    bfs_test.run();
    7577
    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);
    8398  }
    8499  {
     
    87102      ::SetDistMap<concepts::ReadWriteMap<Node,int> >
    88103      ::SetReachedMap<concepts::ReadWriteMap<Node,bool> >
     104      ::SetStandardProcessedMap
    89105      ::SetProcessedMap<concepts::WriteMap<Node,bool> >
    90       ::SetStandardProcessedMap
    91106      ::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);
    92118
    93119    bfs_test.run(s);
    94120    bfs_test.run(s,t);
    95121    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);
    96135
    97136    l  = bfs_test.dist(t);
  • test/counter_test.cc

    r209 r605  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    1919#include <lemon/counter.h>
    2020#include <vector>
     21#include <sstream>
     22
     23#include "test/test_tools.h"
    2124
    2225using namespace lemon;
     
    2427template <typename T>
    2528void 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;
    3643      }
    37       ++co;
    3844    }
    3945  }
     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");
    4049}
    4150
    4251template <typename T>
    4352void 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;
    5569    }
    56     v[j] = value;
    57     ++as;
    5870  }
     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");
    5974}
    6075
    6176template <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();
     77void 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  }
    74101}
    75102
     
    81108int main()
    82109{
    83   counterTest<Counter>();
    84   counterTest<NoCounter>();
     110  counterTest<Counter>(true);
     111  counterTest<NoCounter>(false);
    85112
    86113  std::vector<int> x(10);
  • test/dfs_test.cc

    r293 r632  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    6363  Node s, t;
    6464  Arc e;
    65   int l;
     65  int l, i;
    6666  bool b;
    6767  DType::DistMap d(G);
    6868  DType::PredMap p(G);
    6969  Path<Digraph> pp;
     70  concepts::ReadMap<Arc,bool> am;
    7071
    7172  {
    7273    DType dfs_test(G);
     74    const DType& const_dfs_test = dfs_test;
    7375
    7476    dfs_test.run(s);
     
    7678    dfs_test.run();
    7779
    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);
    8598  }
    8699  {
     
    89102      ::SetDistMap<concepts::ReadWriteMap<Node,int> >
    90103      ::SetReachedMap<concepts::ReadWriteMap<Node,bool> >
     104      ::SetStandardProcessedMap
    91105      ::SetProcessedMap<concepts::WriteMap<Node,bool> >
    92       ::SetStandardProcessedMap
    93106      ::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);
    94118
    95119    dfs_test.run(s);
    96120    dfs_test.run(s,t);
    97121    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);
    98133
    99134    l  = dfs_test.dist(t);
  • test/digraph_test.cc

    r228 r463  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    2020#include <lemon/list_graph.h>
    2121#include <lemon/smart_graph.h>
    22 //#include <lemon/full_graph.h>
    23 //#include <lemon/hypercube_graph.h>
     22#include <lemon/full_graph.h>
    2423
    2524#include "test_tools.h"
     
    3029
    3130template <class Digraph>
    32 void checkDigraph() {
     31void checkDigraphBuild() {
    3332  TEMPLATE_DIGRAPH_TYPEDEFS(Digraph);
    3433  Digraph G;
     
    5958  checkGraphConArcList(G, 1);
    6059
    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
    6264  checkGraphNodeList(G, 3);
    6365  checkGraphArcList(G, 4);
     
    7779  checkGraphNodeMap(G);
    7880  checkGraphArcMap(G);
    79 
    80 }
    81 
     81}
     82
     83template <class Digraph>
     84void 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
     114template <class Digraph>
     115void 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
     193template <class Digraph>
     194void 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
     242template <class Digraph>
     243void 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}
    82290
    83291void checkConcepts() {
     
    110318    checkConcept<ClearableDigraphComponent<>, SmartDigraph>();
    111319  }
    112 //  { // Checking FullDigraph
    113 //    checkConcept<Digraph, FullDigraph>();
    114 //  }
    115 //  { // Checking HyperCubeDigraph
    116 //    checkConcept<Digraph, HyperCubeDigraph>();
    117 //  }
     320  { // Checking FullDigraph
     321    checkConcept<Digraph, FullDigraph>();
     322  }
    118323}
    119324
     
    168373}
    169374
     375void 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
    170407void checkDigraphs() {
    171408  { // Checking ListDigraph
    172     checkDigraph<ListDigraph>();
     409    checkDigraphBuild<ListDigraph>();
     410    checkDigraphSplit<ListDigraph>();
     411    checkDigraphAlter<ListDigraph>();
     412    checkDigraphErase<ListDigraph>();
     413    checkDigraphSnapshot<ListDigraph>();
    173414    checkDigraphValidityErase<ListDigraph>();
    174415  }
    175416  { // Checking SmartDigraph
    176     checkDigraph<SmartDigraph>();
     417    checkDigraphBuild<SmartDigraph>();
     418    checkDigraphSplit<SmartDigraph>();
     419    checkDigraphSnapshot<SmartDigraph>();
    177420    checkDigraphValidity<SmartDigraph>();
     421  }
     422  { // Checking FullDigraph
     423    checkFullDigraph(8);
    178424  }
    179425}
  • test/dijkstra_test.cc

    r412 r632  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    6161
    6262  Digraph G;
    63   Node s, t;
     63  Node s, t, n;
    6464  Arc e;
    6565  VType l;
     66  int i;
    6667  bool b;
    6768  DType::DistMap d(G);
     
    6970  LengthMap length;
    7071  Path<Digraph> pp;
     72  concepts::ReadMap<Node,bool> nm;
    7173
    7274  {
    7375    DType dijkstra_test(G,length);
     76    const DType& const_dijkstra_test = dijkstra_test;
    7477
    7578    dijkstra_test.run(s);
    7679    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);
    77143
    78144    l  = dijkstra_test.dist(t);
     
    80146    s  = dijkstra_test.predNode(t);
    81147    b  = dijkstra_test.reached(t);
    82     d  = dijkstra_test.distMap();
    83     p  = dijkstra_test.predMap();
     148    b  = dijkstra_test.processed(t);
    84149    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);
    105151  }
    106152
  • test/dim_test.cc

    r253 r463  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
  • test/error_test.cc

    r277 r463  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
  • test/graph_copy_test.cc

    r282 r463  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
  • test/graph_test.cc

    r228 r463  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    2020#include <lemon/list_graph.h>
    2121#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>
    2425
    2526#include "test_tools.h"
     
    3031
    3132template <class Graph>
    32 void checkGraph() {
     33void checkGraphBuild() {
    3334  TEMPLATE_GRAPH_TYPEDEFS(Graph);
    3435
     
    3637  checkGraphNodeList(G, 0);
    3738  checkGraphEdgeList(G, 0);
     39  checkGraphArcList(G, 0);
    3840
    3941  Node
     
    4345  checkGraphNodeList(G, 3);
    4446  checkGraphEdgeList(G, 0);
     47  checkGraphArcList(G, 0);
    4548
    4649  Edge e1 = G.addEdge(n1, n2);
    4750  check((G.u(e1) == n1 && G.v(e1) == n2) || (G.u(e1) == n2 && G.v(e1) == n1),
    4851        "Wrong edge");
    49   checkGraphNodeList(G, 3);
     52
     53  checkGraphNodeList(G, 3);
     54  checkGraphEdgeList(G, 1);
    5055  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);
    6562  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);
    7069  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);
    8576  checkGraphConArcList(G, 6);
    86   checkGraphConEdgeList(G, 3);
    8777
    8878  checkArcDirections(G);
     
    9686}
    9787
     88template <class Graph>
     89void 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
     167template <class Graph>
     168void 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
     209template <class Graph>
     210void 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
     265void 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
    98312void checkConcepts() {
    99313  { // Checking graph components
     
    125339    checkConcept<ClearableGraphComponent<>, SmartGraph>();
    126340  }
    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  }
    135350}
    136351
     
    189404}
    190405
    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 // }
     406void 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
     485void 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}
    234532
    235533void checkGraphs() {
    236534  { // Checking ListGraph
    237     checkGraph<ListGraph>();
     535    checkGraphBuild<ListGraph>();
     536    checkGraphAlter<ListGraph>();
     537    checkGraphErase<ListGraph>();
     538    checkGraphSnapshot<ListGraph>();
    238539    checkGraphValidityErase<ListGraph>();
    239540  }
    240541  { // Checking SmartGraph
    241     checkGraph<SmartGraph>();
     542    checkGraphBuild<SmartGraph>();
     543    checkGraphSnapshot<SmartGraph>();
    242544    checkGraphValidity<SmartGraph>();
    243545  }
    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  }
    255563}
    256564
  • test/graph_test.h

    r263 r463  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    115115    check(e==INVALID,"Wrong IncEdge list linking.");
    116116    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);
    117126  }
    118127
  • test/graph_utils_test.cc

    r220 r619  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    3939      digraph.addNode();
    4040    }
    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);
    4343    for (int i = 0; i < 100; ++i) {
    4444      int src = rnd[invNodes.size()];
     
    4747    }
    4848    typename Digraph::template ArcMap<bool> found(digraph, false);
    49     DescriptorMap<Digraph, Arc> arcs(digraph);
     49    RangeIdMap<Digraph, Arc> arcs(digraph);
    5050    for (NodeIt src(digraph); src != INVALID; ++src) {
    5151      for (NodeIt trg(digraph); trg != INVALID; ++trg) {
     
    114114    graph.addNode();
    115115  }
    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);
    118118  for (int i = 0; i < 100; ++i) {
    119119    int src = rnd[invNodes.size()];
     
    122122  }
    123123  typename Graph::template EdgeMap<int> found(graph, 0);
    124   DescriptorMap<Graph, Edge> edges(graph);
     124  RangeIdMap<Graph, Edge> edges(graph);
    125125  for (NodeIt src(graph); src != INVALID; ++src) {
    126126    for (NodeIt trg(graph); trg != INVALID; ++trg) {
  • test/heap_test.cc

    r293 r463  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
  • test/kruskal_test.cc

    r209 r628  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    100100        "Total cost should be 10");
    101101
    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;
    112112
    113113  vector<Edge> tree_edge_vec(5);
  • test/maps_test.cc

    r210 r554  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    171171    typedef ComposeMap<DoubleMap, ReadMap<B,A> > CompMap;
    172172    checkConcept<ReadMap<B,double>, CompMap>();
    173     CompMap map1(DoubleMap(),ReadMap<B,A>());
     173    CompMap map1 = CompMap(DoubleMap(),ReadMap<B,A>());
    174174    CompMap map2 = composeMap(DoubleMap(), ReadMap<B,A>());
    175175
     
    184184    typedef CombineMap<DoubleMap, DoubleMap, std::plus<double> > CombMap;
    185185    checkConcept<ReadMap<A,double>, CombMap>();
    186     CombMap map1(DoubleMap(), DoubleMap());
     186    CombMap map1 = CombMap(DoubleMap(), DoubleMap());
    187187    CombMap map2 = combineMap(DoubleMap(), DoubleMap(), std::plus<double>());
    188188
     
    196196    checkConcept<ReadMap<A,B>, FunctorToMap<F> >();
    197197    FunctorToMap<F> map1;
    198     FunctorToMap<F> map2(F());
     198    FunctorToMap<F> map2 = FunctorToMap<F>(F());
    199199    B b = functorToMap(F())[A()];
    200200
    201201    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>());
    203203
    204204    check(functorToMap(&func)[A()] == 3,
  • test/path_test.cc

    r209 r463  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
  • test/random_test.cc

    r209 r463  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
  • test/test_tools.h

    r209 r463  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
  • test/test_tools_fail.cc

    r209 r463  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
  • test/test_tools_pass.cc

    r209 r463  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
  • test/time_measure_test.cc

    r209 r605  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    4040  Timer T;
    4141  unsigned int n;
    42   for(n=0;T.realTime()<1.0;n++) ;
     42  for(n=0;T.realTime()<0.1;n++) ;
    4343  std::cout << T << " (" << n << " time queries)\n";
    44   T.restart();
    45   while(T.realTime()<2.0) ;
    46   std::cout << T << '\n';
     44
    4745  TimeStamp full;
    4846  TimeStamp t;
    49   t=runningTimeTest(f,1,&n,&full);
     47  t=runningTimeTest(f,0.1,&n,&full);
    5048  std::cout << t << " (" << n << " tests)\n";
    5149  std::cout << "Total: " << full << "\n";
    5250
    53   t=runningTimeTest(g,1,&n,&full);
     51  t=runningTimeTest(g,0.1,&n,&full);
    5452  std::cout << t << " (" << n << " tests)\n";
    5553  std::cout << "Total: " << full << "\n";
  • test/unionfind_test.cc

    r209 r463  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
  • tools/Makefile.am

    r310 r573  
    11if WANT_TOOLS
    22
    3 bin_PROGRAMS +=
     3bin_PROGRAMS += \
     4        tools/dimacs-solver \
     5        tools/dimacs-to-lgf \
     6        tools/lgf-gen
     7
    48dist_bin_SCRIPTS += tools/lemon-0.x-to-1.x.sh
    59
    610endif WANT_TOOLS
     11
     12tools_dimacs_solver_SOURCES = tools/dimacs-solver.cc
     13tools_dimacs_to_lgf_SOURCES = tools/dimacs-to-lgf.cc
     14tools_lgf_gen_SOURCES = tools/lgf-gen.cc
  • tools/lemon-0.x-to-1.x.sh

    r310 r621  
    44
    55if [ $# -eq 0 -o x$1 = "x-h" -o x$1 = "x-help" -o x$1 = "x--help" ]; then
    6         echo "Usage:"
    7         echo "  $0 source-file"
    8         exit
     6    echo "Usage:"
     7    echo "  $0 source-file(s)"
     8    exit
    99fi
    1010
    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
     11for i in $@
     12do
     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
     129done
Note: See TracChangeset for help on using the changeset viewer.