Changes in / [355:aa75d24ba7d0:356:99f1bdf8f7db] in lemon-1.2
- Files:
-
- 14 added
- 1 deleted
- 69 edited
Legend:
- Unmodified
- Added
- Removed
-
.hgignore
r155 r298 30 30 syntax: regexp 31 31 (.*/)?\#[^/]*\#$ 32 (.*/)?\.\#[^/]*$ 32 33 ^doc/html/.* 34 ^doc/.*\.tag 33 35 ^autom4te.cache/.* 34 36 ^build-aux/.* -
CMakeLists.txt
r236 r274 1 1 CMAKE_MINIMUM_REQUIRED(VERSION 2.6) 2 2 3 #EXECUTE_PROCESS(4 # COMMAND hg id -i5 # OUTPUT_VARIABLE HG_REVISION6 # OUTPUT_STRIP_TRAILING_WHITESPACE)7 8 3 SET(PROJECT_NAME "LEMON") 9 SET(PROJECT_VERSION_MAJOR "0") 10 SET(PROJECT_VERSION_MINOR "99") 11 SET(PROJECT_VERSION_PATCH "0") 12 SET(PROJECT_VERSION 13 "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}") 4 SET(PROJECT_VERSION "hg-tip" CACHE STRING "The version string.") 14 5 15 6 PROJECT(${PROJECT_NAME}) … … 40 31 SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE") 41 32 42 SET(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})43 SET(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})44 SET(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})45 33 SET(CPACK_PACKAGE_VERSION ${PROJECT_VERSION}) 46 34 47 35 SET(CPACK_PACKAGE_INSTALL_DIRECTORY 48 "${PROJECT_NAME} ${PROJECT_VERSION _MAJOR}.${PROJECT_VERSION_MINOR}")36 "${PROJECT_NAME} ${PROJECT_VERSION}") 49 37 SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY 50 "${PROJECT_NAME} ${PROJECT_VERSION _MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")38 "${PROJECT_NAME} ${PROJECT_VERSION}") 51 39 52 40 # Variables to generate a component-based installer. -
INSTALL
r245 r318 2 2 ========================= 3 3 4 4 Since you are reading this I assume you already obtained one of the release 5 5 tarballs and successfully extracted it. The latest version of LEMON is 6 6 available at our web page (http://lemon.cs.elte.hu/). 7 7 8 8 In order to install LEMON from the extracted source tarball you have to 9 9 issue the following commands: 10 10 … … 22 22 23 23 This command compiles the non-template part of LEMON into libemon.a 24 file. It also compiles the programs in the tools , benchmark and demo25 subdirectorieswhen enabled.24 file. It also compiles the programs in the tools and demo subdirectories 25 when enabled. 26 26 27 27 4. `make check' … … 50 50 =============================== 51 51 52 52 In step 2 you can customize the actions of configure by setting variables 53 53 and passing options to it. This can be done like this: 54 54 `./configure [OPTION]... [VARIABLE=VALUE]...' 55 55 56 Below you will find some useful variables and options (see 57 `./configure --help'for more):56 Below you will find some useful variables and options (see `./configure --help' 57 for more): 58 58 59 59 CXX='comp' … … 77 77 78 78 Do not build the examples in the demo subdirectory (default). 79 80 --enable-benchmark81 82 Build the programs in the benchmark subdirectory.83 84 --disable-benchmark85 86 Do not build the programs in the benchmark subdirectory (default).87 79 88 80 --enable-tools -
Makefile.am
r227 r321 5 5 6 6 EXTRA_DIST = \ 7 AUTHORS \ 7 8 LICENSE \ 8 9 m4/lx_check_cplex.m4 \ … … 25 26 bin_PROGRAMS = 26 27 check_PROGRAMS = 28 dist_bin_SCRIPTS = 27 29 TESTS = 28 30 XFAIL_TESTS = … … 32 34 include doc/Makefile.am 33 35 include demo/Makefile.am 34 include benchmark/Makefile.am35 36 include tools/Makefile.am 36 37 -
NEWS
r5 r322 1 2008-10-13 Version 1.0 released 2 3 This is the first stable release of LEMON. Compared to the 0.x 4 release series, it features a considerably smaller but more 5 matured set of tools. The API has also completely revised and 6 changed in several places. 7 8 * The major name changes compared to the 0.x series (see the 9 Migration Guide in the doc for more details) 10 * Graph -> Digraph, UGraph -> Graph 11 * Edge -> Arc, UEdge -> Edge 12 * source(UEdge)/target(UEdge) -> u(Edge)/v(Edge) 13 * Other improvements 14 * Better documentation 15 * Reviewed and cleaned up codebase 16 * CMake based build system (along with the autotools based one) 17 * Contents of the library (ported from 0.x) 18 * Algorithms 19 * breadth-first search (bfs.h) 20 * depth-first search (dfs.h) 21 * Dijkstra's algorithm (dijkstra.h) 22 * Kruskal's algorithm (kruskal.h) 23 * Data structures 24 * graph data structures (list_graph.h, smart_graph.h) 25 * path data structures (path.h) 26 * binary heap data structure (bin_heap.h) 27 * union-find data structures (unionfind.h) 28 * miscellaneous property maps (maps.h) 29 * two dimensional vector and bounding box (dim2.h) 30 * Concepts 31 * graph structure concepts (concepts/digraph.h, concepts/graph.h, 32 concepts/graph_components.h) 33 * concepts for other structures (concepts/heap.h, concepts/maps.h, 34 concepts/path.h) 35 * Tools 36 * Mersenne twister random number generator (random.h) 37 * tools for measuring cpu and wall clock time (time_measure.h) 38 * tools for counting steps and events (counter.h) 39 * tool for parsing command line arguments (arg_parser.h) 40 * tool for visualizing graphs (graph_to_eps.h) 41 * tools for reading and writing data in LEMON Graph Format 42 (lgf_reader.h, lgf_writer.h) 43 * tools to handle the anomalies of calculations with 44 floating point numbers (tolerance.h) 45 * tools to manage RGB colors (color.h) 46 * Infrastructure 47 * extended assertion handling (assert.h) 48 * exception classes and error handling (error.h) 49 * concept checking (concept_check.h) 50 * commonly used mathematical constants (math.h) -
README
r246 r318 36 36 test/ 37 37 38 Contains programs to check the integrity and correctness of LEMON. 39 40 benchmark/ 41 42 Contains programs for measuring the performance of algorithms. 38 Programs to check the integrity and correctness of LEMON. 43 39 44 40 tools/ -
configure.ac
r236 r310 2 2 3 3 dnl Version information. 4 m4_define([lemon_version_number], []) 4 m4_define([lemon_version_number], 5 [m4_normalize(esyscmd([echo ${LEMON_VERSION}]))]) 6 dnl m4_define([lemon_version_number], []) 7 m4_define([lemon_hg_path], [m4_normalize(esyscmd([./scripts/chg-len.py]))]) 5 8 m4_define([lemon_hg_revision], [m4_normalize(esyscmd([hg id -i]))]) 6 m4_define([lemon_version], [ifelse(lemon_version_number(), [], [lemon_hg_revision()], [lemon_version_number()])]) 9 m4_define([lemon_version], [ifelse(lemon_version_number(), 10 [], 11 [lemon_hg_path().lemon_hg_revision()], 12 [lemon_version_number()])]) 7 13 8 14 AC_PREREQ([2.59]) … … 16 22 lx_cmdline_cxxflags_set=${CXXFLAGS+set} 17 23 24 dnl Do compilation tests using the C++ compiler. 25 AC_LANG([C++]) 26 18 27 dnl Checks for programs. 19 28 AC_PROG_CXX … … 26 35 AC_CHECK_PROG([gs_found],[gs],[yes],[no]) 27 36 37 dnl Detect Intel compiler. 38 AC_MSG_CHECKING([whether we are using the Intel C++ compiler]) 39 AC_COMPILE_IFELSE([#ifndef __INTEL_COMPILER 40 choke me 41 #endif], [ICC=[yes]], [ICC=[no]]) 42 if test x"$ICC" = x"yes"; then 43 AC_MSG_RESULT([yes]) 44 else 45 AC_MSG_RESULT([no]) 46 fi 47 28 48 dnl Set custom compiler flags when using g++. 29 if test x"$lx_cmdline_cxxflags_set" != x"set" -a "$GXX" = yes ; then49 if test x"$lx_cmdline_cxxflags_set" != x"set" -a "$GXX" = yes -a "$ICC" = no; then 30 50 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" 31 51 fi 32 52 33 53 dnl Checks for libraries. 34 LX_CHECK_GLPK35 LX_CHECK_CPLEX36 LX_CHECK_SOPLEX54 #LX_CHECK_GLPK 55 #LX_CHECK_CPLEX 56 #LX_CHECK_SOPLEX 37 57 38 58 dnl Disable/enable building the demo programs. … … 61 81 fi 62 82 AM_CONDITIONAL([WANT_TOOLS], [test x"$enable_tools" != x"no"]) 63 64 dnl Disable/enable building the benchmarks.65 AC_ARG_ENABLE([benchmark],66 AS_HELP_STRING([--enable-benchmark], [build the benchmarks])67 AS_HELP_STRING([--disable-benchmark], [do not build the benchmarks @<:@default@:>@]),68 [], [enable_benchmark=no])69 AC_MSG_CHECKING([whether to build the benchmarks])70 if test x"$enable_benchmark" != x"no"; then71 AC_MSG_RESULT([yes])72 else73 AC_MSG_RESULT([no])74 fi75 AM_CONDITIONAL([WANT_BENCHMARK], [test x"$enable_benchmark" != x"no"])76 83 77 84 dnl Checks for header files. … … 109 116 echo C++ compiles flags............ : $CXXFLAGS 110 117 echo 111 echo GLPK support.................. : $lx_glpk_found 112 echo CPLEX support................. : $lx_cplex_found 113 echo SOPLEX support................ : $lx_soplex_found 114 echo 115 echo Build benchmarks.............. : $enable_benchmark 118 #echo GLPK support.................. : $lx_glpk_found 119 #echo CPLEX support................. : $lx_cplex_found 120 #echo SOPLEX support................ : $lx_soplex_found 121 #echo 116 122 echo Build demo programs........... : $enable_demo 117 123 echo Build additional tools........ : $enable_tools -
demo/arg_parser_demo.cc
r209 r311 28 28 29 29 using namespace lemon; 30 int main(int argc, c onst char **argv)30 int main(int argc, char **argv) 31 31 { 32 32 // Initialize the argument parser -
demo/graph_to_eps_demo.cc
r220 r313 27 27 /// how to handle parallel egdes, how to change the properties (like 28 28 /// color, shape, size, title etc.) of nodes and arcs individually 29 /// using appropriate \ref maps-page "graph maps".29 /// using appropriate graph maps. 30 30 /// 31 31 /// \include graph_to_eps_demo.cc -
demo/lgf_demo.cc
r209 r294 45 45 46 46 try { 47 digraphReader( "digraph.lgf", g). // read the directed graph into g47 digraphReader(g, "digraph.lgf"). // read the directed graph into g 48 48 arcMap("capacity", cap). // read the 'capacity' arc map into cap 49 49 node("source", s). // read 'source' node to s 50 50 node("target", t). // read 'target' node to t 51 51 run(); 52 } catch ( DataFormatError& error) { // check if there was any error52 } catch (Exception& error) { // check if there was any error 53 53 std::cerr << "Error: " << error.what() << std::endl; 54 54 return -1; … … 61 61 std::cout << "We can write it to the standard output:" << std::endl; 62 62 63 digraphWriter( std::cout, g).// write g to the standard output63 digraphWriter(g). // write g to the standard output 64 64 arcMap("capacity", cap). // write cap into 'capacity' 65 65 node("source", s). // write s to 'source' -
doc/CMakeLists.txt
r225 r335 14 14 COMMAND rm -rf gen-images 15 15 COMMAND mkdir gen-images 16 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 16 17 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 17 18 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 -
doc/Doxyfile.in
r226 r316 1 # Doxyfile 1.5. 51 # Doxyfile 1.5.7.1 2 2 3 3 #--------------------------------------------------------------------------- … … 34 34 CPP_CLI_SUPPORT = NO 35 35 SIP_SUPPORT = NO 36 IDL_PROPERTY_SUPPORT = YES 36 37 DISTRIBUTE_GROUP_DOC = NO 37 38 SUBGROUPING = YES 38 39 TYPEDEF_HIDES_STRUCT = NO 40 SYMBOL_CACHE_SIZE = 0 39 41 #--------------------------------------------------------------------------- 40 42 # Build related configuration options … … 67 69 SHOW_USED_FILES = YES 68 70 SHOW_DIRECTORIES = YES 71 SHOW_FILES = YES 72 SHOW_NAMESPACES = YES 69 73 FILE_VERSION_FILTER = 74 LAYOUT_FILE = DoxygenLayout.xml 70 75 #--------------------------------------------------------------------------- 71 76 # configuration options related to warning and progress messages … … 76 81 WARN_IF_DOC_ERROR = YES 77 82 WARN_NO_PARAMDOC = NO 78 WARN_FORMAT = "$file:$line: $text 83 WARN_FORMAT = "$file:$line: $text" 79 84 WARN_LOGFILE = doxygen.log 80 85 #--------------------------------------------------------------------------- … … 134 139 HTML_STYLESHEET = 135 140 HTML_ALIGN_MEMBERS = YES 136 GENERATE_HTMLHELP= NO141 HTML_DYNAMIC_SECTIONS = NO 137 142 GENERATE_DOCSET = NO 138 143 DOCSET_FEEDNAME = "Doxygen generated docs" 139 144 DOCSET_BUNDLE_ID = org.doxygen.Project 140 HTML_DYNAMIC_SECTIONS= NO145 GENERATE_HTMLHELP = NO 141 146 CHM_FILE = 142 147 HHC_LOCATION = 143 148 GENERATE_CHI = NO 149 CHM_INDEX_ENCODING = 144 150 BINARY_TOC = NO 145 151 TOC_EXPAND = NO 152 GENERATE_QHP = NO 153 QCH_FILE = 154 QHP_NAMESPACE = org.doxygen.Project 155 QHP_VIRTUAL_FOLDER = doc 156 QHG_LOCATION = 146 157 DISABLE_INDEX = NO 147 158 ENUM_VALUES_PER_LINE = 4 148 159 GENERATE_TREEVIEW = NO 149 160 TREEVIEW_WIDTH = 250 161 FORMULA_FONTSIZE = 10 150 162 #--------------------------------------------------------------------------- 151 163 # configuration options related to the LaTeX output … … 222 234 # Configuration options related to the dot tool 223 235 #--------------------------------------------------------------------------- 224 CLASS_DIAGRAMS = NO236 CLASS_DIAGRAMS = YES 225 237 MSCGEN_PATH = 226 238 HIDE_UNDOC_RELATIONS = YES 227 239 HAVE_DOT = YES 240 DOT_FONTNAME = FreeSans 241 DOT_FONTSIZE = 10 242 DOT_FONTPATH = 228 243 CLASS_GRAPH = YES 229 244 COLLABORATION_GRAPH = NO -
doc/Makefile.am
r227 r337 1 1 EXTRA_DIST += \ 2 2 doc/Doxyfile.in \ 3 doc/DoxygenLayout.xml \ 3 4 doc/coding_style.dox \ 4 5 doc/dirs.dox \ … … 7 8 doc/license.dox \ 8 9 doc/mainpage.dox \ 10 doc/migration.dox \ 11 doc/named-param.dox \ 9 12 doc/namespaces.dox \ 10 13 doc/html \ … … 12 15 13 16 DOC_EPS_IMAGES18 = \ 17 grid_graph.eps \ 14 18 nodeshape_0.eps \ 15 19 nodeshape_1.eps \ -
doc/dirs.dox
r209 r318 19 19 /** 20 20 \dir demo 21 \brief A collection of demo application .21 \brief A collection of demo applications. 22 22 23 This directory contains several simple demo application , mainly23 This directory contains several simple demo applications, mainly 24 24 for educational purposes. 25 25 */ … … 29 29 \brief Auxiliary (and the whole generated) documentation. 30 30 31 Auxiliary (and the whole generated) documentation. 31 This directory contains some auxiliary pages and the whole generated 32 documentation. 32 33 */ 33 34 … … 42 43 /** 43 44 \dir tools 44 \brief Some useful executables 45 \brief Some useful executables. 45 46 46 47 This directory contains the sources of some useful complete executables. 47 48 48 */ 49 50 51 49 52 50 /** 53 51 \dir lemon 54 \brief Base include directory of LEMON 52 \brief Base include directory of LEMON. 55 53 56 This is the base directory of lemonincludes, so each include file must be54 This is the base directory of LEMON includes, so each include file must be 57 55 prefixed with this, e.g. 58 56 \code … … 64 62 /** 65 63 \dir concepts 66 \brief Concept descriptors and checking classes 64 \brief Concept descriptors and checking classes. 67 65 68 This directory contains the concept descriptors and concept check ers. As a user69 you typically don't have to deal with these files.66 This directory contains the concept descriptors and concept checking tools. 67 For more information see the \ref concept "Concepts" module. 70 68 */ 71 69 72 70 /** 73 71 \dir bits 74 \brief Implementation helper files72 \brief Auxiliary tools for implementation. 75 73 76 This directory contains some helper classes to implement graphs, maps and77 some other classes. As a user you typically don't have to deal with these 78 files.74 This directory contains some auxiliary classes for implementing graphs, 75 maps and some other classes. 76 As a user you typically don't have to deal with these files. 79 77 */ -
doc/groups.dox
r236 r318 55 55 You are free to use the graph structure that fit your requirements 56 56 the best, most graph algorithms and auxiliary data structures can be used 57 with any graph structures. 57 with any graph structure. 58 59 <b>See also:</b> \ref graph_concepts "Graph Structure Concepts". 58 60 */ 59 61 … … 75 77 This group describes the map structures implemented in LEMON. 76 78 77 LEMON provides several special purpose maps that e.g. combine79 LEMON provides several special purpose maps and map adaptors that e.g. combine 78 80 new maps from existing ones. 81 82 <b>See also:</b> \ref map_concepts "Map Concepts". 79 83 */ 80 84 … … 87 91 values to the nodes and arcs of graphs. 88 92 */ 89 90 93 91 94 /** … … 105 108 algorithms. If a function type algorithm is called then the function 106 109 type map adaptors can be used comfortable. For example let's see the 107 usage of map adaptors with the \c digraphToEps() function.110 usage of map adaptors with the \c graphToEps() function. 108 111 \code 109 112 Color nodeColor(int deg) { … … 119 122 Digraph::NodeMap<int> degree_map(graph); 120 123 121 digraphToEps(graph, "graph.eps")124 graphToEps(graph, "graph.eps") 122 125 .coords(coords).scaleToA4().undirected() 123 126 .nodeColors(composeMap(functorToMap(nodeColor), degree_map)) … … 125 128 \endcode 126 129 The \c functorToMap() function makes an \c int to \c Color map from the 127 \ e nodeColor() function. The \c composeMap() compose the \edegree_map130 \c nodeColor() function. The \c composeMap() compose the \c degree_map 128 131 and the previously created map. The composed map is a proper function to 129 132 get the color of each node. … … 163 166 @defgroup paths Path Structures 164 167 @ingroup datas 165 \brief Path structures implemented in LEMON.168 \brief %Path structures implemented in LEMON. 166 169 167 170 This group describes the path structures implemented in LEMON. … … 174 177 175 178 \sa lemon::concepts::Path 176 177 179 */ 178 180 … … 186 188 */ 187 189 188 189 190 /** 190 191 @defgroup algs Algorithms … … 202 203 203 204 This group describes the common graph search algorithms like 204 Breadth- first search (Bfs) and Depth-first search (Dfs).205 */ 206 207 /** 208 @defgroup shortest_path Shortest Path algorithms205 Breadth-First Search (BFS) and Depth-First Search (DFS). 206 */ 207 208 /** 209 @defgroup shortest_path Shortest Path Algorithms 209 210 @ingroup algs 210 211 \brief Algorithms for finding shortest paths. … … 214 215 215 216 /** 216 @defgroup max_flow Maximum Flow algorithms217 @defgroup max_flow Maximum Flow Algorithms 217 218 @ingroup algs 218 219 \brief Algorithms for finding maximum flows. … … 242 243 provides functions to query the minimum cut, which is the dual linear 243 244 programming problem of the maximum flow. 244 245 */ 246 247 /** 248 @defgroup min_cost_flow Minimum Cost Flow algorithms 245 */ 246 247 /** 248 @defgroup min_cost_flow Minimum Cost Flow Algorithms 249 249 @ingroup algs 250 250 … … 256 256 257 257 /** 258 @defgroup min_cut Minimum Cut algorithms258 @defgroup min_cut Minimum Cut Algorithms 259 259 @ingroup algs 260 260 … … 283 283 If you want to find minimum cut just between two distinict nodes, 284 284 please see the \ref max_flow "Maximum Flow page". 285 286 */ 287 288 /** 289 @defgroup graph_prop Connectivity and other graph properties 285 */ 286 287 /** 288 @defgroup graph_prop Connectivity and Other Graph Properties 290 289 @ingroup algs 291 290 \brief Algorithms for discovering the graph properties … … 299 298 300 299 /** 301 @defgroup planar Planarity embedding and drawing300 @defgroup planar Planarity Embedding and Drawing 302 301 @ingroup algs 303 302 \brief Algorithms for planarity checking, embedding and drawing … … 311 310 312 311 /** 313 @defgroup matching Matching algorithms312 @defgroup matching Matching Algorithms 314 313 @ingroup algs 315 314 \brief Algorithms for finding matchings in graphs and bipartite graphs. … … 349 348 \image html bipartite_matching.png 350 349 \image latex bipartite_matching.eps "Bipartite Matching" width=\textwidth 351 352 */ 353 354 /** 355 @defgroup spantree Minimum Spanning Tree algorithms 350 */ 351 352 /** 353 @defgroup spantree Minimum Spanning Tree Algorithms 356 354 @ingroup algs 357 355 \brief Algorithms for finding a minimum cost spanning tree in a graph. … … 361 359 */ 362 360 363 364 /** 365 @defgroup auxalg Auxiliary algorithms 361 /** 362 @defgroup auxalg Auxiliary Algorithms 366 363 @ingroup algs 367 364 \brief Auxiliary algorithms implemented in LEMON. … … 372 369 373 370 /** 374 @defgroup approx Approximation algorithms 371 @defgroup approx Approximation Algorithms 372 @ingroup algs 375 373 \brief Approximation algorithms. 376 374 … … 386 384 This group describes some general optimization frameworks 387 385 implemented in LEMON. 388 389 */ 390 391 /** 392 @defgroup lp_group Lp and Mip solvers 386 */ 387 388 /** 389 @defgroup lp_group Lp and Mip Solvers 393 390 @ingroup gen_opt_group 394 391 \brief Lp and Mip solver interfaces for LEMON. … … 397 394 various LP solvers could be used in the same manner with this 398 395 interface. 399 400 */ 401 402 /** 403 @defgroup lp_utils Tools for Lp and Mip solvers 396 */ 397 398 /** 399 @defgroup lp_utils Tools for Lp and Mip Solvers 404 400 @ingroup lp_group 405 401 \brief Helper tools to the Lp and Mip solvers. … … 442 438 443 439 /** 444 @defgroup timecount Time measuring and Counting440 @defgroup timecount Time Measuring and Counting 445 441 @ingroup misc 446 442 \brief Simple tools for measuring the performance of algorithms. … … 448 444 This group describes simple tools for measuring the performance 449 445 of algorithms. 450 */451 452 /**453 @defgroup graphbits Tools for Graph Implementation454 @ingroup utils455 \brief Tools to make it easier to create graphs.456 457 This group describes the tools that makes it easier to create graphs and458 the maps that dynamically update with the graph changes.459 446 */ 460 447 … … 472 459 473 460 This group describes the tools for importing and exporting graphs 474 and graph related data. Now it supports the LEMON format, the 475 \c DIMACS format and the encapsulated postscript (EPS) format. 461 and graph related data. Now it supports the \ref lgf-format 462 "LEMON Graph Format", the \c DIMACS format and the encapsulated 463 postscript (EPS) format. 476 464 */ 477 465 … … 479 467 @defgroup lemon_io LEMON Input-Output 480 468 @ingroup io_group 481 \brief Reading and writing \ref lgf-format "LEMON Graph Format".469 \brief Reading and writing LEMON Graph Format. 482 470 483 471 This group describes methods for reading and writing … … 486 474 487 475 /** 488 @defgroup eps_io Postscript exporting476 @defgroup eps_io Postscript Exporting 489 477 @ingroup io_group 490 478 \brief General \c EPS drawer and graph exporter … … 494 482 */ 495 483 496 497 484 /** 498 485 @defgroup concept Concepts … … 504 491 The purpose of the classes in this group is fourfold. 505 492 506 - These classes contain the documentations of the concepts. In order493 - These classes contain the documentations of the %concepts. In order 507 494 to avoid document multiplications, an implementation of a concept 508 495 simply refers to the corresponding concept class. 509 496 510 497 - These classes declare every functions, <tt>typedef</tt>s etc. an 511 implementation of the concepts should provide, however completely498 implementation of the %concepts should provide, however completely 512 499 without implementations and real data structures behind the 513 500 interface. On the other hand they should provide nothing else. All … … 522 509 523 510 - Finally, They can serve as a skeleton of a new implementation of a concept. 524 525 */ 526 511 */ 527 512 528 513 /** … … 535 520 */ 536 521 537 /* --- Unused group 538 @defgroup experimental Experimental Structures and Algorithms 539 This group describes some Experimental structures and algorithms. 540 The stuff here is subject to change. 522 /** 523 @defgroup map_concepts Map Concepts 524 @ingroup concept 525 \brief Skeleton and concept checking classes for maps 526 527 This group describes the skeletons and concept checking classes of maps. 541 528 */ 542 529 -
doc/lgf.dox
r236 r313 79 79 \endcode 80 80 81 The \c \@edges is just a synonym of \c \@arcs. The @arcs section can81 The \c \@edges is just a synonym of \c \@arcs. The \@arcs section can 82 82 also store the edge set of an undirected graph. In such case there is 83 83 a conventional method for store arc maps in the file, if two columns -
doc/mainpage.dox
r209 r314 51 51 If you 52 52 want to see how LEMON works, see 53 some \ref demoprograms "demo programs" !53 some \ref demoprograms "demo programs". 54 54 55 55 If you know what you are looking for then try to find it under the … … 57 57 section. 58 58 59 59 If you are a user of the old (0.x) series of LEMON, please check out the 60 \ref migration "Migration Guide" for the backward incompatibilities. 60 61 */ -
lemon/Makefile.am
r353 r356 13 13 lemon/random.cc 14 14 15 16 lemon_libemon_la_CXXFLAGS = $(GLPK_CFLAGS) $(CPLEX_CFLAGS) $(SOPLEX_CXXFLAGS) 17 lemon_libemon_la_LDFLAGS = $(GLPK_LIBS) $(CPLEX_LIBS) $(SOPLEX_LIBS) 15 #lemon_libemon_la_CXXFLAGS = $(GLPK_CFLAGS) $(CPLEX_CFLAGS) $(SOPLEX_CXXFLAGS) 16 #lemon_libemon_la_LDFLAGS = $(GLPK_LIBS) $(CPLEX_LIBS) $(SOPLEX_LIBS) 18 17 19 18 lemon_HEADERS += \ … … 32 31 lemon/full_graph.h \ 33 32 lemon/graph_to_eps.h \ 33 lemon/grid_graph.h \ 34 34 lemon/kruskal.h \ 35 35 lemon/lgf_reader.h \ … … 38 38 lemon/maps.h \ 39 39 lemon/math.h \ 40 lemon/max_matching.h \ 41 lemon/nauty_reader.h \ 40 42 lemon/path.h \ 41 43 lemon/random.h \ 42 44 lemon/smart_graph.h \ 45 lemon/suurballe.h \ 43 46 lemon/time_measure.h \ 44 47 lemon/tolerance.h \ -
lemon/arg_parser.cc
r214 r311 27 27 } 28 28 29 ArgParser::ArgParser(int argc, const char * *argv) :_argc(argc), _argv(argv),30 29 ArgParser::ArgParser(int argc, const char * const *argv) 30 :_argc(argc), _argv(argv), _command_name(argv[0]) { 31 31 funcOption("-help","Print a short help message",_showHelp,this); 32 32 synonym("help","-help"); 33 33 synonym("h","-help"); 34 35 34 } 36 35 -
lemon/arg_parser.h
r214 r311 17 17 */ 18 18 19 #ifndef LEMON_ARG_PARSER 20 #define LEMON_ARG_PARSER 19 #ifndef LEMON_ARG_PARSER_H 20 #define LEMON_ARG_PARSER_H 21 21 22 22 #include <vector> … … 47 47 48 48 int _argc; 49 const char * *_argv;49 const char * const *_argv; 50 50 51 51 enum OptType { UNKNOWN=0, BOOL=1, STRING=2, DOUBLE=3, INTEGER=4, FUNC=5 }; … … 120 120 121 121 ///Constructor 122 ArgParser(int argc, const char * *argv);122 ArgParser(int argc, const char * const *argv); 123 123 124 124 ~ArgParser(); … … 311 311 ///This is the type of the return value of ArgParser::operator[](). 312 312 ///It automatically converts to \c int, \c double, \c bool or 313 ///\c std::string if the type of the option matches, otherwise it 314 ///throws an exception (i.e. it performs runtime type checking). 313 ///\c std::string if the type of the option matches, which is checked 314 ///with an \ref LEMON_ASSERT "assertion" (i.e. it performs runtime 315 ///type checking). 315 316 class RefType 316 317 { … … 383 384 } 384 385 385 #endif // LEMON_ARG_PARSER 386 #endif // LEMON_ARG_PARSER_H -
lemon/assert.h
r218 r290 28 28 namespace lemon { 29 29 30 inline void assert_fail_log(const char *file, int line, const char *function, 31 const char *message, const char *assertion) 30 inline void assert_fail_abort(const char *file, int line, 31 const char *function, const char* message, 32 const char *assertion) 32 33 { 33 34 std::cerr << file << ":" << line << ": "; … … 38 39 std::cerr << " (assertion '" << assertion << "' failed)"; 39 40 std::cerr << std::endl; 40 }41 42 inline void assert_fail_abort(const char *file, int line,43 const char *function, const char* message,44 const char *assertion)45 {46 assert_fail_log(file, line, function, message, assertion);47 41 std::abort(); 48 42 } … … 64 58 65 59 #undef LEMON_ASSERT 66 #undef LEMON_FIXME67 60 #undef LEMON_DEBUG 68 61 69 #if (defined(LEMON_ASSERT_LOG) ? 1 : 0) + \ 70 (defined(LEMON_ASSERT_ABORT) ? 1 : 0) + \ 62 #if (defined(LEMON_ASSERT_ABORT) ? 1 : 0) + \ 71 63 (defined(LEMON_ASSERT_CUSTOM) ? 1 : 0) > 1 72 64 #error "LEMON assertion system is not set properly" 73 65 #endif 74 66 75 #if ((defined(LEMON_ASSERT_LOG) ? 1 : 0) + \ 76 (defined(LEMON_ASSERT_ABORT) ? 1 : 0) + \ 67 #if ((defined(LEMON_ASSERT_ABORT) ? 1 : 0) + \ 77 68 (defined(LEMON_ASSERT_CUSTOM) ? 1 : 0) == 1 || \ 78 69 defined(LEMON_ENABLE_ASSERTS)) && \ … … 83 74 84 75 85 #if defined LEMON_ASSERT_LOG 86 # undef LEMON_ASSERT_HANDLER 87 # define LEMON_ASSERT_HANDLER ::lemon::assert_fail_log 88 #elif defined LEMON_ASSERT_ABORT 76 #if defined LEMON_ASSERT_ABORT 89 77 # undef LEMON_ASSERT_HANDLER 90 78 # define LEMON_ASSERT_HANDLER ::lemon::assert_fail_abort … … 108 96 # elif defined _MSC_VER 109 97 # define LEMON_FUNCTION_NAME (__FUNCSIG__) 98 # elif __STDC_VERSION__ >= 199901L 99 # define LEMON_FUNCTION_NAME (__func__) 110 100 # else 111 # define LEMON_FUNCTION_NAME ( __func__)101 # define LEMON_FUNCTION_NAME ("<unknown>") 112 102 # endif 113 103 #endif … … 119 109 /// \brief Macro for assertion with customizable message 120 110 /// 121 /// Macro for assertion with customizable message. \param exp An122 /// expression that must be convertible to \c bool. If it is \c123 /// false, then an assertion is raised. The concrete behaviour depends 124 /// on the settings of the assertion system. \param msg A <tt>const125 /// char*</tt> parameter, which can be used to provide information126 /// about the circumstances of the failed assertion.111 /// Macro for assertion with customizable message. 112 /// \param exp An expression that must be convertible to \c bool. If it is \c 113 /// false, then an assertion is raised. The concrete behaviour depends on the 114 /// settings of the assertion system. 115 /// \param msg A <tt>const char*</tt> parameter, which can be used to provide 116 /// information about the circumstances of the failed assertion. 127 117 /// 128 118 /// The assertions are enabled in the default behaviour. … … 138 128 /// The checking is also disabled when the standard macro \c NDEBUG is defined. 139 129 /// 140 /// The LEMON assertion system has a wide range of customization 141 /// properties. As a default behaviour the failed assertion prints a 142 /// short log message to the standard error and aborts the execution. 143 /// 144 /// The following modes can be used in the assertion system: 145 /// 146 /// - \c LEMON_ASSERT_LOG The failed assertion prints a short log 147 /// message to the standard error and continues the execution. 148 /// - \c LEMON_ASSERT_ABORT This mode is similar to the \c 149 /// LEMON_ASSERT_LOG, but it aborts the program. It is the default 150 /// behaviour. 130 /// As a default behaviour the failed assertion prints a short log message to 131 /// the standard error and aborts the execution. 132 /// 133 /// However, the following modes can be used in the assertion system: 134 /// - \c LEMON_ASSERT_ABORT The failed assertion prints a short log message to 135 /// the standard error and aborts the program. It is the default behaviour. 151 136 /// - \c LEMON_ASSERT_CUSTOM The user can define own assertion handler 152 137 /// function. … … 176 161 /// \ingroup exceptions 177 162 /// 178 /// \brief Macro for mark not yet implemented features.179 ///180 /// Macro for mark not yet implemented features and outstanding bugs.181 /// It is close to be the shortcut of the following code:182 /// \code183 /// LEMON_ASSERT(false, msg);184 /// \endcode185 ///186 /// \see LEMON_ASSERT187 # define LEMON_FIXME(msg) \188 (LEMON_ASSERT_HANDLER(__FILE__, __LINE__, LEMON_FUNCTION_NAME, \189 ::lemon::_assert_bits::cstringify(msg), \190 static_cast<const char*>(0)))191 192 /// \ingroup exceptions193 ///194 163 /// \brief Macro for internal assertions 195 164 /// … … 223 192 # ifndef LEMON_ASSERT_HANDLER 224 193 # define LEMON_ASSERT(exp, msg) (static_cast<void>(0)) 225 # define LEMON_FIXME(msg) (static_cast<void>(0))226 194 # define LEMON_DEBUG(exp, msg) (static_cast<void>(0)) 227 195 # else … … 232 200 ::lemon::_assert_bits::cstringify(msg), \ 233 201 #exp), 0))) 234 # define LEMON_FIXME(msg) \235 (LEMON_ASSERT_HANDLER(__FILE__, __LINE__, LEMON_FUNCTION_NAME, \236 ::lemon::_assert_bits::cstringify(msg), \237 static_cast<const char*>(0)))238 239 202 # if LEMON_ENABLE_DEBUG 240 203 # define LEMON_DEBUG(exp, msg) \ -
lemon/bfs.h
r247 r329 29 29 #include <lemon/error.h> 30 30 #include <lemon/maps.h> 31 #include <lemon/path.h> 31 32 32 33 namespace lemon { … … 49 50 ///It must meet the \ref concepts::WriteMap "WriteMap" concept. 50 51 typedef typename Digraph::template NodeMap<typename Digraph::Arc> PredMap; 51 ///Instantiates a \refPredMap.52 53 ///This function instantiates a \ref PredMap.52 ///Instantiates a PredMap. 53 54 ///This function instantiates a PredMap. 54 55 ///\param g is the digraph, to which we would like to define the 55 ///\ref PredMap. 56 ///\todo The digraph alone may be insufficient to initialize 56 ///PredMap. 57 57 static PredMap *createPredMap(const Digraph &g) 58 58 { … … 64 64 ///The type of the map that indicates which nodes are processed. 65 65 ///It must meet the \ref concepts::WriteMap "WriteMap" concept. 66 ///By default it is a NullMap.67 66 typedef NullMap<typename Digraph::Node,bool> ProcessedMap; 68 ///Instantiates a \refProcessedMap.69 70 ///This function instantiates a \refProcessedMap.67 ///Instantiates a ProcessedMap. 68 69 ///This function instantiates a ProcessedMap. 71 70 ///\param g is the digraph, to which 72 ///we would like to define the \refProcessedMap71 ///we would like to define the ProcessedMap 73 72 #ifdef DOXYGEN 74 73 static ProcessedMap *createProcessedMap(const Digraph &g) … … 82 81 ///The type of the map that indicates which nodes are reached. 83 82 84 ///The type of the map that indicates which nodes are reached. 85 ///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept. 83 ///The type of the map that indicates which nodes are reached.///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept. 86 84 typedef typename Digraph::template NodeMap<bool> ReachedMap; 87 ///Instantiates a \refReachedMap.88 89 ///This function instantiates a \refReachedMap.85 ///Instantiates a ReachedMap. 86 87 ///This function instantiates a ReachedMap. 90 88 ///\param g is the digraph, to which 91 ///we would like to define the \refReachedMap.89 ///we would like to define the ReachedMap. 92 90 static ReachedMap *createReachedMap(const Digraph &g) 93 91 { … … 100 98 ///It must meet the \ref concepts::WriteMap "WriteMap" concept. 101 99 typedef typename Digraph::template NodeMap<int> DistMap; 102 ///Instantiates a \refDistMap.103 104 ///This function instantiates a \refDistMap.100 ///Instantiates a DistMap. 101 102 ///This function instantiates a DistMap. 105 103 ///\param g is the digraph, to which we would like to define the 106 /// \refDistMap.104 ///DistMap. 107 105 static DistMap *createDistMap(const Digraph &g) 108 106 { … … 116 114 ///This class provides an efficient implementation of the %BFS algorithm. 117 115 /// 118 ///There is also a \ref bfs() "function 116 ///There is also a \ref bfs() "function-type interface" for the BFS 119 117 ///algorithm, which is convenient in the simplier cases and it can be 120 118 ///used easier. … … 137 135 class Bfs { 138 136 public: 139 ///\ref Exception for uninitialized parameters.140 141 ///This error represents problems in the initialization of the142 ///parameters of the algorithm.143 class UninitializedParameter : public lemon::UninitializedParameter {144 public:145 virtual const char* what() const throw() {146 return "lemon::Bfs::UninitializedParameter";147 }148 };149 137 150 138 ///The type of the digraph the algorithm runs on. … … 196 184 int _curr_dist; 197 185 198 ///Creates the maps if necessary. 199 ///\todo Better memory allocation (instead of new). 186 //Creates the maps if necessary. 200 187 void create_maps() 201 188 { … … 231 218 232 219 template <class T> 233 struct DefPredMapTraits : public Traits {220 struct SetPredMapTraits : public Traits { 234 221 typedef T PredMap; 235 222 static PredMap *createPredMap(const Digraph &) 236 223 { 237 throw UninitializedParameter(); 224 LEMON_ASSERT(false, "PredMap is not initialized"); 225 return 0; // ignore warnings 238 226 } 239 227 }; 240 228 ///\brief \ref named-templ-param "Named parameter" for setting 241 /// \refPredMap type.229 ///PredMap type. 242 230 /// 243 231 ///\ref named-templ-param "Named parameter" for setting 244 /// \refPredMap type.232 ///PredMap type. 245 233 template <class T> 246 struct DefPredMap : public Bfs< Digraph, DefPredMapTraits<T> > {247 typedef Bfs< Digraph, DefPredMapTraits<T> > Create;234 struct SetPredMap : public Bfs< Digraph, SetPredMapTraits<T> > { 235 typedef Bfs< Digraph, SetPredMapTraits<T> > Create; 248 236 }; 249 237 250 238 template <class T> 251 struct DefDistMapTraits : public Traits {239 struct SetDistMapTraits : public Traits { 252 240 typedef T DistMap; 253 241 static DistMap *createDistMap(const Digraph &) 254 242 { 255 throw UninitializedParameter(); 243 LEMON_ASSERT(false, "DistMap is not initialized"); 244 return 0; // ignore warnings 256 245 } 257 246 }; 258 247 ///\brief \ref named-templ-param "Named parameter" for setting 259 /// \refDistMap type.248 ///DistMap type. 260 249 /// 261 250 ///\ref named-templ-param "Named parameter" for setting 262 /// \refDistMap type.251 ///DistMap type. 263 252 template <class T> 264 struct DefDistMap : public Bfs< Digraph, DefDistMapTraits<T> > {265 typedef Bfs< Digraph, DefDistMapTraits<T> > Create;253 struct SetDistMap : public Bfs< Digraph, SetDistMapTraits<T> > { 254 typedef Bfs< Digraph, SetDistMapTraits<T> > Create; 266 255 }; 267 256 268 257 template <class T> 269 struct DefReachedMapTraits : public Traits {258 struct SetReachedMapTraits : public Traits { 270 259 typedef T ReachedMap; 271 260 static ReachedMap *createReachedMap(const Digraph &) 272 261 { 273 throw UninitializedParameter(); 262 LEMON_ASSERT(false, "ReachedMap is not initialized"); 263 return 0; // ignore warnings 274 264 } 275 265 }; 276 266 ///\brief \ref named-templ-param "Named parameter" for setting 277 /// \refReachedMap type.267 ///ReachedMap type. 278 268 /// 279 269 ///\ref named-templ-param "Named parameter" for setting 280 /// \refReachedMap type.270 ///ReachedMap type. 281 271 template <class T> 282 struct DefReachedMap : public Bfs< Digraph, DefReachedMapTraits<T> > {283 typedef Bfs< Digraph, DefReachedMapTraits<T> > Create;272 struct SetReachedMap : public Bfs< Digraph, SetReachedMapTraits<T> > { 273 typedef Bfs< Digraph, SetReachedMapTraits<T> > Create; 284 274 }; 285 275 286 276 template <class T> 287 struct DefProcessedMapTraits : public Traits {277 struct SetProcessedMapTraits : public Traits { 288 278 typedef T ProcessedMap; 289 279 static ProcessedMap *createProcessedMap(const Digraph &) 290 280 { 291 throw UninitializedParameter(); 281 LEMON_ASSERT(false, "ProcessedMap is not initialized"); 282 return 0; // ignore warnings 292 283 } 293 284 }; 294 285 ///\brief \ref named-templ-param "Named parameter" for setting 295 /// \refProcessedMap type.286 ///ProcessedMap type. 296 287 /// 297 288 ///\ref named-templ-param "Named parameter" for setting 298 /// \refProcessedMap type.289 ///ProcessedMap type. 299 290 template <class T> 300 struct DefProcessedMap : public Bfs< Digraph, DefProcessedMapTraits<T> > {301 typedef Bfs< Digraph, DefProcessedMapTraits<T> > Create;291 struct SetProcessedMap : public Bfs< Digraph, SetProcessedMapTraits<T> > { 292 typedef Bfs< Digraph, SetProcessedMapTraits<T> > Create; 302 293 }; 303 294 304 struct DefDigraphProcessedMapTraits : public Traits {295 struct SetStandardProcessedMapTraits : public Traits { 305 296 typedef typename Digraph::template NodeMap<bool> ProcessedMap; 306 297 static ProcessedMap *createProcessedMap(const Digraph &g) 307 298 { 308 299 return new ProcessedMap(g); 300 return 0; // ignore warnings 309 301 } 310 302 }; 311 303 ///\brief \ref named-templ-param "Named parameter" for setting 312 /// \refProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>.304 ///ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>. 313 305 /// 314 306 ///\ref named-templ-param "Named parameter" for setting 315 /// \refProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>.307 ///ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>. 316 308 ///If you don't set it explicitly, it will be automatically allocated. 317 template <class T> 318 struct DefProcessedMapToBeDefaultMap : 319 public Bfs< Digraph, DefDigraphProcessedMapTraits> { 320 typedef Bfs< Digraph, DefDigraphProcessedMapTraits> Create; 309 struct SetStandardProcessedMap : 310 public Bfs< Digraph, SetStandardProcessedMapTraits > { 311 typedef Bfs< Digraph, SetStandardProcessedMapTraits > Create; 321 312 }; 322 313 … … 608 599 /// 609 600 ///This method runs the %BFS algorithm from the root node(s) 610 ///in order to compute the shortest path to \c dest.601 ///in order to compute the shortest path to \c t. 611 602 /// 612 603 ///The algorithm computes 613 ///- the shortest path to \c dest,614 ///- the distance of \c dest from the root(s).604 ///- the shortest path to \c t, 605 ///- the distance of \c t from the root(s). 615 606 /// 616 607 ///\pre init() must be called and at least one root node should be … … 624 615 /// } 625 616 ///\endcode 626 void start(Node dest)617 void start(Node t) 627 618 { 628 619 bool reach = false; 629 while ( !emptyQueue() && !reach ) processNextNode( dest, reach);620 while ( !emptyQueue() && !reach ) processNextNode(t, reach); 630 621 } 631 622 … … 665 656 } 666 657 667 ///Runs the algorithm from the given node.658 ///Runs the algorithm from the given source node. 668 659 669 660 ///This method runs the %BFS algorithm from node \c s … … 689 680 690 681 ///This method runs the %BFS algorithm from node \c s 691 ///in order to compute the shortest path to \c t.692 /// 693 /// \return The length of the shortest <tt>s</tt>--<tt>t</tt> path,694 /// if \c t is reachable form \c s, \c 0 otherwise.682 ///in order to compute the shortest path to node \c t 683 ///(it stops searching when \c t is processed). 684 /// 685 ///\return \c true if \c t is reachable form \c s. 695 686 /// 696 687 ///\note Apart from the return value, <tt>b.run(s,t)</tt> is just a … … 701 692 /// b.start(t); 702 693 ///\endcode 703 intrun(Node s,Node t) {694 bool run(Node s,Node t) { 704 695 init(); 705 696 addSource(s); 706 697 start(t); 707 return reached(t) ? _curr_dist : 0;698 return reached(t); 708 699 } 709 700 … … 843 834 ///arcs of the shortest paths. 844 835 ///It must meet the \ref concepts::WriteMap "WriteMap" concept. 845 typedef NullMap<typename Digraph::Node,typename Digraph::Arc> PredMap;846 ///Instantiates a \refPredMap.847 848 ///This function instantiates a \refPredMap.836 typedef typename Digraph::template NodeMap<typename Digraph::Arc> PredMap; 837 ///Instantiates a PredMap. 838 839 ///This function instantiates a PredMap. 849 840 ///\param g is the digraph, to which we would like to define the 850 ///\ref PredMap. 851 ///\todo The digraph alone may be insufficient to initialize 852 #ifdef DOXYGEN 841 ///PredMap. 853 842 static PredMap *createPredMap(const Digraph &g) 854 #else 855 static PredMap *createPredMap(const Digraph &) 856 #endif 857 { 858 return new PredMap(); 843 { 844 return new PredMap(g); 859 845 } 860 846 … … 863 849 ///The type of the map that indicates which nodes are processed. 864 850 ///It must meet the \ref concepts::WriteMap "WriteMap" concept. 851 ///By default it is a NullMap. 865 852 typedef NullMap<typename Digraph::Node,bool> ProcessedMap; 866 ///Instantiates a \refProcessedMap.867 868 ///This function instantiates a \refProcessedMap.853 ///Instantiates a ProcessedMap. 854 855 ///This function instantiates a ProcessedMap. 869 856 ///\param g is the digraph, to which 870 ///we would like to define the \refProcessedMap.857 ///we would like to define the ProcessedMap. 871 858 #ifdef DOXYGEN 872 859 static ProcessedMap *createProcessedMap(const Digraph &g) … … 883 870 ///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept. 884 871 typedef typename Digraph::template NodeMap<bool> ReachedMap; 885 ///Instantiates a \refReachedMap.886 887 ///This function instantiates a \refReachedMap.872 ///Instantiates a ReachedMap. 873 874 ///This function instantiates a ReachedMap. 888 875 ///\param g is the digraph, to which 889 ///we would like to define the \refReachedMap.876 ///we would like to define the ReachedMap. 890 877 static ReachedMap *createReachedMap(const Digraph &g) 891 878 { … … 897 884 ///The type of the map that stores the distances of the nodes. 898 885 ///It must meet the \ref concepts::WriteMap "WriteMap" concept. 899 /// 900 typedef NullMap<typename Digraph::Node,int> DistMap; 901 ///Instantiates a \ref DistMap. 902 903 ///This function instantiates a \ref DistMap. 886 typedef typename Digraph::template NodeMap<int> DistMap; 887 ///Instantiates a DistMap. 888 889 ///This function instantiates a DistMap. 904 890 ///\param g is the digraph, to which we would like to define 905 ///the \ref DistMap 906 #ifdef DOXYGEN 891 ///the DistMap 907 892 static DistMap *createDistMap(const Digraph &g) 908 #else 909 static DistMap *createDistMap(const Digraph &) 910 #endif 911 { 912 return new DistMap(); 913 } 893 { 894 return new DistMap(g); 895 } 896 897 ///The type of the shortest paths. 898 899 ///The type of the shortest paths. 900 ///It must meet the \ref concepts::Path "Path" concept. 901 typedef lemon::Path<Digraph> Path; 914 902 }; 915 903 916 /// Default traits class used by \refBfsWizard904 /// Default traits class used by BfsWizard 917 905 918 906 /// To make it easier to use Bfs algorithm … … 941 929 //Pointer to the map of distances. 942 930 void *_dist; 943 //Pointer to the source node. 944 Node _source; 931 //Pointer to the shortest path to the target node. 932 void *_path; 933 //Pointer to the distance of the target node. 934 int *_di; 945 935 946 936 public: … … 948 938 949 939 /// This constructor does not require parameters, therefore it initiates 950 /// all of the attributes to default values (0, INVALID).940 /// all of the attributes to \c 0. 951 941 BfsWizardBase() : _g(0), _reached(0), _processed(0), _pred(0), 952 _dist(0), _ source(INVALID) {}942 _dist(0), _path(0), _di(0) {} 953 943 954 944 /// Constructor. 955 945 956 /// This constructor requires some parameters, 957 /// listed in the parameters list. 958 /// Others are initiated to 0. 946 /// This constructor requires one parameter, 947 /// others are initiated to \c 0. 959 948 /// \param g The digraph the algorithm runs on. 960 /// \param s The source node. 961 BfsWizardBase(const GR &g, Node s=INVALID) : 949 BfsWizardBase(const GR &g) : 962 950 _g(reinterpret_cast<void*>(const_cast<GR*>(&g))), 963 _reached(0), _processed(0), _pred(0), _dist(0), _source(s) {}951 _reached(0), _processed(0), _pred(0), _dist(0), _path(0), _di(0) {} 964 952 965 953 }; 966 954 967 /// Auxiliary class for the function type interface of BFS algorithm. 968 969 /// This auxiliary class is created to implement the function type 970 /// interface of \ref Bfs algorithm. It uses the functions and features 971 /// of the plain \ref Bfs, but it is much simpler to use it. 972 /// It should only be used through the \ref bfs() function, which makes 973 /// it easier to use the algorithm. 955 /// Auxiliary class for the function-type interface of BFS algorithm. 956 957 /// This auxiliary class is created to implement the 958 /// \ref bfs() "function-type interface" of \ref Bfs algorithm. 959 /// It does not have own \ref run() method, it uses the functions 960 /// and features of the plain \ref Bfs. 974 961 /// 975 /// Simplicity means that the way to change the types defined 976 /// in the traits class is based on functions that returns the new class 977 /// and not on templatable built-in classes. 978 /// When using the plain \ref Bfs 979 /// the new class with the modified type comes from 980 /// the original class by using the :: 981 /// operator. In the case of \ref BfsWizard only 982 /// a function have to be called, and it will 983 /// return the needed class. 984 /// 985 /// It does not have own \ref run() method. When its \ref run() method 986 /// is called, it initiates a plain \ref Bfs object, and calls the 987 /// \ref Bfs::run() method of it. 962 /// This class should only be used through the \ref bfs() function, 963 /// which makes it easier to use the algorithm. 988 964 template<class TR> 989 965 class BfsWizard : public TR … … 1008 984 ///\brief The type of the map that indicates which nodes are processed. 1009 985 typedef typename TR::ProcessedMap ProcessedMap; 986 ///The type of the shortest paths 987 typedef typename TR::Path Path; 1010 988 1011 989 public: … … 1018 996 /// Constructor that requires parameters. 1019 997 /// These parameters will be the default values for the traits class. 1020 BfsWizard(const Digraph &g, Node s=INVALID) : 1021 TR(g,s) {} 998 /// \param g The digraph the algorithm runs on. 999 BfsWizard(const Digraph &g) : 1000 TR(g) {} 1022 1001 1023 1002 ///Copy constructor … … 1026 1005 ~BfsWizard() {} 1027 1006 1028 ///Runs BFS algorithm from a source node. 1029 1030 ///Runs BFS algorithm from a source node. 1031 ///The node can be given with the \ref source() function. 1007 ///Runs BFS algorithm from the given source node. 1008 1009 ///This method runs BFS algorithm from node \c s 1010 ///in order to compute the shortest path to each node. 1011 void run(Node s) 1012 { 1013 Bfs<Digraph,TR> alg(*reinterpret_cast<const Digraph*>(Base::_g)); 1014 if (Base::_pred) 1015 alg.predMap(*reinterpret_cast<PredMap*>(Base::_pred)); 1016 if (Base::_dist) 1017 alg.distMap(*reinterpret_cast<DistMap*>(Base::_dist)); 1018 if (Base::_reached) 1019 alg.reachedMap(*reinterpret_cast<ReachedMap*>(Base::_reached)); 1020 if (Base::_processed) 1021 alg.processedMap(*reinterpret_cast<ProcessedMap*>(Base::_processed)); 1022 if (s!=INVALID) 1023 alg.run(s); 1024 else 1025 alg.run(); 1026 } 1027 1028 ///Finds the shortest path between \c s and \c t. 1029 1030 ///This method runs BFS algorithm from node \c s 1031 ///in order to compute the shortest path to node \c t 1032 ///(it stops searching when \c t is processed). 1033 /// 1034 ///\return \c true if \c t is reachable form \c s. 1035 bool run(Node s, Node t) 1036 { 1037 Bfs<Digraph,TR> alg(*reinterpret_cast<const Digraph*>(Base::_g)); 1038 if (Base::_pred) 1039 alg.predMap(*reinterpret_cast<PredMap*>(Base::_pred)); 1040 if (Base::_dist) 1041 alg.distMap(*reinterpret_cast<DistMap*>(Base::_dist)); 1042 if (Base::_reached) 1043 alg.reachedMap(*reinterpret_cast<ReachedMap*>(Base::_reached)); 1044 if (Base::_processed) 1045 alg.processedMap(*reinterpret_cast<ProcessedMap*>(Base::_processed)); 1046 alg.run(s,t); 1047 if (Base::_path) 1048 *reinterpret_cast<Path*>(Base::_path) = alg.path(t); 1049 if (Base::_di) 1050 *Base::_di = alg.dist(t); 1051 return alg.reached(t); 1052 } 1053 1054 ///Runs BFS algorithm to visit all nodes in the digraph. 1055 1056 ///This method runs BFS algorithm in order to compute 1057 ///the shortest path to each node. 1032 1058 void run() 1033 1059 { 1034 if(Base::_source==INVALID) throw UninitializedParameter(); 1035 Bfs<Digraph,TR> alg(*reinterpret_cast<const Digraph*>(Base::_g)); 1036 if(Base::_reached) 1037 alg.reachedMap(*reinterpret_cast<ReachedMap*>(Base::_reached)); 1038 if(Base::_processed) 1039 alg.processedMap(*reinterpret_cast<ProcessedMap*>(Base::_processed)); 1040 if(Base::_pred) 1041 alg.predMap(*reinterpret_cast<PredMap*>(Base::_pred)); 1042 if(Base::_dist) 1043 alg.distMap(*reinterpret_cast<DistMap*>(Base::_dist)); 1044 alg.run(Base::_source); 1045 } 1046 1047 ///Runs BFS algorithm from the given node. 1048 1049 ///Runs BFS algorithm from the given node. 1050 ///\param s is the given source. 1051 void run(Node s) 1052 { 1053 Base::_source=s; 1054 run(); 1055 } 1056 1057 /// Sets the source node, from which the Bfs algorithm runs. 1058 1059 /// Sets the source node, from which the Bfs algorithm runs. 1060 /// \param s is the source node. 1061 BfsWizard<TR> &source(Node s) 1062 { 1063 Base::_source=s; 1064 return *this; 1060 run(INVALID); 1065 1061 } 1066 1062 1067 1063 template<class T> 1068 struct DefPredMapBase : public Base {1064 struct SetPredMapBase : public Base { 1069 1065 typedef T PredMap; 1070 1066 static PredMap *createPredMap(const Digraph &) { return 0; }; 1071 DefPredMapBase(const TR &b) : TR(b) {}1067 SetPredMapBase(const TR &b) : TR(b) {} 1072 1068 }; 1073 ///\brief \ref named- templ-param "Named parameter"1074 ///for setting \refPredMap object.1075 /// 1076 /// \ref named-templ-param "Named parameter"1077 ///for setting \refPredMap object.1069 ///\brief \ref named-func-param "Named parameter" 1070 ///for setting PredMap object. 1071 /// 1072 ///\ref named-func-param "Named parameter" 1073 ///for setting PredMap object. 1078 1074 template<class T> 1079 BfsWizard< DefPredMapBase<T> > predMap(const T &t)1075 BfsWizard<SetPredMapBase<T> > predMap(const T &t) 1080 1076 { 1081 1077 Base::_pred=reinterpret_cast<void*>(const_cast<T*>(&t)); 1082 return BfsWizard< DefPredMapBase<T> >(*this);1078 return BfsWizard<SetPredMapBase<T> >(*this); 1083 1079 } 1084 1080 1085 1081 template<class T> 1086 struct DefReachedMapBase : public Base {1082 struct SetReachedMapBase : public Base { 1087 1083 typedef T ReachedMap; 1088 1084 static ReachedMap *createReachedMap(const Digraph &) { return 0; }; 1089 DefReachedMapBase(const TR &b) : TR(b) {}1085 SetReachedMapBase(const TR &b) : TR(b) {} 1090 1086 }; 1091 ///\brief \ref named- templ-param "Named parameter"1092 ///for setting \refReachedMap object.1093 /// 1094 /// \ref named- templ-param "Named parameter"1095 ///for setting \refReachedMap object.1087 ///\brief \ref named-func-param "Named parameter" 1088 ///for setting ReachedMap object. 1089 /// 1090 /// \ref named-func-param "Named parameter" 1091 ///for setting ReachedMap object. 1096 1092 template<class T> 1097 BfsWizard< DefReachedMapBase<T> > reachedMap(const T &t)1093 BfsWizard<SetReachedMapBase<T> > reachedMap(const T &t) 1098 1094 { 1099 1095 Base::_reached=reinterpret_cast<void*>(const_cast<T*>(&t)); 1100 return BfsWizard< DefReachedMapBase<T> >(*this);1096 return BfsWizard<SetReachedMapBase<T> >(*this); 1101 1097 } 1102 1098 1103 1099 template<class T> 1104 struct DefProcessedMapBase : public Base { 1100 struct SetDistMapBase : public Base { 1101 typedef T DistMap; 1102 static DistMap *createDistMap(const Digraph &) { return 0; }; 1103 SetDistMapBase(const TR &b) : TR(b) {} 1104 }; 1105 ///\brief \ref named-func-param "Named parameter" 1106 ///for setting DistMap object. 1107 /// 1108 /// \ref named-func-param "Named parameter" 1109 ///for setting DistMap object. 1110 template<class T> 1111 BfsWizard<SetDistMapBase<T> > distMap(const T &t) 1112 { 1113 Base::_dist=reinterpret_cast<void*>(const_cast<T*>(&t)); 1114 return BfsWizard<SetDistMapBase<T> >(*this); 1115 } 1116 1117 template<class T> 1118 struct SetProcessedMapBase : public Base { 1105 1119 typedef T ProcessedMap; 1106 1120 static ProcessedMap *createProcessedMap(const Digraph &) { return 0; }; 1107 DefProcessedMapBase(const TR &b) : TR(b) {}1121 SetProcessedMapBase(const TR &b) : TR(b) {} 1108 1122 }; 1109 ///\brief \ref named- templ-param "Named parameter"1110 ///for setting \refProcessedMap object.1111 /// 1112 /// \ref named- templ-param "Named parameter"1113 ///for setting \refProcessedMap object.1123 ///\brief \ref named-func-param "Named parameter" 1124 ///for setting ProcessedMap object. 1125 /// 1126 /// \ref named-func-param "Named parameter" 1127 ///for setting ProcessedMap object. 1114 1128 template<class T> 1115 BfsWizard< DefProcessedMapBase<T> > processedMap(const T &t)1129 BfsWizard<SetProcessedMapBase<T> > processedMap(const T &t) 1116 1130 { 1117 1131 Base::_processed=reinterpret_cast<void*>(const_cast<T*>(&t)); 1118 return BfsWizard< DefProcessedMapBase<T> >(*this);1132 return BfsWizard<SetProcessedMapBase<T> >(*this); 1119 1133 } 1120 1134 1121 1135 template<class T> 1122 struct DefDistMapBase : public Base { 1123 typedef T DistMap; 1124 static DistMap *createDistMap(const Digraph &) { return 0; }; 1125 DefDistMapBase(const TR &b) : TR(b) {} 1136 struct SetPathBase : public Base { 1137 typedef T Path; 1138 SetPathBase(const TR &b) : TR(b) {} 1126 1139 }; 1127 ///\brief \ref named- templ-param "Named parameter"1128 ///for setting \ref DistMap object.1129 /// 1130 /// \ref named-templ-param "Named parameter"1131 ///for setting \ref DistMap object.1140 ///\brief \ref named-func-param "Named parameter" 1141 ///for getting the shortest path to the target node. 1142 /// 1143 ///\ref named-func-param "Named parameter" 1144 ///for getting the shortest path to the target node. 1132 1145 template<class T> 1133 BfsWizard<DefDistMapBase<T> > distMap(const T &t) 1134 { 1135 Base::_dist=reinterpret_cast<void*>(const_cast<T*>(&t)); 1136 return BfsWizard<DefDistMapBase<T> >(*this); 1146 BfsWizard<SetPathBase<T> > path(const T &t) 1147 { 1148 Base::_path=reinterpret_cast<void*>(const_cast<T*>(&t)); 1149 return BfsWizard<SetPathBase<T> >(*this); 1150 } 1151 1152 ///\brief \ref named-func-param "Named parameter" 1153 ///for getting the distance of the target node. 1154 /// 1155 ///\ref named-func-param "Named parameter" 1156 ///for getting the distance of the target node. 1157 BfsWizard dist(const int &d) 1158 { 1159 Base::_di=const_cast<int*>(&d); 1160 return *this; 1137 1161 } 1138 1162 1139 1163 }; 1140 1164 1141 ///Function type interface for Bfsalgorithm.1165 ///Function-type interface for BFS algorithm. 1142 1166 1143 1167 /// \ingroup search 1144 ///Function type interface for Bfsalgorithm.1168 ///Function-type interface for BFS algorithm. 1145 1169 /// 1146 ///This function also has several 1147 ///\ref named-templ-func-param "named parameters", 1170 ///This function also has several \ref named-func-param "named parameters", 1148 1171 ///they are declared as the members of class \ref BfsWizard. 1149 ///The following 1150 ///example shows how to use these parameters. 1172 ///The following examples show how to use these parameters. 1151 1173 ///\code 1152 /// bfs(g,source).predMap(preds).run(); 1174 /// // Compute shortest path from node s to each node 1175 /// bfs(g).predMap(preds).distMap(dists).run(s); 1176 /// 1177 /// // Compute shortest path from s to t 1178 /// bool reached = bfs(g).path(p).dist(d).run(s,t); 1153 1179 ///\endcode 1154 1180 ///\warning Don't forget to put the \ref BfsWizard::run() "run()" … … 1158 1184 template<class GR> 1159 1185 BfsWizard<BfsWizardBase<GR> > 1160 bfs(const GR & g,typename GR::Node s=INVALID)1186 bfs(const GR &digraph) 1161 1187 { 1162 return BfsWizard<BfsWizardBase<GR> >( g,s);1188 return BfsWizard<BfsWizardBase<GR> >(digraph); 1163 1189 } 1164 1190 … … 1241 1267 typedef typename Digraph::template NodeMap<bool> ReachedMap; 1242 1268 1243 /// \brief Instantiates a \refReachedMap.1244 /// 1245 /// This function instantiates a \refReachedMap.1269 /// \brief Instantiates a ReachedMap. 1270 /// 1271 /// This function instantiates a ReachedMap. 1246 1272 /// \param digraph is the digraph, to which 1247 /// we would like to define the \refReachedMap.1273 /// we would like to define the ReachedMap. 1248 1274 static ReachedMap *createReachedMap(const Digraph &digraph) { 1249 1275 return new ReachedMap(digraph); … … 1262 1288 /// class. It works with callback mechanism, the BfsVisit object calls 1263 1289 /// the member functions of the \c Visitor class on every BFS event. 1290 /// 1291 /// This interface of the BFS algorithm should be used in special cases 1292 /// when extra actions have to be performed in connection with certain 1293 /// events of the BFS algorithm. Otherwise consider to use Bfs or bfs() 1294 /// instead. 1264 1295 /// 1265 1296 /// \tparam _Digraph The type of the digraph the algorithm runs on. … … 1281 1312 template <typename _Digraph = ListDigraph, 1282 1313 typename _Visitor = BfsVisitor<_Digraph>, 1283 typename _Traits = Bfs DefaultTraits<_Digraph> >1314 typename _Traits = BfsVisitDefaultTraits<_Digraph> > 1284 1315 #endif 1285 1316 class BfsVisit { 1286 1317 public: 1287 1288 /// \brief \ref Exception for uninitialized parameters.1289 ///1290 /// This error represents problems in the initialization1291 /// of the parameters of the algorithm.1292 class UninitializedParameter : public lemon::UninitializedParameter {1293 public:1294 virtual const char* what() const throw()1295 {1296 return "lemon::BfsVisit::UninitializedParameter";1297 }1298 };1299 1318 1300 1319 ///The traits class. … … 1329 1348 int _list_front, _list_back; 1330 1349 1331 ///Creates the maps if necessary. 1332 ///\todo Better memory allocation (instead of new). 1350 //Creates the maps if necessary. 1333 1351 void create_maps() { 1334 1352 if(!_reached) { … … 1350 1368 ///@{ 1351 1369 template <class T> 1352 struct DefReachedMapTraits : public Traits {1370 struct SetReachedMapTraits : public Traits { 1353 1371 typedef T ReachedMap; 1354 1372 static ReachedMap *createReachedMap(const Digraph &digraph) { 1355 throw UninitializedParameter(); 1373 LEMON_ASSERT(false, "ReachedMap is not initialized"); 1374 return 0; // ignore warnings 1356 1375 } 1357 1376 }; … … 1361 1380 /// \ref named-templ-param "Named parameter" for setting ReachedMap type. 1362 1381 template <class T> 1363 struct DefReachedMap : public BfsVisit< Digraph, Visitor,1364 DefReachedMapTraits<T> > {1365 typedef BfsVisit< Digraph, Visitor, DefReachedMapTraits<T> > Create;1382 struct SetReachedMap : public BfsVisit< Digraph, Visitor, 1383 SetReachedMapTraits<T> > { 1384 typedef BfsVisit< Digraph, Visitor, SetReachedMapTraits<T> > Create; 1366 1385 }; 1367 1386 ///@} … … 1580 1599 /// 1581 1600 /// This method runs the %BFS algorithm from the root node(s) 1582 /// in order to compute the shortest path to \c dest.1601 /// in order to compute the shortest path to \c t. 1583 1602 /// 1584 1603 /// The algorithm computes 1585 /// - the shortest path to \c dest,1586 /// - the distance of \c dest from the root(s).1604 /// - the shortest path to \c t, 1605 /// - the distance of \c t from the root(s). 1587 1606 /// 1588 1607 /// \pre init() must be called and at least one root node should be … … 1596 1615 /// } 1597 1616 /// \endcode 1598 void start(Node dest) {1617 void start(Node t) { 1599 1618 bool reach = false; 1600 while ( !emptyQueue() && !reach ) processNextNode( dest, reach);1619 while ( !emptyQueue() && !reach ) processNextNode(t, reach); 1601 1620 } 1602 1621 … … 1636 1655 } 1637 1656 1638 /// \brief Runs the algorithm from the given node.1657 /// \brief Runs the algorithm from the given source node. 1639 1658 /// 1640 1659 /// This method runs the %BFS algorithm from node \c s … … 1655 1674 addSource(s); 1656 1675 start(); 1676 } 1677 1678 /// \brief Finds the shortest path between \c s and \c t. 1679 /// 1680 /// This method runs the %BFS algorithm from node \c s 1681 /// in order to compute the shortest path to node \c t 1682 /// (it stops searching when \c t is processed). 1683 /// 1684 /// \return \c true if \c t is reachable form \c s. 1685 /// 1686 /// \note Apart from the return value, <tt>b.run(s,t)</tt> is just a 1687 /// shortcut of the following code. 1688 ///\code 1689 /// b.init(); 1690 /// b.addSource(s); 1691 /// b.start(t); 1692 ///\endcode 1693 bool run(Node s,Node t) { 1694 init(); 1695 addSource(s); 1696 start(t); 1697 return reached(t); 1657 1698 } 1658 1699 -
lemon/bits/alteration_notifier.h
r236 r314 25 25 #include <lemon/core.h> 26 26 27 // /\ingroup graphbits28 // /\file29 // /\brief Observer notifier for graph alteration observers.27 //\ingroup graphbits 28 //\file 29 //\brief Observer notifier for graph alteration observers. 30 30 31 31 namespace lemon { 32 32 33 /// \ingroup graphbits 34 /// 35 /// \brief Notifier class to notify observes about alterations in 36 /// a container. 37 /// 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 44 /// nodes and edges in the graph. LEMON would like to handle easily 45 /// that the node and edge maps should contain values for all nodes or 46 /// edges. If we want to check on every indicing if the map contains 47 /// the current indicing key that cause a drawback in the performance 48 /// in the library. We use another solution we notify all maps about 49 /// an alteration in the graph, which cause only drawback on the 50 /// alteration of the graph. 51 /// 52 /// This class provides an interface to the container. The \e first() and \e 53 /// next() member functions make possible to iterate on the keys of the 54 /// container. The \e id() function returns an integer id for each key. 55 /// The \e maxId() function gives back an upper bound of the ids. 56 /// 57 /// 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 63 /// 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 /// them from the container, on the other way on item addition we should 66 /// first extend the container and just after that signal the alteration. 67 /// 68 /// The alteration can be observed with a class inherited from the 69 /// \e ObserverBase nested class. The signals can be handled with 70 /// overriding the virtual functions defined in the base class. The 71 /// observer base can be attached to the notifier with the 72 /// \e attach() member and can be detached with detach() function. The 73 /// alteration handlers should not call any function which signals 74 /// an other alteration in the same notifier and should not 75 /// detach any observer from the notifier. 76 /// 77 /// Alteration observers try to be exception safe. If an \e add() or 78 /// a \e clear() function throws an exception then the remaining 79 /// 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 83 /// \ref AlterationObserver::ImmediateDetach ImmediateDetach 84 /// exception which detach the observer from the notifier. 85 /// 86 /// There are some place when the alteration observing is not completly 87 /// reliable. If we want to carry out the node degree in the graph 88 /// as in the \ref InDegMap and we use the reverseEdge that cause 89 /// unreliable functionality. Because the alteration observing signals 90 /// only erasing and adding but not the reversing it will stores bad 91 /// degrees. The sub graph adaptors cannot signal the alterations because 92 /// just a setting in the filter map can modify the graph and this cannot 93 /// be watched in any way. 94 /// 95 /// \param _Container The container which is observed. 96 /// \param _Item The item type which is obserbved. 33 // \ingroup graphbits 34 // 35 // \brief Notifier class to notify observes about alterations in 36 // a container. 37 // 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 44 // nodes and edges in the graph. LEMON would like to handle easily 45 // that the node and edge maps should contain values for all nodes or 46 // edges. If we want to check on every indicing if the map contains 47 // the current indicing key that cause a drawback in the performance 48 // in the library. We use another solution we notify all maps about 49 // an alteration in the graph, which cause only drawback on the 50 // alteration of the graph. 51 // 52 // This class provides an interface to the container. The \e first() and \e 53 // next() member functions make possible to iterate on the keys of the 54 // container. The \e id() function returns an integer id for each key. 55 // The \e maxId() function gives back an upper bound of the ids. 56 // 57 // 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 63 // 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 // them from the container, on the other way on item addition we should 66 // first extend the container and just after that signal the alteration. 67 // 68 // The alteration can be observed with a class inherited from the 69 // \e ObserverBase nested class. The signals can be handled with 70 // overriding the virtual functions defined in the base class. The 71 // observer base can be attached to the notifier with the 72 // \e attach() member and can be detached with detach() function. The 73 // alteration handlers should not call any function which signals 74 // an other alteration in the same notifier and should not 75 // detach any observer from the notifier. 76 // 77 // Alteration observers try to be exception safe. If an \e add() or 78 // a \e clear() function throws an exception then the remaining 79 // 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 86 // 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 // 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. 93 // 94 // \param _Container The container which is observed. 95 // \param _Item The item type which is obserbved. 97 96 98 97 template <typename _Container, typename _Item> … … 105 104 typedef _Item Item; 106 105 107 // /\brief Exception which can be called from \e clear() and108 // /\e erase().109 // /110 // /From the \e clear() and \e erase() function only this111 // /exception is allowed to throw. The exception immediatly112 // /detaches the current observer from the notifier. Because the113 // /\e clear() and \e erase() should not throw other exceptions114 // /it can be used to invalidate the observer.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 110 // exception is allowed to throw. The exception immediatly 111 // detaches the current observer from the notifier. Because the 112 // \e clear() and \e erase() should not throw other exceptions 113 // it can be used to invalidate the observer. 115 114 struct ImmediateDetach {}; 116 115 117 /// \brief ObserverBase is the base class for the observers. 118 /// 119 /// ObserverBase is the abstract base class for the observers. 120 /// It will be notified about an item was inserted into or 121 /// erased from the graph. 122 /// 123 /// The observer interface contains some pure virtual functions 124 /// to override. The add() and erase() functions are 125 /// to notify the oberver when one item is added or 126 /// erased. 127 /// 128 /// The build() and clear() members are to notify the observer 129 /// about the container is built from an empty container or 130 /// is cleared to an empty container. 131 116 // \brief ObserverBase is the base class for the observers. 117 // 118 // ObserverBase is the abstract base class for the observers. 119 // It will be notified about an item was inserted into or 120 // erased from the graph. 121 // 122 // The observer interface contains some pure virtual functions 123 // to override. The add() and erase() functions are 124 // to notify the oberver when one item is added or 125 // erased. 126 // 127 // The build() and clear() members are to notify the observer 128 // about the container is built from an empty container or 129 // is cleared to an empty container. 132 130 class ObserverBase { 133 131 protected: … … 136 134 friend class AlterationNotifier; 137 135 138 /// \brief Default constructor. 139 /// 140 /// Default constructor for ObserverBase. 141 /// 136 // \brief Default constructor. 137 // 138 // Default constructor for ObserverBase. 142 139 ObserverBase() : _notifier(0) {} 143 140 144 // /\brief Constructor which attach the observer into notifier.145 // /146 // /Constructor which attach the observer into notifier.141 // \brief Constructor which attach the observer into notifier. 142 // 143 // Constructor which attach the observer into notifier. 147 144 ObserverBase(AlterationNotifier& nf) { 148 145 attach(nf); 149 146 } 150 147 151 // /\brief Constructor which attach the obserever to the same notifier.152 // /153 // /Constructor which attach the obserever to the same notifier as154 // /the other observer is attached to.148 // \brief Constructor which attach the obserever to the same notifier. 149 // 150 // Constructor which attach the obserever to the same notifier as 151 // the other observer is attached to. 155 152 ObserverBase(const ObserverBase& copy) { 156 153 if (copy.attached()) { … … 159 156 } 160 157 161 // /\brief Destructor158 // \brief Destructor 162 159 virtual ~ObserverBase() { 163 160 if (attached()) { … … 166 163 } 167 164 168 /// \brief Attaches the observer into an AlterationNotifier. 169 /// 170 /// This member attaches the observer into an AlterationNotifier. 171 /// 165 // \brief Attaches the observer into an AlterationNotifier. 166 // 167 // This member attaches the observer into an AlterationNotifier. 172 168 void attach(AlterationNotifier& nf) { 173 169 nf.attach(*this); 174 170 } 175 171 176 /// \brief Detaches the observer into an AlterationNotifier. 177 /// 178 /// This member detaches the observer from an AlterationNotifier. 179 /// 172 // \brief Detaches the observer into an AlterationNotifier. 173 // 174 // This member detaches the observer from an AlterationNotifier. 180 175 void detach() { 181 176 _notifier->detach(*this); 182 177 } 183 178 184 /// \brief Gives back a pointer to the notifier which the map 185 /// attached into. 186 /// 187 /// This function gives back a pointer to the notifier which the map 188 /// attached into. 189 /// 179 // \brief Gives back a pointer to the notifier which the map 180 // attached into. 181 // 182 // This function gives back a pointer to the notifier which the map 183 // attached into. 190 184 Notifier* notifier() const { return const_cast<Notifier*>(_notifier); } 191 185 192 // /Gives back true when the observer is attached into a notifier.186 // Gives back true when the observer is attached into a notifier. 193 187 bool attached() const { return _notifier != 0; } 194 188 … … 202 196 typename std::list<ObserverBase*>::iterator _index; 203 197 204 // /\brief The member function to notificate the observer about an205 // /item is added to the container.206 // /207 // /The add() member function notificates the observer about an item208 // /is added to the container. It have to be overrided in the209 // /subclasses.198 // \brief The member function to notificate the observer about an 199 // item is added to the container. 200 // 201 // The add() member function notificates the observer about an item 202 // is added to the container. It have to be overrided in the 203 // subclasses. 210 204 virtual void add(const Item&) = 0; 211 205 212 // /\brief The member function to notificate the observer about213 // /more item is added to the container.214 // /215 // /The add() member function notificates the observer about more item216 // /is added to the container. It have to be overrided in the217 // /subclasses.206 // \brief The member function to notificate the observer about 207 // more item is added to the container. 208 // 209 // The add() member function notificates the observer about more item 210 // is added to the container. It have to be overrided in the 211 // subclasses. 218 212 virtual void add(const std::vector<Item>& items) = 0; 219 213 220 // /\brief The member function to notificate the observer about an221 // /item is erased from the container.222 // /223 // /The erase() member function notificates the observer about an224 // /item is erased from the container. It have to be overrided in225 // /the subclasses.214 // \brief The member function to notificate the observer about an 215 // item is erased from the container. 216 // 217 // The erase() member function notificates the observer about an 218 // item is erased from the container. It have to be overrided in 219 // the subclasses. 226 220 virtual void erase(const Item&) = 0; 227 221 228 // /\brief The member function to notificate the observer about229 // /more item is erased from the container.230 // /231 // /The erase() member function notificates the observer about more item232 // /is erased from the container. It have to be overrided in the233 // /subclasses.222 // \brief The member function to notificate the observer about 223 // more item is erased from the container. 224 // 225 // The erase() member function notificates the observer about more item 226 // is erased from the container. It have to be overrided in the 227 // subclasses. 234 228 virtual void erase(const std::vector<Item>& items) = 0; 235 229 236 /// \brief The member function to notificate the observer about the 237 /// container is built. 238 /// 239 /// The build() member function notificates the observer about the 240 /// container is built from an empty container. It have to be 241 /// overrided in the subclasses. 242 230 // \brief The member function to notificate the observer about the 231 // container is built. 232 // 233 // The build() member function notificates the observer about the 234 // container is built from an empty container. It have to be 235 // overrided in the subclasses. 243 236 virtual void build() = 0; 244 237 245 // /\brief The member function to notificate the observer about all246 // /items are erased from the container.247 // /248 // /The clear() member function notificates the observer about all249 // /items are erased from the container. It have to be overrided in250 // /the subclasses.238 // \brief The member function to notificate the observer about all 239 // items are erased from the container. 240 // 241 // The clear() member function notificates the observer about all 242 // items are erased from the container. It have to be overrided in 243 // the subclasses. 251 244 virtual void clear() = 0; 252 245 … … 263 256 public: 264 257 265 // /\brief Default constructor.266 // /267 // /The default constructor of the AlterationNotifier.268 // /It creates an empty notifier.258 // \brief Default constructor. 259 // 260 // The default constructor of the AlterationNotifier. 261 // It creates an empty notifier. 269 262 AlterationNotifier() 270 263 : container(0) {} 271 264 272 // /\brief Constructor.273 // /274 // /Constructor with the observed container parameter.265 // \brief Constructor. 266 // 267 // Constructor with the observed container parameter. 275 268 AlterationNotifier(const Container& _container) 276 269 : container(&_container) {} 277 270 278 // /\brief Copy Constructor of the AlterationNotifier.279 // /280 // /Copy constructor of the AlterationNotifier.281 // /It creates only an empty notifier because the copiable282 // /notifier's observers have to be registered still into that notifier.271 // \brief Copy Constructor of the AlterationNotifier. 272 // 273 // Copy constructor of the AlterationNotifier. 274 // It creates only an empty notifier because the copiable 275 // notifier's observers have to be registered still into that notifier. 283 276 AlterationNotifier(const AlterationNotifier& _notifier) 284 277 : container(_notifier.container) {} 285 278 286 /// \brief Destructor. 287 /// 288 /// Destructor of the AlterationNotifier. 289 /// 279 // \brief Destructor. 280 // 281 // Destructor of the AlterationNotifier. 290 282 ~AlterationNotifier() { 291 283 typename Observers::iterator it; … … 295 287 } 296 288 297 // /\brief Sets the container.298 // /299 // /Sets the container.289 // \brief Sets the container. 290 // 291 // Sets the container. 300 292 void setContainer(const Container& _container) { 301 293 container = &_container; … … 308 300 public: 309 301 310 311 312 /// \brief First item in the container. 313 /// 314 /// Returns the first item in the container. It is 315 /// for start the iteration on the container. 302 // \brief First item in the container. 303 // 304 // Returns the first item in the container. It is 305 // for start the iteration on the container. 316 306 void first(Item& item) const { 317 307 container->first(item); 318 308 } 319 309 320 // /\brief Next item in the container.321 // /322 // /Returns the next item in the container. It is323 // /for iterate on the container.310 // \brief Next item in the container. 311 // 312 // Returns the next item in the container. It is 313 // for iterate on the container. 324 314 void next(Item& item) const { 325 315 container->next(item); 326 316 } 327 317 328 // /\brief Returns the id of the item.329 // /330 // /Returns the id of the item provided by the container.318 // \brief Returns the id of the item. 319 // 320 // Returns the id of the item provided by the container. 331 321 int id(const Item& item) const { 332 322 return container->id(item); 333 323 } 334 324 335 // /\brief Returns the maximum id of the container.336 // /337 // /Returns the maximum id of the container.325 // \brief Returns the maximum id of the container. 326 // 327 // Returns the maximum id of the container. 338 328 int maxId() const { 339 329 return container->maxId(Item()); … … 355 345 public: 356 346 357 /// \brief Notifies all the registed observers about an item added to 358 /// the container. 359 /// 360 /// It notifies all the registed observers about an item added to 361 /// the container. 362 /// 347 // \brief Notifies all the registed observers about an item added to 348 // the container. 349 // 350 // It notifies all the registed observers about an item added to 351 // the container. 363 352 void add(const Item& item) { 364 353 typename Observers::reverse_iterator it; … … 376 365 } 377 366 378 /// \brief Notifies all the registed observers about more item added to 379 /// the container. 380 /// 381 /// It notifies all the registed observers about more item added to 382 /// the container. 383 /// 367 // \brief Notifies all the registed observers about more item added to 368 // the container. 369 // 370 // It notifies all the registed observers about more item added to 371 // the container. 384 372 void add(const std::vector<Item>& items) { 385 373 typename Observers::reverse_iterator it; … … 397 385 } 398 386 399 /// \brief Notifies all the registed observers about an item erased from 400 /// the container. 401 /// 402 /// It notifies all the registed observers about an item erased from 403 /// the container. 404 /// 387 // \brief Notifies all the registed observers about an item erased from 388 // the container. 389 // 390 // It notifies all the registed observers about an item erased from 391 // the container. 405 392 void erase(const Item& item) throw() { 406 393 typename Observers::iterator it = _observers.begin(); … … 417 404 } 418 405 419 /// \brief Notifies all the registed observers about more item erased 420 /// from the container. 421 /// 422 /// It notifies all the registed observers about more item erased from 423 /// the container. 424 /// 406 // \brief Notifies all the registed observers about more item erased 407 // from the container. 408 // 409 // It notifies all the registed observers about more item erased from 410 // the container. 425 411 void erase(const std::vector<Item>& items) { 426 412 typename Observers::iterator it = _observers.begin(); … … 437 423 } 438 424 439 // /\brief Notifies all the registed observers about the container is440 // /built.441 // /442 // /Notifies all the registed observers about the container is built443 // /from an empty container.425 // \brief Notifies all the registed observers about the container is 426 // built. 427 // 428 // Notifies all the registed observers about the container is built 429 // from an empty container. 444 430 void build() { 445 431 typename Observers::reverse_iterator it; … … 457 443 } 458 444 459 // /\brief Notifies all the registed observers about all items are460 // /erased.461 // /462 // /Notifies all the registed observers about all items are erased463 // /from the container.445 // \brief Notifies all the registed observers about all items are 446 // erased. 447 // 448 // Notifies all the registed observers about all items are erased 449 // from the container. 464 450 void clear() { 465 451 typename Observers::iterator it = _observers.begin(); -
lemon/bits/array_map.h
r209 r314 27 27 #include <lemon/concepts/maps.h> 28 28 29 // /\ingroup graphbits30 // /\file31 // /\brief Graph map based on the array storage.29 // \ingroup graphbits 30 // \file 31 // \brief Graph map based on the array storage. 32 32 33 33 namespace lemon { 34 34 35 // /\ingroup graphbits36 // /37 // /\brief Graph map based on the array storage.38 // /39 // /The ArrayMap template class is graph map structure what40 // /automatically updates the map when a key is added to or erased from41 // /the map. This map uses the allocators to implement42 // /the container functionality.43 // /44 // /The template parameters are the Graph the current Item type and45 // /the Value type of the map.35 // \ingroup graphbits 36 // 37 // \brief Graph map based on the array storage. 38 // 39 // The ArrayMap template class is graph map structure what 40 // automatically updates the map when a key is added to or erased from 41 // the map. This map uses the allocators to implement 42 // the container functionality. 43 // 44 // The template parameters are the Graph the current Item type and 45 // the Value type of the map. 46 46 template <typename _Graph, typename _Item, typename _Value> 47 47 class ArrayMap 48 48 : public ItemSetTraits<_Graph, _Item>::ItemNotifier::ObserverBase { 49 49 public: 50 // /The graph type of the maps.50 // The graph type of the maps. 51 51 typedef _Graph Graph; 52 // /The item type of the map.52 // The item type of the map. 53 53 typedef _Item Item; 54 // /The reference map tag.54 // The reference map tag. 55 55 typedef True ReferenceMapTag; 56 56 57 // /The key type of the maps.57 // The key type of the maps. 58 58 typedef _Item Key; 59 // /The value type of the map.59 // The value type of the map. 60 60 typedef _Value Value; 61 61 62 // /The const reference type of the map.62 // The const reference type of the map. 63 63 typedef const _Value& ConstReference; 64 // /The reference type of the map.64 // The reference type of the map. 65 65 typedef _Value& Reference; 66 66 67 // /The notifier type.67 // The notifier type. 68 68 typedef typename ItemSetTraits<_Graph, _Item>::ItemNotifier Notifier; 69 69 70 // /The MapBase of the Map which imlements the core regisitry function.70 // The MapBase of the Map which imlements the core regisitry function. 71 71 typedef typename Notifier::ObserverBase Parent; 72 72 … … 76 76 public: 77 77 78 // /\brief Graph initialized map constructor.79 // /80 // /Graph initialized map constructor.78 // \brief Graph initialized map constructor. 79 // 80 // Graph initialized map constructor. 81 81 explicit ArrayMap(const Graph& graph) { 82 82 Parent::attach(graph.notifier(Item())); … … 90 90 } 91 91 92 // /\brief Constructor to use default value to initialize the map.93 // /94 // /It constructs a map and initialize all of the the map.92 // \brief Constructor to use default value to initialize the map. 93 // 94 // It constructs a map and initialize all of the the map. 95 95 ArrayMap(const Graph& graph, const Value& value) { 96 96 Parent::attach(graph.notifier(Item())); … … 104 104 } 105 105 106 /// \brief Constructor to copy a map of the same map type. 107 /// 108 /// Constructor to copy a map of the same map type. 106 private: 107 // \brief Constructor to copy a map of the same map type. 108 // 109 // Constructor to copy a map of the same map type. 109 110 ArrayMap(const ArrayMap& copy) : Parent() { 110 111 if (copy.attached()) { … … 122 123 } 123 124 124 // /\brief Assign operator.125 // /126 // /This operator assigns for each item in the map the127 // /value mapped to the same item in the copied map.128 // /The parameter map should be indiced with the same129 // /itemset because this assign operator does not change130 // /the container of the map.125 // \brief Assign operator. 126 // 127 // This operator assigns for each item in the map the 128 // value mapped to the same item in the copied map. 129 // The parameter map should be indiced with the same 130 // itemset because this assign operator does not change 131 // the container of the map. 131 132 ArrayMap& operator=(const ArrayMap& cmap) { 132 133 return operator=<ArrayMap>(cmap); … … 134 135 135 136 136 // /\brief Template assign operator.137 // /138 // /The given parameter should be conform to the ReadMap139 // /concecpt and could be indiced by the current item set of140 // /the NodeMap. In this case the value for each item141 // /is assigned by the value of the given ReadMap.137 // \brief Template assign operator. 138 // 139 // The given parameter should be conform to the ReadMap 140 // concecpt and could be indiced by the current item set of 141 // the NodeMap. In this case the value for each item 142 // is assigned by the value of the given ReadMap. 142 143 template <typename CMap> 143 144 ArrayMap& operator=(const CMap& cmap) { … … 151 152 } 152 153 153 /// \brief The destructor of the map. 154 /// 155 /// The destructor of the map. 154 public: 155 // \brief The destructor of the map. 156 // 157 // The destructor of the map. 156 158 virtual ~ArrayMap() { 157 159 if (attached()) { … … 169 171 public: 170 172 171 // /\brief The subscript operator.172 // /173 // /The subscript operator. The map can be subscripted by the174 // /actual keys of the graph.173 // \brief The subscript operator. 174 // 175 // The subscript operator. The map can be subscripted by the 176 // actual keys of the graph. 175 177 Value& operator[](const Key& key) { 176 178 int id = Parent::notifier()->id(key); … … 178 180 } 179 181 180 // /\brief The const subscript operator.181 // /182 // /The const subscript operator. The map can be subscripted by the183 // /actual keys of the graph.182 // \brief The const subscript operator. 183 // 184 // The const subscript operator. The map can be subscripted by the 185 // actual keys of the graph. 184 186 const Value& operator[](const Key& key) const { 185 187 int id = Parent::notifier()->id(key); … … 187 189 } 188 190 189 // /\brief Setter function of the map.190 // /191 // /Setter function of the map. Equivalent with map[key] = val.192 // /This is a compatibility feature with the not dereferable maps.191 // \brief Setter function of the map. 192 // 193 // Setter function of the map. Equivalent with map[key] = val. 194 // This is a compatibility feature with the not dereferable maps. 193 195 void set(const Key& key, const Value& val) { 194 196 (*this)[key] = val; … … 197 199 protected: 198 200 199 // /\brief Adds a new key to the map.200 // /201 // /It adds a new key to the map. It called by the observer notifier202 // /and it overrides the add() member function of the observer base.201 // \brief Adds a new key to the map. 202 // 203 // It adds a new key to the map. It called by the observer notifier 204 // and it overrides the add() member function of the observer base. 203 205 virtual void add(const Key& key) { 204 206 Notifier* nf = Parent::notifier(); … … 225 227 } 226 228 227 // /\brief Adds more new keys to the map.228 // /229 // /It adds more new keys to the map. It called by the observer notifier230 // /and it overrides the add() member function of the observer base.229 // \brief Adds more new keys to the map. 230 // 231 // It adds more new keys to the map. It called by the observer notifier 232 // and it overrides the add() member function of the observer base. 231 233 virtual void add(const std::vector<Key>& keys) { 232 234 Notifier* nf = Parent::notifier(); … … 269 271 } 270 272 271 // /\brief Erase a key from the map.272 // /273 // /Erase a key from the map. It called by the observer notifier274 // /and it overrides the erase() member function of the observer base.273 // \brief Erase a key from the map. 274 // 275 // Erase a key from the map. It called by the observer notifier 276 // and it overrides the erase() member function of the observer base. 275 277 virtual void erase(const Key& key) { 276 278 int id = Parent::notifier()->id(key); … … 278 280 } 279 281 280 // /\brief Erase more keys from the map.281 // /282 // /Erase more keys from the map. It called by the observer notifier283 // /and it overrides the erase() member function of the observer base.282 // \brief Erase more keys from the map. 283 // 284 // Erase more keys from the map. It called by the observer notifier 285 // and it overrides the erase() member function of the observer base. 284 286 virtual void erase(const std::vector<Key>& keys) { 285 287 for (int i = 0; i < int(keys.size()); ++i) { … … 289 291 } 290 292 291 // /\brief Buildes the map.292 // /293 // /It buildes the map. It called by the observer notifier294 // /and it overrides the build() member function of the observer base.293 // \brief Buildes the map. 294 // 295 // It buildes the map. It called by the observer notifier 296 // and it overrides the build() member function of the observer base. 295 297 virtual void build() { 296 298 Notifier* nf = Parent::notifier(); … … 303 305 } 304 306 305 // /\brief Clear the map.306 // /307 // /It erase all items from the map. It called by the observer notifier308 // /and it overrides the clear() member function of the observer base.307 // \brief Clear the map. 308 // 309 // It erase all items from the map. It called by the observer notifier 310 // and it overrides the clear() member function of the observer base. 309 311 virtual void clear() { 310 312 Notifier* nf = Parent::notifier(); -
lemon/bits/base_extender.h
r220 r314 29 29 #include <lemon/concepts/maps.h> 30 30 31 // /\ingroup digraphbits32 // /\file33 // /\brief Extenders for the digraph types31 //\ingroup digraphbits 32 //\file 33 //\brief Extenders for the digraph types 34 34 namespace lemon { 35 35 36 // /\ingroup digraphbits37 // /38 // /\brief BaseDigraph to BaseGraph extender36 // \ingroup digraphbits 37 // 38 // \brief BaseDigraph to BaseGraph extender 39 39 template <typename Base> 40 40 class UndirDigraphExtender : public Base { … … 60 60 Arc() {} 61 61 62 // /Invalid arc constructor62 // Invalid arc constructor 63 63 Arc(Invalid i) : Edge(i), forward(true) {} 64 64 … … 75 75 }; 76 76 77 78 79 using Parent::source; 80 81 /// Source of the given Arc. 77 // First node of the edge 78 Node u(const Edge &e) const { 79 return Parent::source(e); 80 } 81 82 // Source of the given arc 82 83 Node source(const Arc &e) const { 83 84 return e.forward ? Parent::source(e) : Parent::target(e); 84 85 } 85 86 86 using Parent::target; 87 88 /// Target of the given Arc. 87 // Second node of the edge 88 Node v(const Edge &e) const { 89 return Parent::target(e); 90 } 91 92 // Target of the given arc 89 93 Node target(const Arc &e) const { 90 94 return e.forward ? Parent::target(e) : Parent::source(e); 91 95 } 92 96 93 /// \brief Directed arc from an edge. 94 /// 95 /// Returns a directed arc corresponding to the specified Edge. 96 /// If the given bool is true the given edge and the 97 /// returned arc have the same source node. 98 static Arc direct(const Edge &ue, bool d) { 99 return Arc(ue, d); 100 } 101 102 /// Returns whether the given directed arc is same orientation as the 103 /// corresponding edge. 104 /// 105 /// \todo reference to the corresponding point of the undirected digraph 106 /// concept. "What does the direction of an edge mean?" 107 static bool direction(const Arc &e) { return e.forward; } 108 97 // \brief Directed arc from an edge. 98 // 99 // Returns a directed arc corresponding to the specified edge. 100 // If the given bool is true, the first node of the given edge and 101 // the source node of the returned arc are the same. 102 static Arc direct(const Edge &e, bool d) { 103 return Arc(e, d); 104 } 105 106 // Returns whether the given directed arc has the same orientation 107 // as the corresponding edge. 108 static bool direction(const Arc &a) { return a.forward; } 109 109 110 110 using Parent::first; … … 229 229 return Parent::maxArcId(); 230 230 } 231 232 231 233 232 int arcNum() const { … … 300 299 Red() {} 301 300 Red(const Node& node) : Node(node) { 302 LEMON_ ASSERT(Parent::red(node) || node == INVALID,303 301 LEMON_DEBUG(Parent::red(node) || node == INVALID, 302 typename Parent::NodeSetError()); 304 303 } 305 304 Red& operator=(const Node& node) { 306 LEMON_ ASSERT(Parent::red(node) || node == INVALID,307 305 LEMON_DEBUG(Parent::red(node) || node == INVALID, 306 typename Parent::NodeSetError()); 308 307 Node::operator=(node); 309 308 return *this; … … 332 331 Blue() {} 333 332 Blue(const Node& node) : Node(node) { 334 LEMON_ ASSERT(Parent::blue(node) || node == INVALID,335 333 LEMON_DEBUG(Parent::blue(node) || node == INVALID, 334 typename Parent::NodeSetError()); 336 335 } 337 336 Blue& operator=(const Node& node) { 338 LEMON_ ASSERT(Parent::blue(node) || node == INVALID,339 337 LEMON_DEBUG(Parent::blue(node) || node == INVALID, 338 typename Parent::NodeSetError()); 340 339 Node::operator=(node); 341 340 return *this; -
lemon/bits/bezier.h
r209 r314 20 20 #define LEMON_BEZIER_H 21 21 22 // /\ingroup misc23 // /\file24 // /\brief Classes to compute with Bezier curves.25 // /26 // /Up to now this file is used internally by \ref graph_to_eps.h22 //\ingroup misc 23 //\file 24 //\brief Classes to compute with Bezier curves. 25 // 26 //Up to now this file is used internally by \ref graph_to_eps.h 27 27 28 28 #include<lemon/dim2.h> -
lemon/bits/default_map.h
r209 r314 20 20 #define LEMON_BITS_DEFAULT_MAP_H 21 21 22 23 22 #include <lemon/bits/array_map.h> 24 23 #include <lemon/bits/vector_map.h> 25 24 //#include <lemon/bits/debug_map.h> 26 25 27 // /\ingroup graphbits28 // /\file29 // /\brief Graph maps that construct and destruct their elements dynamically.26 //\ingroup graphbits 27 //\file 28 //\brief Graph maps that construct and destruct their elements dynamically. 30 29 31 30 namespace lemon { … … 150 149 // #endif 151 150 152 // / \e151 // DefaultMap class 153 152 template <typename _Graph, typename _Item, typename _Value> 154 153 class DefaultMap -
lemon/bits/enable_if.h
r220 r314 36 36 #define LEMON_BITS_ENABLE_IF_H 37 37 38 // /\file39 // /\brief Miscellaneous basic utilities38 //\file 39 //\brief Miscellaneous basic utilities 40 40 41 41 namespace lemon 42 42 { 43 43 44 // /Basic type for defining "tags". A "YES" condition for \c enable_if.44 // Basic type for defining "tags". A "YES" condition for \c enable_if. 45 45 46 // /Basic type for defining "tags". A "YES" condition for \c enable_if.47 // /48 // /\sa False46 // Basic type for defining "tags". A "YES" condition for \c enable_if. 47 // 48 //\sa False 49 49 struct True { 50 // /\e50 //\e 51 51 static const bool value = true; 52 52 }; 53 53 54 // /Basic type for defining "tags". A "NO" condition for \c enable_if.54 // Basic type for defining "tags". A "NO" condition for \c enable_if. 55 55 56 // /Basic type for defining "tags". A "NO" condition for \c enable_if.57 // /58 // /\sa True56 // Basic type for defining "tags". A "NO" condition for \c enable_if. 57 // 58 //\sa True 59 59 struct False { 60 // /\e60 //\e 61 61 static const bool value = false; 62 62 }; -
lemon/bits/graph_extender.h
r220 r314 28 28 #include <lemon/concepts/maps.h> 29 29 30 // /\ingroup graphbits31 // /\file32 // /\brief Extenders for the digraph types30 //\ingroup graphbits 31 //\file 32 //\brief Extenders for the digraph types 33 33 namespace lemon { 34 34 35 // /\ingroup graphbits36 // /37 // /\brief Extender for the Digraphs35 // \ingroup graphbits 36 // 37 // \brief Extender for the Digraphs 38 38 template <typename Base> 39 39 class DigraphExtender : public Base { … … 187 187 }; 188 188 189 // /\brief Base node of the iterator190 // /191 // /Returns the base node (i.e. the source in this case) of the iterator189 // \brief Base node of the iterator 190 // 191 // Returns the base node (i.e. the source in this case) of the iterator 192 192 Node baseNode(const OutArcIt &arc) const { 193 193 return Parent::source(arc); 194 194 } 195 // /\brief Running node of the iterator196 // /197 // /Returns the running node (i.e. the target in this case) of the198 // /iterator195 // \brief Running node of the iterator 196 // 197 // Returns the running node (i.e. the target in this case) of the 198 // iterator 199 199 Node runningNode(const OutArcIt &arc) const { 200 200 return Parent::target(arc); 201 201 } 202 202 203 // /\brief Base node of the iterator204 // /205 // /Returns the base node (i.e. the target in this case) of the iterator203 // \brief Base node of the iterator 204 // 205 // Returns the base node (i.e. the target in this case) of the iterator 206 206 Node baseNode(const InArcIt &arc) const { 207 207 return Parent::target(arc); 208 208 } 209 // /\brief Running node of the iterator210 // /211 // /Returns the running node (i.e. the source in this case) of the212 // /iterator209 // \brief Running node of the iterator 210 // 211 // Returns the running node (i.e. the source in this case) of the 212 // iterator 213 213 Node runningNode(const InArcIt &arc) const { 214 214 return Parent::source(arc); … … 228 228 : Parent(digraph, value) {} 229 229 230 private: 230 231 NodeMap& operator=(const NodeMap& cmap) { 231 232 return operator=<NodeMap>(cmap); … … 252 253 : Parent(digraph, value) {} 253 254 255 private: 254 256 ArcMap& operator=(const ArcMap& cmap) { 255 257 return operator=<ArcMap>(cmap); … … 324 326 }; 325 327 326 // /\ingroup _graphbits327 // /328 // /\brief Extender for the Graphs328 // \ingroup _graphbits 329 // 330 // \brief Extender for the Graphs 329 331 template <typename Base> 330 332 class GraphExtender : public Base { … … 554 556 }; 555 557 556 // /\brief Base node of the iterator557 // /558 // /Returns the base node (ie. the source in this case) of the iterator558 // \brief Base node of the iterator 559 // 560 // Returns the base node (ie. the source in this case) of the iterator 559 561 Node baseNode(const OutArcIt &arc) const { 560 562 return Parent::source(static_cast<const Arc&>(arc)); 561 563 } 562 // /\brief Running node of the iterator563 // /564 // /Returns the running node (ie. the target in this case) of the565 // /iterator564 // \brief Running node of the iterator 565 // 566 // Returns the running node (ie. the target in this case) of the 567 // iterator 566 568 Node runningNode(const OutArcIt &arc) const { 567 569 return Parent::target(static_cast<const Arc&>(arc)); 568 570 } 569 571 570 // /\brief Base node of the iterator571 // /572 // /Returns the base node (ie. the target in this case) of the iterator572 // \brief Base node of the iterator 573 // 574 // Returns the base node (ie. the target in this case) of the iterator 573 575 Node baseNode(const InArcIt &arc) const { 574 576 return Parent::target(static_cast<const Arc&>(arc)); 575 577 } 576 // /\brief Running node of the iterator577 // /578 // /Returns the running node (ie. the source in this case) of the579 // /iterator578 // \brief Running node of the iterator 579 // 580 // Returns the running node (ie. the source in this case) of the 581 // iterator 580 582 Node runningNode(const InArcIt &arc) const { 581 583 return Parent::source(static_cast<const Arc&>(arc)); 582 584 } 583 585 584 // /Base node of the iterator585 // /586 // /Returns the base node of the iterator586 // Base node of the iterator 587 // 588 // Returns the base node of the iterator 587 589 Node baseNode(const IncEdgeIt &edge) const { 588 590 return edge._direction ? u(edge) : v(edge); 589 591 } 590 // /Running node of the iterator591 // /592 // /Returns the running node of the iterator592 // Running node of the iterator 593 // 594 // Returns the running node of the iterator 593 595 Node runningNode(const IncEdgeIt &edge) const { 594 596 return edge._direction ? v(edge) : u(edge); … … 609 611 : Parent(graph, value) {} 610 612 613 private: 611 614 NodeMap& operator=(const NodeMap& cmap) { 612 615 return operator=<NodeMap>(cmap); … … 633 636 : Parent(graph, value) {} 634 637 638 private: 635 639 ArcMap& operator=(const ArcMap& cmap) { 636 640 return operator=<ArcMap>(cmap); … … 658 662 : Parent(graph, value) {} 659 663 664 private: 660 665 EdgeMap& operator=(const EdgeMap& cmap) { 661 666 return operator=<EdgeMap>(cmap); -
lemon/bits/map_extender.h
r209 r314 27 27 #include <lemon/concepts/maps.h> 28 28 29 // /\file30 // /\brief Extenders for iterable maps.29 //\file 30 //\brief Extenders for iterable maps. 31 31 32 32 namespace lemon { 33 33 34 // /\ingroup graphbits35 // /36 // /\brief Extender for maps34 // \ingroup graphbits 35 // 36 // \brief Extender for maps 37 37 template <typename _Map> 38 38 class MapExtender : public _Map { … … 63 63 : Parent(graph, value) {} 64 64 65 private: 65 66 MapExtender& operator=(const MapExtender& cmap) { 66 67 return operator=<MapExtender>(cmap); … … 73 74 } 74 75 76 public: 75 77 class MapIt : public Item { 76 78 public: … … 170 172 }; 171 173 172 // /\ingroup graphbits173 // /174 // /\brief Extender for maps which use a subset of the items.174 // \ingroup graphbits 175 // 176 // \brief Extender for maps which use a subset of the items. 175 177 template <typename _Graph, typename _Map> 176 178 class SubMapExtender : public _Map { … … 201 203 : Parent(_graph, _value), graph(_graph) {} 202 204 205 private: 203 206 SubMapExtender& operator=(const SubMapExtender& cmap) { 204 207 return operator=<MapExtender>(cmap); … … 215 218 } 216 219 220 public: 217 221 class MapIt : public Item { 218 222 public: -
lemon/bits/traits.h
r220 r314 20 20 #define LEMON_BITS_TRAITS_H 21 21 22 // /\file23 // /\brief Traits for graphs and maps24 // /22 //\file 23 //\brief Traits for graphs and maps 24 // 25 25 26 26 #include <lemon/bits/enable_if.h> -
lemon/bits/vector_map.h
r220 r314 29 29 #include <lemon/concepts/maps.h> 30 30 31 // /\ingroup graphbits32 // /33 // /\file34 // /\brief Vector based graph maps.31 //\ingroup graphbits 32 // 33 //\file 34 //\brief Vector based graph maps. 35 35 namespace lemon { 36 36 37 /// \ingroup graphbits 38 /// 39 /// \brief Graph map based on the std::vector storage. 40 /// 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. 44 /// 45 /// \tparam _Notifier The AlterationNotifier that will notify this map. 46 /// \tparam _Item The item type of the graph items. 47 /// \tparam _Value The value type of the map. 48 /// \todo Fix the doc: there is _Graph parameter instead of _Notifier. 37 // \ingroup graphbits 38 // 39 // \brief Graph map based on the std::vector storage. 40 // 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. 44 // 45 // \tparam _Graph The graph this map is attached to. 46 // \tparam _Item The item type of the graph items. 47 // \tparam _Value The value type of the map. 49 48 template <typename _Graph, typename _Item, typename _Value> 50 49 class VectorMap … … 52 51 private: 53 52 54 // /The container type of the map.53 // The container type of the map. 55 54 typedef std::vector<_Value> Container; 56 55 57 56 public: 58 57 59 // /The graph type of the map.58 // The graph type of the map. 60 59 typedef _Graph Graph; 61 // /The item type of the map.60 // The item type of the map. 62 61 typedef _Item Item; 63 // /The reference map tag.62 // The reference map tag. 64 63 typedef True ReferenceMapTag; 65 64 66 // /The key type of the map.65 // The key type of the map. 67 66 typedef _Item Key; 68 // /The value type of the map.67 // The value type of the map. 69 68 typedef _Value Value; 70 69 71 // /The notifier type.70 // The notifier type. 72 71 typedef typename ItemSetTraits<_Graph, _Item>::ItemNotifier Notifier; 73 72 74 // /The map type.73 // The map type. 75 74 typedef VectorMap Map; 76 // /The base class of the map.75 // The base class of the map. 77 76 typedef typename Notifier::ObserverBase Parent; 78 77 79 // /The reference type of the map;78 // The reference type of the map; 80 79 typedef typename Container::reference Reference; 81 // /The const reference type of the map;80 // The const reference type of the map; 82 81 typedef typename Container::const_reference ConstReference; 83 82 84 83 85 // /\brief Constructor to attach the new map into the notifier.86 // /87 // /It constructs a map and attachs it into the notifier.88 // /It adds all the items of the graph to the map.84 // \brief Constructor to attach the new map into the notifier. 85 // 86 // It constructs a map and attachs it into the notifier. 87 // It adds all the items of the graph to the map. 89 88 VectorMap(const Graph& graph) { 90 89 Parent::attach(graph.notifier(Item())); … … 92 91 } 93 92 94 // /\brief Constructor uses given value to initialize the map.95 // /96 // /It constructs a map uses a given value to initialize the map.97 // /It adds all the items of the graph to the map.93 // \brief Constructor uses given value to initialize the map. 94 // 95 // It constructs a map uses a given value to initialize the map. 96 // It adds all the items of the graph to the map. 98 97 VectorMap(const Graph& graph, const Value& value) { 99 98 Parent::attach(graph.notifier(Item())); … … 101 100 } 102 101 103 /// \brief Copy constructor 104 /// 105 /// Copy constructor. 102 private: 103 // \brief Copy constructor 104 // 105 // Copy constructor. 106 106 VectorMap(const VectorMap& _copy) : Parent() { 107 107 if (_copy.attached()) { … … 111 111 } 112 112 113 // /\brief Assign operator.114 // /115 // /This operator assigns for each item in the map the116 // /value mapped to the same item in the copied map.117 // /The parameter map should be indiced with the same118 // /itemset because this assign operator does not change119 // /the container of the map.113 // \brief Assign operator. 114 // 115 // This operator assigns for each item in the map the 116 // value mapped to the same item in the copied map. 117 // The parameter map should be indiced with the same 118 // itemset because this assign operator does not change 119 // the container of the map. 120 120 VectorMap& operator=(const VectorMap& cmap) { 121 121 return operator=<VectorMap>(cmap); … … 123 123 124 124 125 // /\brief Template assign operator.126 // /127 // /The given parameter should be conform to the ReadMap128 // /concecpt and could be indiced by the current item set of129 // /the NodeMap. In this case the value for each item130 // /is assigned by the value of the given ReadMap.125 // \brief Template assign operator. 126 // 127 // The given parameter should be conform to the ReadMap 128 // concecpt and could be indiced by the current item set of 129 // the NodeMap. In this case the value for each item 130 // is assigned by the value of the given ReadMap. 131 131 template <typename CMap> 132 132 VectorMap& operator=(const CMap& cmap) { … … 142 142 public: 143 143 144 // /\brief The subcript operator.145 // /146 // /The subscript operator. The map can be subscripted by the147 // /actual items of the graph.144 // \brief The subcript operator. 145 // 146 // The subscript operator. The map can be subscripted by the 147 // actual items of the graph. 148 148 Reference operator[](const Key& key) { 149 149 return container[Parent::notifier()->id(key)]; 150 150 } 151 151 152 // /\brief The const subcript operator.153 // /154 // /The const subscript operator. The map can be subscripted by the155 // /actual items of the graph.152 // \brief The const subcript operator. 153 // 154 // The const subscript operator. The map can be subscripted by the 155 // actual items of the graph. 156 156 ConstReference operator[](const Key& key) const { 157 157 return container[Parent::notifier()->id(key)]; … … 159 159 160 160 161 // /\brief The setter function of the map.162 // /163 // /It the same as operator[](key) = value expression.161 // \brief The setter function of the map. 162 // 163 // It the same as operator[](key) = value expression. 164 164 void set(const Key& key, const Value& value) { 165 165 (*this)[key] = value; … … 168 168 protected: 169 169 170 // /\brief Adds a new key to the map.171 // /172 // /It adds a new key to the map. It called by the observer notifier173 // /and it overrides the add() member function of the observer base.170 // \brief Adds a new key to the map. 171 // 172 // It adds a new key to the map. It called by the observer notifier 173 // and it overrides the add() member function of the observer base. 174 174 virtual void add(const Key& key) { 175 175 int id = Parent::notifier()->id(key); … … 179 179 } 180 180 181 // /\brief Adds more new keys to the map.182 // /183 // /It adds more new keys to the map. It called by the observer notifier184 // /and it overrides the add() member function of the observer base.181 // \brief Adds more new keys to the map. 182 // 183 // It adds more new keys to the map. It called by the observer notifier 184 // and it overrides the add() member function of the observer base. 185 185 virtual void add(const std::vector<Key>& keys) { 186 186 int max = container.size() - 1; … … 194 194 } 195 195 196 // /\brief Erase a key from the map.197 // /198 // /Erase a key from the map. It called by the observer notifier199 // /and it overrides the erase() member function of the observer base.196 // \brief Erase a key from the map. 197 // 198 // Erase a key from the map. It called by the observer notifier 199 // and it overrides the erase() member function of the observer base. 200 200 virtual void erase(const Key& key) { 201 201 container[Parent::notifier()->id(key)] = Value(); 202 202 } 203 203 204 // /\brief Erase more keys from the map.205 // /206 // /Erase more keys from the map. It called by the observer notifier207 // /and it overrides the erase() member function of the observer base.204 // \brief Erase more keys from the map. 205 // 206 // Erase more keys from the map. It called by the observer notifier 207 // and it overrides the erase() member function of the observer base. 208 208 virtual void erase(const std::vector<Key>& keys) { 209 209 for (int i = 0; i < int(keys.size()); ++i) { … … 212 212 } 213 213 214 // /\brief Buildes the map.215 // /216 // /It buildes the map. It called by the observer notifier217 // /and it overrides the build() member function of the observer base.214 // \brief Buildes the map. 215 // 216 // It buildes the map. It called by the observer notifier 217 // and it overrides the build() member function of the observer base. 218 218 virtual void build() { 219 219 int size = Parent::notifier()->maxId() + 1; … … 222 222 } 223 223 224 // /\brief Clear the map.225 // /226 // /It erase all items from the map. It called by the observer notifier227 // /and it overrides the clear() member function of the observer base.224 // \brief Clear the map. 225 // 226 // It erase all items from the map. It called by the observer notifier 227 // and it overrides the clear() member function of the observer base. 228 228 virtual void clear() { 229 229 container.clear(); -
lemon/color.h
r209 r313 93 93 extern const Color DARK_CYAN; 94 94 95 ///Map <tt>int</tt>s to different \ref Color "Color"s95 ///Map <tt>int</tt>s to different <tt>Color</tt>s 96 96 97 97 ///This map assigns one of the predefined \ref Color "Color"s to -
lemon/concept_check.h
r209 r285 17 17 */ 18 18 19 // This file contains a modified version of the concept checking 20 // utility from BOOST. 21 // See the appropriate copyright notice below. 22 23 // (C) Copyright Jeremy Siek 2000. 24 // Distributed under the Boost Software License, Version 1.0. (See 25 // accompanying file LICENSE_1_0.txt or copy at 26 // http://www.boost.org/LICENSE_1_0.txt) 27 // 28 // Revision History: 29 // 05 May 2001: Workarounds for HP aCC from Thomas Matelich. (Jeremy Siek) 30 // 02 April 2001: Removed limits header altogether. (Jeremy Siek) 31 // 01 April 2001: Modified to use new <boost/limits.hpp> header. (JMaddock) 32 // 33 34 // See http://www.boost.org/libs/concept_check for documentation. 19 // The contents of this file was inspired by the concept checking 20 // utility of the BOOST library (http://www.boost.org). 35 21 36 22 ///\file 37 23 ///\brief Basic utilities for concept checking. 38 24 /// 39 ///\todo Are we still using BOOST concept checking utility?40 ///Is the BOOST copyright notice necessary?41 25 42 26 #ifndef LEMON_CONCEPT_CHECK_H -
lemon/concepts/digraph.h
r220 r263 435 435 NodeMap(const Digraph&, T) { } 436 436 437 private: 437 438 ///Copy constructor 438 439 NodeMap(const NodeMap& nm) : ReadWriteMap< Node, T >(nm) { } … … 457 458 ///\e 458 459 ArcMap(const Digraph&, T) { } 460 private: 459 461 ///Copy constructor 460 462 ArcMap(const ArcMap& em) : ReadWriteMap<Arc,T>(em) { } -
lemon/concepts/graph.h
r220 r263 513 513 NodeMap(const Graph&, T) { } 514 514 515 private: 515 516 ///Copy constructor 516 517 NodeMap(const NodeMap& nm) : ReadWriteMap< Node, T >(nm) { } … … 536 537 ///\e 537 538 ArcMap(const Graph&, T) { } 539 private: 538 540 ///Copy constructor 539 541 ArcMap(const ArcMap& em) : ReadWriteMap<Arc,T>(em) { } … … 559 561 ///\e 560 562 EdgeMap(const Graph&, T) { } 563 private: 561 564 ///Copy constructor 562 565 EdgeMap(const EdgeMap& em) : ReadWriteMap<Edge,T>(em) {} -
lemon/concepts/graph_components.h
r220 r313 983 983 /// 984 984 /// This class describes the common interface of the graph maps 985 /// (NodeMap, ArcMap), that is \ref maps-page "maps" whichcan be used to985 /// (NodeMap, ArcMap), that is maps that can be used to 986 986 /// associate data to graph descriptors (nodes or arcs). 987 987 template <typename _Graph, typename _Item, typename _Value> … … 1006 1006 /// Construct a new map for the graph and initalise the values. 1007 1007 GraphMap(const Graph&, const Value&) {} 1008 1009 private: 1008 1010 /// \brief Copy constructor. 1009 1011 /// … … 1022 1024 } 1023 1025 1026 public: 1024 1027 template<typename _Map> 1025 1028 struct Constraints { … … 1031 1034 _Map a2(g,t); 1032 1035 // Copy constructor. 1033 _Map b(c); 1034 1035 ReadMap<Key, Value> cmap; 1036 b = cmap; 1037 1036 // _Map b(c); 1037 1038 // ReadMap<Key, Value> cmap; 1039 // b = cmap; 1040 1041 ignore_unused_variable_warning(a); 1038 1042 ignore_unused_variable_warning(a2); 1039 ignore_unused_variable_warning(b);1043 // ignore_unused_variable_warning(b); 1040 1044 } 1041 1045 … … 1083 1087 : Parent(digraph, value) {} 1084 1088 1089 private: 1085 1090 /// \brief Copy constructor. 1086 1091 /// … … 1120 1125 : Parent(digraph, value) {} 1121 1126 1127 private: 1122 1128 /// \brief Copy constructor. 1123 1129 /// … … 1216 1222 : Parent(graph, value) {} 1217 1223 1224 private: 1218 1225 /// \brief Copy constructor. 1219 1226 /// -
lemon/concepts/heap.h
r220 r290 130 130 /// Otherwise it inserts the given item with the given priority. 131 131 /// 132 /// It may throw an \ref UnderflowPriorityException.133 132 /// \param i The item. 134 133 /// \param p The priority. -
lemon/concepts/maps.h
r220 r314 23 23 #include <lemon/concept_check.h> 24 24 25 ///\ingroup concept25 ///\ingroup map_concepts 26 26 ///\file 27 27 ///\brief The concept of maps. … … 31 31 namespace concepts { 32 32 33 /// \addtogroup concept33 /// \addtogroup map_concepts 34 34 /// @{ 35 35 -
lemon/concepts/path.h
r236 r281 21 21 ///\brief Classes for representing paths in digraphs. 22 22 /// 23 ///\todo Iterators have obsolete style24 23 25 24 #ifndef LEMON_CONCEPT_PATH_H … … 67 66 /// \brief Template assigment 68 67 template <typename CPath> 69 Path& operator=(const CPath& cpath) {} 68 Path& operator=(const CPath& cpath) { 69 ignore_unused_variable_warning(cpath); 70 return *this; 71 } 70 72 71 73 /// Length of the path ie. the number of arcs in the path. -
lemon/core.h
r233 r319 25 25 #include <lemon/bits/enable_if.h> 26 26 #include <lemon/bits/traits.h> 27 #include <lemon/assert.h> 27 28 28 29 ///\file … … 59 60 /// @{ 60 61 61 ///Create sconvenience typedefs for the digraph types and iterators62 63 ///This \c \#define creates convenien ce typedefs for the following types64 /// of \c Digraph: \c Node, \c NodeIt, \c Arc, \c ArcIt, \c InArcIt,62 ///Create convenience typedefs for the digraph types and iterators 63 64 ///This \c \#define creates convenient type definitions for the following 65 ///types of \c Digraph: \c Node, \c NodeIt, \c Arc, \c ArcIt, \c InArcIt, 65 66 ///\c OutArcIt, \c BoolNodeMap, \c IntNodeMap, \c DoubleNodeMap, 66 67 ///\c BoolArcMap, \c IntArcMap, \c DoubleArcMap. … … 83 84 typedef Digraph::ArcMap<double> DoubleArcMap 84 85 85 ///Create sconvenience typedefs for the digraph types and iterators86 ///Create convenience typedefs for the digraph types and iterators 86 87 87 88 ///\see DIGRAPH_TYPEDEFS … … 103 104 typedef typename Digraph::template ArcMap<double> DoubleArcMap 104 105 105 ///Create sconvenience typedefs for the graph types and iterators106 107 ///This \c \#define creates the same convenien ce typedefs as defined106 ///Create convenience typedefs for the graph types and iterators 107 108 ///This \c \#define creates the same convenient type definitions as defined 108 109 ///by \ref DIGRAPH_TYPEDEFS(Graph) and six more, namely it creates 109 110 ///\c Edge, \c EdgeIt, \c IncEdgeIt, \c BoolEdgeMap, \c IntEdgeMap, … … 111 112 /// 112 113 ///\note If the graph type is a dependent type, ie. the graph type depend 113 ///on a template parameter, then use \c TEMPLATE_ DIGRAPH_TYPEDEFS()114 ///on a template parameter, then use \c TEMPLATE_GRAPH_TYPEDEFS() 114 115 ///macro. 115 116 #define GRAPH_TYPEDEFS(Graph) \ … … 122 123 typedef Graph::EdgeMap<double> DoubleEdgeMap 123 124 124 ///Create sconvenience typedefs for the graph types and iterators125 ///Create convenience typedefs for the graph types and iterators 125 126 126 127 ///\see GRAPH_TYPEDEFS … … 137 138 typedef typename Graph::template EdgeMap<double> DoubleEdgeMap 138 139 139 /// \brief Function to count the items in thegraph.140 /// 141 /// This function counts the items (nodes, arcs etc ) in thegraph.142 /// The complexity of the function is O(n)because140 /// \brief Function to count the items in a graph. 141 /// 142 /// This function counts the items (nodes, arcs etc.) in a graph. 143 /// The complexity of the function is linear because 143 144 /// it iterates on all of the items. 144 145 template <typename Graph, typename Item> … … 177 178 /// 178 179 /// This function counts the nodes in the graph. 179 /// The complexity of the function is O(n)but for some180 /// graph structures it is specialized to run in O(1).181 /// 182 /// If the graph contains a \enodeNum() member function and a183 /// \ eNodeNumTag tag then this function calls directly the member180 /// The complexity of the function is <em>O</em>(<em>n</em>), but for some 181 /// graph structures it is specialized to run in <em>O</em>(1). 182 /// 183 /// \note If the graph contains a \c nodeNum() member function and a 184 /// \c NodeNumTag tag then this function calls directly the member 184 185 /// function to query the cardinality of the node set. 185 186 template <typename Graph> … … 213 214 /// 214 215 /// This function counts the arcs in the graph. 215 /// The complexity of the function is O(e)but for some216 /// graph structures it is specialized to run in O(1).217 /// 218 /// If the graph contains a \earcNum() member function and a219 /// \ e EdgeNumTag tag then this function calls directly the member216 /// The complexity of the function is <em>O</em>(<em>m</em>), but for some 217 /// graph structures it is specialized to run in <em>O</em>(1). 218 /// 219 /// \note If the graph contains a \c arcNum() member function and a 220 /// \c ArcNumTag tag then this function calls directly the member 220 221 /// function to query the cardinality of the arc set. 221 222 template <typename Graph> … … 225 226 226 227 // Edge counting: 228 227 229 namespace _core_bits { 228 230 … … 248 250 /// 249 251 /// This function counts the edges in the graph. 250 /// The complexity of the function is O(m)but for some251 /// graph structures it is specialized to run in O(1).252 /// 253 /// If the graph contains a \eedgeNum() member function and a254 /// \ eEdgeNumTag tag then this function calls directly the member252 /// The complexity of the function is <em>O</em>(<em>m</em>), but for some 253 /// graph structures it is specialized to run in <em>O</em>(1). 254 /// 255 /// \note If the graph contains a \c edgeNum() member function and a 256 /// \c EdgeNumTag tag then this function calls directly the member 255 257 /// function to query the cardinality of the edge set. 256 258 template <typename Graph> … … 273 275 /// 274 276 /// This function counts the number of the out-arcs from node \c n 275 /// in the graph .277 /// in the graph \c g. 276 278 template <typename Graph> 277 inline int countOutArcs(const Graph& _g, const typename Graph::Node& _n) {278 return countNodeDegree<Graph, typename Graph::OutArcIt>( _g, _n);279 inline int countOutArcs(const Graph& g, const typename Graph::Node& n) { 280 return countNodeDegree<Graph, typename Graph::OutArcIt>(g, n); 279 281 } 280 282 … … 282 284 /// 283 285 /// This function counts the number of the in-arcs to node \c n 284 /// in the graph .286 /// in the graph \c g. 285 287 template <typename Graph> 286 inline int countInArcs(const Graph& _g, const typename Graph::Node& _n) {287 return countNodeDegree<Graph, typename Graph::InArcIt>( _g, _n);288 inline int countInArcs(const Graph& g, const typename Graph::Node& n) { 289 return countNodeDegree<Graph, typename Graph::InArcIt>(g, n); 288 290 } 289 291 … … 291 293 /// 292 294 /// This function counts the number of the inc-edges to node \c n 293 /// in the graph.295 /// in the undirected graph \c g. 294 296 template <typename Graph> 295 inline int countIncEdges(const Graph& _g, const typename Graph::Node& _n) {296 return countNodeDegree<Graph, typename Graph::IncEdgeIt>( _g, _n);297 inline int countIncEdges(const Graph& g, const typename Graph::Node& n) { 298 return countNodeDegree<Graph, typename Graph::IncEdgeIt>(g, n); 297 299 } 298 300 … … 308 310 309 311 template <typename Digraph, typename Item, typename RefMap, 310 typename ToMap, typename FromMap>312 typename FromMap, typename ToMap> 311 313 class MapCopy : public MapCopyBase<Digraph, Item, RefMap> { 312 314 public: 313 315 314 MapCopy( ToMap& tmap, const FromMap&map)315 : _ tmap(tmap), _map(map) {}316 MapCopy(const FromMap& map, ToMap& tmap) 317 : _map(map), _tmap(tmap) {} 316 318 317 319 virtual void copy(const Digraph& digraph, const RefMap& refMap) { … … 323 325 324 326 private: 327 const FromMap& _map; 325 328 ToMap& _tmap; 326 const FromMap& _map;327 329 }; 328 330 … … 331 333 public: 332 334 333 ItemCopy( It& it, const Item& item) : _it(it), _item(item) {}335 ItemCopy(const Item& item, It& it) : _item(item), _it(it) {} 334 336 335 337 virtual void copy(const Digraph&, const RefMap& refMap) { … … 338 340 339 341 private: 342 Item _item; 340 343 It& _it; 341 Item _item;342 344 }; 343 345 … … 380 382 struct DigraphCopySelector { 381 383 template <typename From, typename NodeRefMap, typename ArcRefMap> 382 static void copy( Digraph &to, const From& from,384 static void copy(const From& from, Digraph &to, 383 385 NodeRefMap& nodeRefMap, ArcRefMap& arcRefMap) { 384 386 for (typename From::NodeIt it(from); it != INVALID; ++it) { … … 398 400 { 399 401 template <typename From, typename NodeRefMap, typename ArcRefMap> 400 static void copy( Digraph &to, const From& from,402 static void copy(const From& from, Digraph &to, 401 403 NodeRefMap& nodeRefMap, ArcRefMap& arcRefMap) { 402 404 to.build(from, nodeRefMap, arcRefMap); … … 407 409 struct GraphCopySelector { 408 410 template <typename From, typename NodeRefMap, typename EdgeRefMap> 409 static void copy( Graph &to, const From& from,411 static void copy(const From& from, Graph &to, 410 412 NodeRefMap& nodeRefMap, EdgeRefMap& edgeRefMap) { 411 413 for (typename From::NodeIt it(from); it != INVALID; ++it) { … … 425 427 { 426 428 template <typename From, typename NodeRefMap, typename EdgeRefMap> 427 static void copy( Graph &to, const From& from,429 static void copy(const From& from, Graph &to, 428 430 NodeRefMap& nodeRefMap, EdgeRefMap& edgeRefMap) { 429 431 to.build(from, nodeRefMap, edgeRefMap); … … 436 438 /// 437 439 /// Class to copy a digraph to another digraph (duplicate a digraph). The 438 /// simplest way of using it is through the \c copyDigraph() function.439 /// 440 /// This class not just make a copy of agraph, but it can create440 /// simplest way of using it is through the \c digraphCopy() function. 441 /// 442 /// This class not only make a copy of a digraph, but it can create 441 443 /// references and cross references between the nodes and arcs of 442 /// the two graphs, it can copy maps foruse with the newly created443 /// graph and copy nodes and arcs.444 /// 445 /// To make a copy from a graph, first an instance of DigraphCopy446 /// should be created, then the data belongs to the graph should444 /// the two digraphs, and it can copy maps to use with the newly created 445 /// digraph. 446 /// 447 /// To make a copy from a digraph, first an instance of DigraphCopy 448 /// should be created, then the data belongs to the digraph should 447 449 /// assigned to copy. In the end, the \c run() member should be 448 450 /// called. 449 451 /// 450 /// The next code copies a graph with several data:452 /// The next code copies a digraph with several data: 451 453 ///\code 452 /// DigraphCopy< NewGraph, OrigGraph> dc(new_graph, orig_graph);453 /// // create a referencefor the nodes454 /// DigraphCopy<OrigGraph, NewGraph> cg(orig_graph, new_graph); 455 /// // Create references for the nodes 454 456 /// OrigGraph::NodeMap<NewGraph::Node> nr(orig_graph); 455 /// dc.nodeRef(nr);456 /// // create a cross reference(inverse) for the arcs457 /// cg.nodeRef(nr); 458 /// // Create cross references (inverse) for the arcs 457 459 /// NewGraph::ArcMap<OrigGraph::Arc> acr(new_graph); 458 /// dc.arcCrossRef(acr);459 /// // copy an arc map460 /// cg.arcCrossRef(acr); 461 /// // Copy an arc map 460 462 /// OrigGraph::ArcMap<double> oamap(orig_graph); 461 463 /// NewGraph::ArcMap<double> namap(new_graph); 462 /// dc.arcMap(namap, oamap);463 /// // copy a node464 /// cg.arcMap(oamap, namap); 465 /// // Copy a node 464 466 /// OrigGraph::Node on; 465 467 /// NewGraph::Node nn; 466 /// dc.node(nn, on);467 /// // Execut ions of copy468 /// dc.run();468 /// cg.node(on, nn); 469 /// // Execute copying 470 /// cg.run(); 469 471 ///\endcode 470 template <typename To, typename From>472 template <typename From, typename To> 471 473 class DigraphCopy { 472 474 private: … … 483 485 typedef typename From::template ArcMap<TArc> ArcRefMap; 484 486 485 486 487 public: 487 488 488 489 /// \brief Constructor for the DigraphCopy. 490 /// 491 /// It copies the content of the \c _from digraph into the 492 /// \c _to digraph. 493 DigraphCopy(To& to, const From& from) 489 /// \brief Constructor of DigraphCopy. 490 /// 491 /// Constructor of DigraphCopy for copying the content of the 492 /// \c from digraph into the \c to digraph. 493 DigraphCopy(const From& from, To& to) 494 494 : _from(from), _to(to) {} 495 495 496 /// \brief Destructor of theDigraphCopy497 /// 498 /// Destructor of the DigraphCopy496 /// \brief Destructor of DigraphCopy 497 /// 498 /// Destructor of DigraphCopy. 499 499 ~DigraphCopy() { 500 500 for (int i = 0; i < int(_node_maps.size()); ++i) { … … 507 507 } 508 508 509 /// \brief Cop iesthe node references into the given map.510 /// 511 /// Copies the node references into the given map. The parameter512 /// should be a map, which key type is the Node type of the source513 /// graph, while the value type is the Node type of the514 /// destination graph.509 /// \brief Copy the node references into the given map. 510 /// 511 /// This function copies the node references into the given map. 512 /// The parameter should be a map, whose key type is the Node type of 513 /// the source digraph, while the value type is the Node type of the 514 /// destination digraph. 515 515 template <typename NodeRef> 516 516 DigraphCopy& nodeRef(NodeRef& map) { … … 520 520 } 521 521 522 /// \brief Cop iesthe node cross references into the given map.523 /// 524 /// Copies the node cross references (reverse references) into525 /// the given map. The parameter should be a map, whichkey type526 /// is the Node type of the destinationgraph, while the value type is527 /// the Node type of the sourcegraph.522 /// \brief Copy the node cross references into the given map. 523 /// 524 /// This function copies the node cross references (reverse references) 525 /// into the given map. The parameter should be a map, whose key type 526 /// is the Node type of the destination digraph, while the value type is 527 /// the Node type of the source digraph. 528 528 template <typename NodeCrossRef> 529 529 DigraphCopy& nodeCrossRef(NodeCrossRef& map) { … … 533 533 } 534 534 535 /// \brief Make copy of the given map. 536 /// 537 /// Makes copy of the given map for the newly created digraph. 538 /// The new map's key type is the destination graph's node type, 539 /// and the copied map's key type is the source graph's node type. 540 template <typename ToMap, typename FromMap> 541 DigraphCopy& nodeMap(ToMap& tmap, const FromMap& map) { 535 /// \brief Make a copy of the given node map. 536 /// 537 /// This function makes a copy of the given node map for the newly 538 /// created digraph. 539 /// The key type of the new map \c tmap should be the Node type of the 540 /// destination digraph, and the key type of the original map \c map 541 /// should be the Node type of the source digraph. 542 template <typename FromMap, typename ToMap> 543 DigraphCopy& nodeMap(const FromMap& map, ToMap& tmap) { 542 544 _node_maps.push_back(new _core_bits::MapCopy<From, Node, 543 NodeRefMap, ToMap, FromMap>(tmap,map));545 NodeRefMap, FromMap, ToMap>(map, tmap)); 544 546 return *this; 545 547 } … … 547 549 /// \brief Make a copy of the given node. 548 550 /// 549 /// Makea copy of the given node.550 DigraphCopy& node( TNode& tnode, const Node& snode) {551 /// This function makes a copy of the given node. 552 DigraphCopy& node(const Node& node, TNode& tnode) { 551 553 _node_maps.push_back(new _core_bits::ItemCopy<From, Node, 552 NodeRefMap, TNode>(tnode, snode)); 553 return *this; 554 } 555 556 /// \brief Copies the arc references into the given map. 557 /// 558 /// Copies the arc references into the given map. 554 NodeRefMap, TNode>(node, tnode)); 555 return *this; 556 } 557 558 /// \brief Copy the arc references into the given map. 559 /// 560 /// This function copies the arc references into the given map. 561 /// The parameter should be a map, whose key type is the Arc type of 562 /// the source digraph, while the value type is the Arc type of the 563 /// destination digraph. 559 564 template <typename ArcRef> 560 565 DigraphCopy& arcRef(ArcRef& map) { … … 564 569 } 565 570 566 /// \brief Copies the arc cross references into the given map. 567 /// 568 /// Copies the arc cross references (reverse references) into 569 /// the given map. 571 /// \brief Copy the arc cross references into the given map. 572 /// 573 /// This function copies the arc cross references (reverse references) 574 /// into the given map. The parameter should be a map, whose key type 575 /// is the Arc type of the destination digraph, while the value type is 576 /// the Arc type of the source digraph. 570 577 template <typename ArcCrossRef> 571 578 DigraphCopy& arcCrossRef(ArcCrossRef& map) { … … 575 582 } 576 583 577 /// \brief Make copy of the given map. 578 /// 579 /// Makes copy of the given map for the newly created digraph. 580 /// The new map's key type is the to digraph's arc type, 581 /// and the copied map's key type is the from digraph's arc 582 /// type. 583 template <typename ToMap, typename FromMap> 584 DigraphCopy& arcMap(ToMap& tmap, const FromMap& map) { 584 /// \brief Make a copy of the given arc map. 585 /// 586 /// This function makes a copy of the given arc map for the newly 587 /// created digraph. 588 /// The key type of the new map \c tmap should be the Arc type of the 589 /// destination digraph, and the key type of the original map \c map 590 /// should be the Arc type of the source digraph. 591 template <typename FromMap, typename ToMap> 592 DigraphCopy& arcMap(const FromMap& map, ToMap& tmap) { 585 593 _arc_maps.push_back(new _core_bits::MapCopy<From, Arc, 586 ArcRefMap, ToMap, FromMap>(tmap,map));594 ArcRefMap, FromMap, ToMap>(map, tmap)); 587 595 return *this; 588 596 } … … 590 598 /// \brief Make a copy of the given arc. 591 599 /// 592 /// Makea copy of the given arc.593 DigraphCopy& arc( TArc& tarc, const Arc& sarc) {600 /// This function makes a copy of the given arc. 601 DigraphCopy& arc(const Arc& arc, TArc& tarc) { 594 602 _arc_maps.push_back(new _core_bits::ItemCopy<From, Arc, 595 ArcRefMap, TArc>(tarc, sarc)); 596 return *this; 597 } 598 599 /// \brief Executes the copies. 600 /// 601 /// Executes the copies. 603 ArcRefMap, TArc>(arc, tarc)); 604 return *this; 605 } 606 607 /// \brief Execute copying. 608 /// 609 /// This function executes the copying of the digraph along with the 610 /// copying of the assigned data. 602 611 void run() { 603 612 NodeRefMap nodeRefMap(_from); 604 613 ArcRefMap arcRefMap(_from); 605 614 _core_bits::DigraphCopySelector<To>:: 606 copy(_ to, _from, nodeRefMap, arcRefMap);615 copy(_from, _to, nodeRefMap, arcRefMap); 607 616 for (int i = 0; i < int(_node_maps.size()); ++i) { 608 617 _node_maps[i]->copy(_from, nodeRefMap); … … 615 624 protected: 616 625 617 618 626 const From& _from; 619 627 To& _to; 620 628 621 629 std::vector<_core_bits::MapCopyBase<From, Node, NodeRefMap>* > 622 _node_maps;630 _node_maps; 623 631 624 632 std::vector<_core_bits::MapCopyBase<From, Arc, ArcRefMap>* > 625 _arc_maps;633 _arc_maps; 626 634 627 635 }; … … 629 637 /// \brief Copy a digraph to another digraph. 630 638 /// 631 /// Copy a digraph to another digraph. The complete usage of the632 /// function is detailed in the DigraphCopy class, but a short633 /// example shows a basic work:639 /// This function copies a digraph to another digraph. 640 /// The complete usage of it is detailed in the DigraphCopy class, but 641 /// a short example shows a basic work: 634 642 ///\code 635 /// copyDigraph(trg, src).nodeRef(nr).arcCrossRef(ecr).run();643 /// digraphCopy(src, trg).nodeRef(nr).arcCrossRef(acr).run(); 636 644 ///\endcode 637 645 /// 638 646 /// After the copy the \c nr map will contain the mapping from the 639 647 /// nodes of the \c from digraph to the nodes of the \c to digraph and 640 /// \c ecr will contain the mapping from the arcs of the \c to digraph648 /// \c acr will contain the mapping from the arcs of the \c to digraph 641 649 /// to the arcs of the \c from digraph. 642 650 /// 643 651 /// \see DigraphCopy 644 template <typename To, typename From>645 DigraphCopy< To, From> copyDigraph(To& to, const From& from) {646 return DigraphCopy< To, From>(to, from);652 template <typename From, typename To> 653 DigraphCopy<From, To> digraphCopy(const From& from, To& to) { 654 return DigraphCopy<From, To>(from, to); 647 655 } 648 656 … … 650 658 /// 651 659 /// Class to copy a graph to another graph (duplicate a graph). The 652 /// simplest way of using it is through the \c copyGraph() function.653 /// 654 /// This class not justmake a copy of a graph, but it can create660 /// simplest way of using it is through the \c graphCopy() function. 661 /// 662 /// This class not only make a copy of a graph, but it can create 655 663 /// references and cross references between the nodes, edges and arcs of 656 /// the two graphs, it can copy maps for usewith the newly created657 /// graph and copy nodes, edges and arcs.664 /// the two graphs, and it can copy maps for using with the newly created 665 /// graph. 658 666 /// 659 667 /// To make a copy from a graph, first an instance of GraphCopy … … 664 672 /// The next code copies a graph with several data: 665 673 ///\code 666 /// GraphCopy< NewGraph, OrigGraph> dc(new_graph, orig_graph);667 /// // create a referencefor the nodes674 /// GraphCopy<OrigGraph, NewGraph> cg(orig_graph, new_graph); 675 /// // Create references for the nodes 668 676 /// OrigGraph::NodeMap<NewGraph::Node> nr(orig_graph); 669 /// dc.nodeRef(nr);670 /// // create a cross reference(inverse) for the edges671 /// NewGraph::EdgeMap<OrigGraph:: Arc> ecr(new_graph);672 /// dc.edgeCrossRef(ecr);673 /// // copy an arcmap674 /// OrigGraph:: ArcMap<double> oamap(orig_graph);675 /// NewGraph:: ArcMap<double> namap(new_graph);676 /// dc.arcMap(namap, oamap);677 /// // copy a node677 /// cg.nodeRef(nr); 678 /// // Create cross references (inverse) for the edges 679 /// NewGraph::EdgeMap<OrigGraph::Edge> ecr(new_graph); 680 /// cg.edgeCrossRef(ecr); 681 /// // Copy an edge map 682 /// OrigGraph::EdgeMap<double> oemap(orig_graph); 683 /// NewGraph::EdgeMap<double> nemap(new_graph); 684 /// cg.edgeMap(oemap, nemap); 685 /// // Copy a node 678 686 /// OrigGraph::Node on; 679 687 /// NewGraph::Node nn; 680 /// dc.node(nn, on);681 /// // Execut ions of copy682 /// dc.run();688 /// cg.node(on, nn); 689 /// // Execute copying 690 /// cg.run(); 683 691 ///\endcode 684 template <typename To, typename From>692 template <typename From, typename To> 685 693 class GraphCopy { 686 694 private: … … 701 709 702 710 struct ArcRefMap { 703 ArcRefMap(const To& to, const From& from,711 ArcRefMap(const From& from, const To& to, 704 712 const EdgeRefMap& edge_ref, const NodeRefMap& node_ref) 705 : _ to(to), _from(from),713 : _from(from), _to(to), 706 714 _edge_ref(edge_ref), _node_ref(node_ref) {} 707 715 … … 717 725 } 718 726 727 const From& _from; 719 728 const To& _to; 720 const From& _from;721 729 const EdgeRefMap& _edge_ref; 722 730 const NodeRefMap& _node_ref; 723 731 }; 724 732 725 726 733 public: 727 734 728 729 /// \brief Constructor for the GraphCopy. 730 /// 731 /// It copies the content of the \c _from graph into the 732 /// \c _to graph. 733 GraphCopy(To& to, const From& from) 735 /// \brief Constructor of GraphCopy. 736 /// 737 /// Constructor of GraphCopy for copying the content of the 738 /// \c from graph into the \c to graph. 739 GraphCopy(const From& from, To& to) 734 740 : _from(from), _to(to) {} 735 741 736 /// \brief Destructor of theGraphCopy737 /// 738 /// Destructor of the GraphCopy742 /// \brief Destructor of GraphCopy 743 /// 744 /// Destructor of GraphCopy. 739 745 ~GraphCopy() { 740 746 for (int i = 0; i < int(_node_maps.size()); ++i) { … … 747 753 delete _edge_maps[i]; 748 754 } 749 750 } 751 752 /// \brief Copies the node references into the given map. 753 /// 754 /// Copies the node references into the given map. 755 } 756 757 /// \brief Copy the node references into the given map. 758 /// 759 /// This function copies the node references into the given map. 760 /// The parameter should be a map, whose key type is the Node type of 761 /// the source graph, while the value type is the Node type of the 762 /// destination graph. 755 763 template <typename NodeRef> 756 764 GraphCopy& nodeRef(NodeRef& map) { … … 760 768 } 761 769 762 /// \brief Copies the node cross references into the given map. 763 /// 764 /// Copies the node cross references (reverse references) into 765 /// the given map. 770 /// \brief Copy the node cross references into the given map. 771 /// 772 /// This function copies the node cross references (reverse references) 773 /// into the given map. The parameter should be a map, whose key type 774 /// is the Node type of the destination graph, while the value type is 775 /// the Node type of the source graph. 766 776 template <typename NodeCrossRef> 767 777 GraphCopy& nodeCrossRef(NodeCrossRef& map) { … … 771 781 } 772 782 773 /// \brief Make copy of the given map. 774 /// 775 /// Makes copy of the given map for the newly created graph. 776 /// The new map's key type is the to graph's node type, 777 /// and the copied map's key type is the from graph's node 778 /// type. 779 template <typename ToMap, typename FromMap> 780 GraphCopy& nodeMap(ToMap& tmap, const FromMap& map) { 783 /// \brief Make a copy of the given node map. 784 /// 785 /// This function makes a copy of the given node map for the newly 786 /// created graph. 787 /// The key type of the new map \c tmap should be the Node type of the 788 /// destination graph, and the key type of the original map \c map 789 /// should be the Node type of the source graph. 790 template <typename FromMap, typename ToMap> 791 GraphCopy& nodeMap(const FromMap& map, ToMap& tmap) { 781 792 _node_maps.push_back(new _core_bits::MapCopy<From, Node, 782 NodeRefMap, ToMap, FromMap>(tmap,map));793 NodeRefMap, FromMap, ToMap>(map, tmap)); 783 794 return *this; 784 795 } … … 786 797 /// \brief Make a copy of the given node. 787 798 /// 788 /// Makea copy of the given node.789 GraphCopy& node( TNode& tnode, const Node& snode) {799 /// This function makes a copy of the given node. 800 GraphCopy& node(const Node& node, TNode& tnode) { 790 801 _node_maps.push_back(new _core_bits::ItemCopy<From, Node, 791 NodeRefMap, TNode>(tnode, snode)); 792 return *this; 793 } 794 795 /// \brief Copies the arc references into the given map. 796 /// 797 /// Copies the arc references into the given map. 802 NodeRefMap, TNode>(node, tnode)); 803 return *this; 804 } 805 806 /// \brief Copy the arc references into the given map. 807 /// 808 /// This function copies the arc references into the given map. 809 /// The parameter should be a map, whose key type is the Arc type of 810 /// the source graph, while the value type is the Arc type of the 811 /// destination graph. 798 812 template <typename ArcRef> 799 813 GraphCopy& arcRef(ArcRef& map) { … … 803 817 } 804 818 805 /// \brief Copies the arc cross references into the given map. 806 /// 807 /// Copies the arc cross references (reverse references) into 808 /// the given map. 819 /// \brief Copy the arc cross references into the given map. 820 /// 821 /// This function copies the arc cross references (reverse references) 822 /// into the given map. The parameter should be a map, whose key type 823 /// is the Arc type of the destination graph, while the value type is 824 /// the Arc type of the source graph. 809 825 template <typename ArcCrossRef> 810 826 GraphCopy& arcCrossRef(ArcCrossRef& map) { … … 814 830 } 815 831 816 /// \brief Make copy of the given map. 817 /// 818 /// Makes copy of the given map for the newly created graph. 819 /// The new map's key type is the to graph's arc type, 820 /// and the copied map's key type is the from graph's arc 821 /// type. 822 template <typename ToMap, typename FromMap> 823 GraphCopy& arcMap(ToMap& tmap, const FromMap& map) { 832 /// \brief Make a copy of the given arc map. 833 /// 834 /// This function makes a copy of the given arc map for the newly 835 /// created graph. 836 /// The key type of the new map \c tmap should be the Arc type of the 837 /// destination graph, and the key type of the original map \c map 838 /// should be the Arc type of the source graph. 839 template <typename FromMap, typename ToMap> 840 GraphCopy& arcMap(const FromMap& map, ToMap& tmap) { 824 841 _arc_maps.push_back(new _core_bits::MapCopy<From, Arc, 825 ArcRefMap, ToMap, FromMap>(tmap,map));842 ArcRefMap, FromMap, ToMap>(map, tmap)); 826 843 return *this; 827 844 } … … 829 846 /// \brief Make a copy of the given arc. 830 847 /// 831 /// Makea copy of the given arc.832 GraphCopy& arc( TArc& tarc, const Arc& sarc) {848 /// This function makes a copy of the given arc. 849 GraphCopy& arc(const Arc& arc, TArc& tarc) { 833 850 _arc_maps.push_back(new _core_bits::ItemCopy<From, Arc, 834 ArcRefMap, TArc>(tarc, sarc)); 835 return *this; 836 } 837 838 /// \brief Copies the edge references into the given map. 839 /// 840 /// Copies the edge references into the given map. 851 ArcRefMap, TArc>(arc, tarc)); 852 return *this; 853 } 854 855 /// \brief Copy the edge references into the given map. 856 /// 857 /// This function copies the edge references into the given map. 858 /// The parameter should be a map, whose key type is the Edge type of 859 /// the source graph, while the value type is the Edge type of the 860 /// destination graph. 841 861 template <typename EdgeRef> 842 862 GraphCopy& edgeRef(EdgeRef& map) { … … 846 866 } 847 867 848 /// \brief Copies the edge cross references into the given map. 849 /// 850 /// Copies the edge cross references (reverse 851 /// references) into the given map. 868 /// \brief Copy the edge cross references into the given map. 869 /// 870 /// This function copies the edge cross references (reverse references) 871 /// into the given map. The parameter should be a map, whose key type 872 /// is the Edge type of the destination graph, while the value type is 873 /// the Edge type of the source graph. 852 874 template <typename EdgeCrossRef> 853 875 GraphCopy& edgeCrossRef(EdgeCrossRef& map) { … … 857 879 } 858 880 859 /// \brief Make copy of the given map. 860 /// 861 /// Makes copy of the given map for the newly created graph. 862 /// The new map's key type is the to graph's edge type, 863 /// and the copied map's key type is the from graph's edge 864 /// type. 865 template <typename ToMap, typename FromMap> 866 GraphCopy& edgeMap(ToMap& tmap, const FromMap& map) { 881 /// \brief Make a copy of the given edge map. 882 /// 883 /// This function makes a copy of the given edge map for the newly 884 /// created graph. 885 /// The key type of the new map \c tmap should be the Edge type of the 886 /// destination graph, and the key type of the original map \c map 887 /// should be the Edge type of the source graph. 888 template <typename FromMap, typename ToMap> 889 GraphCopy& edgeMap(const FromMap& map, ToMap& tmap) { 867 890 _edge_maps.push_back(new _core_bits::MapCopy<From, Edge, 868 EdgeRefMap, ToMap, FromMap>(tmap,map));891 EdgeRefMap, FromMap, ToMap>(map, tmap)); 869 892 return *this; 870 893 } … … 872 895 /// \brief Make a copy of the given edge. 873 896 /// 874 /// Makea copy of the given edge.875 GraphCopy& edge( TEdge& tedge, const Edge& sedge) {897 /// This function makes a copy of the given edge. 898 GraphCopy& edge(const Edge& edge, TEdge& tedge) { 876 899 _edge_maps.push_back(new _core_bits::ItemCopy<From, Edge, 877 EdgeRefMap, TEdge>(tedge, sedge)); 878 return *this; 879 } 880 881 /// \brief Executes the copies. 882 /// 883 /// Executes the copies. 900 EdgeRefMap, TEdge>(edge, tedge)); 901 return *this; 902 } 903 904 /// \brief Execute copying. 905 /// 906 /// This function executes the copying of the graph along with the 907 /// copying of the assigned data. 884 908 void run() { 885 909 NodeRefMap nodeRefMap(_from); 886 910 EdgeRefMap edgeRefMap(_from); 887 ArcRefMap arcRefMap(_ to, _from, edgeRefMap, nodeRefMap);911 ArcRefMap arcRefMap(_from, _to, edgeRefMap, nodeRefMap); 888 912 _core_bits::GraphCopySelector<To>:: 889 copy(_ to, _from, nodeRefMap, edgeRefMap);913 copy(_from, _to, nodeRefMap, edgeRefMap); 890 914 for (int i = 0; i < int(_node_maps.size()); ++i) { 891 915 _node_maps[i]->copy(_from, nodeRefMap); … … 905 929 906 930 std::vector<_core_bits::MapCopyBase<From, Node, NodeRefMap>* > 907 _node_maps;931 _node_maps; 908 932 909 933 std::vector<_core_bits::MapCopyBase<From, Arc, ArcRefMap>* > 910 _arc_maps;934 _arc_maps; 911 935 912 936 std::vector<_core_bits::MapCopyBase<From, Edge, EdgeRefMap>* > 913 _edge_maps;937 _edge_maps; 914 938 915 939 }; … … 917 941 /// \brief Copy a graph to another graph. 918 942 /// 919 /// Copy a graph to another graph. The complete usage of the920 /// function is detailed in the GraphCopy class, but a short921 /// example shows a basic work:943 /// This function copies a graph to another graph. 944 /// The complete usage of it is detailed in the GraphCopy class, 945 /// but a short example shows a basic work: 922 946 ///\code 923 /// copyGraph(trg, src).nodeRef(nr).arcCrossRef(ecr).run();947 /// graphCopy(src, trg).nodeRef(nr).edgeCrossRef(ecr).run(); 924 948 ///\endcode 925 949 /// 926 950 /// After the copy the \c nr map will contain the mapping from the 927 951 /// nodes of the \c from graph to the nodes of the \c to graph and 928 /// \c ecr will contain the mapping from the arcs of the \c to graph929 /// to the arcs of the \c from graph.952 /// \c ecr will contain the mapping from the edges of the \c to graph 953 /// to the edges of the \c from graph. 930 954 /// 931 955 /// \see GraphCopy 932 template <typename To, typename From>933 GraphCopy< To, From>934 copyGraph(To& to, const From& from) {935 return GraphCopy< To, From>(to, from);956 template <typename From, typename To> 957 GraphCopy<From, To> 958 graphCopy(const From& from, To& to) { 959 return GraphCopy<From, To>(from, to); 936 960 } 937 961 … … 958 982 struct FindArcSelector< 959 983 Graph, 960 typename enable_if<typename Graph::Find EdgeTag, void>::type>984 typename enable_if<typename Graph::FindArcTag, void>::type> 961 985 { 962 986 typedef typename Graph::Node Node; … … 968 992 } 969 993 970 /// \brief Finds an arc between two nodes of a graph. 971 /// 972 /// Finds an arc from node \c u to node \c v in graph \c g. 994 /// \brief Find an arc between two nodes of a digraph. 995 /// 996 /// This function finds an arc from node \c u to node \c v in the 997 /// digraph \c g. 973 998 /// 974 999 /// If \c prev is \ref INVALID (this is the default value), then … … 979 1004 /// Thus you can iterate through each arc from \c u to \c v as it follows. 980 1005 ///\code 981 /// for(Arc e =findArc(g,u,v);e!=INVALID;e=findArc(g,u,v,e)) {1006 /// for(Arc e = findArc(g,u,v); e != INVALID; e = findArc(g,u,v,e)) { 982 1007 /// ... 983 1008 /// } 984 1009 ///\endcode 985 1010 /// 986 /// \sa ArcLookUp987 /// \sa AllArcLookUp988 /// \sa DynArcLookUp1011 /// \note \ref ConArcIt provides iterator interface for the same 1012 /// functionality. 1013 /// 989 1014 ///\sa ConArcIt 1015 ///\sa ArcLookUp, AllArcLookUp, DynArcLookUp 990 1016 template <typename Graph> 991 1017 inline typename Graph::Arc … … 995 1021 } 996 1022 997 /// \brief Iterator for iterating on arcs connectedthe same nodes.998 /// 999 /// Iterator for iterating on arcs connectedthe same nodes. It is1000 /// higher level interface for thefindArc() function. You can1023 /// \brief Iterator for iterating on parallel arcs connecting the same nodes. 1024 /// 1025 /// Iterator for iterating on parallel arcs connecting the same nodes. It is 1026 /// a higher level interface for the \ref findArc() function. You can 1001 1027 /// use it the following way: 1002 1028 ///\code … … 1007 1033 /// 1008 1034 ///\sa findArc() 1009 ///\sa ArcLookUp 1010 ///\sa AllArcLookUp 1011 ///\sa DynArcLookUp 1035 ///\sa ArcLookUp, AllArcLookUp, DynArcLookUp 1012 1036 template <typename _Graph> 1013 1037 class ConArcIt : public _Graph::Arc { … … 1022 1046 /// \brief Constructor. 1023 1047 /// 1024 /// Construct a new ConArcIt iterating on the arcs which1025 /// connects the \c u and \c v node.1048 /// Construct a new ConArcIt iterating on the arcs that 1049 /// connects nodes \c u and \c v. 1026 1050 ConArcIt(const Graph& g, Node u, Node v) : _graph(g) { 1027 1051 Parent::operator=(findArc(_graph, u, v)); … … 1030 1054 /// \brief Constructor. 1031 1055 /// 1032 /// Construct a new ConArcIt which continues the iterating from 1033 /// the \c e arc. 1056 /// Construct a new ConArcIt that continues the iterating from arc \c a. 1034 1057 ConArcIt(const Graph& g, Arc a) : Parent(a), _graph(g) {} 1035 1058 … … 1092 1115 } 1093 1116 1094 /// \brief Find san edge between two nodes of a graph.1095 /// 1096 /// Finds an edge from node \c u to node \c v in graph \c g.1097 /// If thenode \c u and node \c v is equal then each loop edge1117 /// \brief Find an edge between two nodes of a graph. 1118 /// 1119 /// This function finds an edge from node \c u to node \c v in graph \c g. 1120 /// If node \c u and node \c v is equal then each loop edge 1098 1121 /// will be enumerated once. 1099 1122 /// 1100 1123 /// If \c prev is \ref INVALID (this is the default value), then 1101 /// it finds the first arc from \c u to \c v. Otherwise it looks for 1102 /// the next arc from \c u to \c v after \c prev. 1103 /// \return The found arc or \ref INVALID if there is no such an arc. 1104 /// 1105 /// Thus you can iterate through each arc from \c u to \c v as it follows. 1124 /// it finds the first edge from \c u to \c v. Otherwise it looks for 1125 /// the next edge from \c u to \c v after \c prev. 1126 /// \return The found edge or \ref INVALID if there is no such an edge. 1127 /// 1128 /// Thus you can iterate through each edge between \c u and \c v 1129 /// as it follows. 1106 1130 ///\code 1107 /// for(Edge e = findEdge(g,u,v); e != INVALID; 1108 /// e = findEdge(g,u,v,e)) { 1131 /// for(Edge e = findEdge(g,u,v); e != INVALID; e = findEdge(g,u,v,e)) { 1109 1132 /// ... 1110 1133 /// } 1111 1134 ///\endcode 1112 1135 /// 1136 /// \note \ref ConEdgeIt provides iterator interface for the same 1137 /// functionality. 1138 /// 1113 1139 ///\sa ConEdgeIt 1114 1115 1140 template <typename Graph> 1116 1141 inline typename Graph::Edge … … 1120 1145 } 1121 1146 1122 /// \brief Iterator for iterating on edges connectedthe same nodes.1123 /// 1124 /// Iterator for iterating on edges connected the same nodes. It is1125 /// higher level interface for the findEdge() function. You can1147 /// \brief Iterator for iterating on parallel edges connecting the same nodes. 1148 /// 1149 /// Iterator for iterating on parallel edges connecting the same nodes. 1150 /// It is a higher level interface for the findEdge() function. You can 1126 1151 /// use it the following way: 1127 1152 ///\code 1128 /// for (ConEdgeIt<Graph> it(g, src, trg); it != INVALID; ++it) {1153 /// for (ConEdgeIt<Graph> it(g, u, v); it != INVALID; ++it) { 1129 1154 /// ... 1130 1155 /// } … … 1144 1169 /// \brief Constructor. 1145 1170 /// 1146 /// Construct a new ConEdgeIt iterating on the edges which1147 /// connects the \c u and \c v node.1171 /// Construct a new ConEdgeIt iterating on the edges that 1172 /// connects nodes \c u and \c v. 1148 1173 ConEdgeIt(const Graph& g, Node u, Node v) : _graph(g) { 1149 1174 Parent::operator=(findEdge(_graph, u, v)); … … 1152 1177 /// \brief Constructor. 1153 1178 /// 1154 /// Construct a new ConEdgeIt which continues the iterating from 1155 /// the \c e edge. 1179 /// Construct a new ConEdgeIt that continues iterating from edge \c e. 1156 1180 ConEdgeIt(const Graph& g, Edge e) : Parent(e), _graph(g) {} 1157 1181 … … 1169 1193 1170 1194 1171 ///Dynamic arc look 1195 ///Dynamic arc look-up between given endpoints. 1172 1196 1173 1197 ///Using this class, you can find an arc in a digraph from a given 1174 ///source to a given target in amortized time <em>O (log</em>d<em>)</em>,1198 ///source to a given target in amortized time <em>O</em>(log<em>d</em>), 1175 1199 ///where <em>d</em> is the out-degree of the source node. 1176 1200 /// … … 1178 1202 ///the \c operator() member. 1179 1203 /// 1180 /// See the \ref ArcLookUp and \ref AllArcLookUp classes if your1181 /// digraph is not changed so frequently.1182 /// 1183 ///This class uses a self-adjusting binary search tree, Sleator's1184 /// and Tarjan's Splay tree forguarantee the logarithmic amortized1185 ///time bound for arc look ups. This class also guarantees the1204 ///This is a dynamic data structure. Consider to use \ref ArcLookUp or 1205 ///\ref AllArcLookUp if your digraph is not changed so frequently. 1206 /// 1207 ///This class uses a self-adjusting binary search tree, the Splay tree 1208 ///of Sleator and Tarjan to guarantee the logarithmic amortized 1209 ///time bound for arc look-ups. This class also guarantees the 1186 1210 ///optimal time bound in a constant factor for any distribution of 1187 1211 ///queries. … … 1508 1532 1509 1533 ///Find an arc between two nodes. 1510 ///\param s The source node 1511 ///\param t The target node 1534 ///\param s The source node. 1535 ///\param t The target node. 1512 1536 ///\param p The previous arc between \c s and \c t. It it is INVALID or 1513 1537 ///not given, the operator finds the first appropriate arc. … … 1520 1544 ///DynArcLookUp<ListDigraph> ae(g); 1521 1545 ///... 1522 ///int n =0;1523 ///for(Arc e=ae(u,v);e!=INVALID;e=ae(u,v,e)) n++;1546 ///int n = 0; 1547 ///for(Arc a = ae(u,v); a != INVALID; a = ae(u,v,a)) n++; 1524 1548 ///\endcode 1525 1549 /// 1526 ///Finding the arcs take at most <em>O (</em>log<em>d)</em>1550 ///Finding the arcs take at most <em>O</em>(log<em>d</em>) 1527 1551 ///amortized time, specifically, the time complexity of the lookups 1528 1552 ///is equal to the optimal search tree implementation for the … … 1530 1554 /// 1531 1555 ///\note This is a dynamic data structure, therefore the data 1532 ///structure is updated after each graph alteration. However,1533 ///th eoretically this data structure is faster than \cArcLookUp1534 /// or AllEdgeLookup, butit often provides worse performance than1556 ///structure is updated after each graph alteration. Thus although 1557 ///this data structure is theoretically faster than \ref ArcLookUp 1558 ///and \ref AllArcLookUp, it often provides worse performance than 1535 1559 ///them. 1536 ///1537 1560 Arc operator()(Node s, Node t, Arc p = INVALID) const { 1538 1561 if (p == INVALID) { … … 1586 1609 }; 1587 1610 1588 ///Fast arc look 1611 ///Fast arc look-up between given endpoints. 1589 1612 1590 1613 ///Using this class, you can find an arc in a digraph from a given 1591 ///source to a given target in time <em>O (log d)</em>,1614 ///source to a given target in time <em>O</em>(log<em>d</em>), 1592 1615 ///where <em>d</em> is the out-degree of the source node. 1593 1616 /// … … 1595 1618 ///Use \ref AllArcLookUp for this purpose. 1596 1619 /// 1597 ///\warning This class is static, so you should refresh() (or at least1598 /// refresh(Node)) this data structure1599 /// whenever the digraph changes. This is a time consuming (superlinearly1600 /// proportional (<em>O(m</em>log<em>m)</em>) to the number of arcs).1620 ///\warning This class is static, so you should call refresh() (or at 1621 ///least refresh(Node)) to refresh this data structure whenever the 1622 ///digraph changes. This is a time consuming (superlinearly proportional 1623 ///(<em>O</em>(<em>m</em> log<em>m</em>)) to the number of arcs). 1601 1624 /// 1602 1625 ///\tparam G The type of the underlying digraph. … … 1647 1670 } 1648 1671 public: 1649 ///Refresh the data structure at a node.1672 ///Refresh the search data structure at a node. 1650 1673 1651 1674 ///Build up the search database of node \c n. 1652 1675 /// 1653 ///It runs in time <em>O (d</em>log<em>d)</em>, where <em>d</em> is1654 /// the number of the outgoing arcs of \c n.1676 ///It runs in time <em>O</em>(<em>d</em> log<em>d</em>), where <em>d</em> 1677 ///is the number of the outgoing arcs of \c n. 1655 1678 void refresh(Node n) 1656 1679 { … … 1668 1691 ///\ref refresh(Node) "refresh(n)" for each node \c n. 1669 1692 /// 1670 ///It runs in time <em>O (m</em>log<em>D)</em>, where <em>m</em> is1671 ///the number of the arcs of \c nand <em>D</em> is the maximum1693 ///It runs in time <em>O</em>(<em>m</em> log<em>D</em>), where <em>m</em> is 1694 ///the number of the arcs in the digraph and <em>D</em> is the maximum 1672 1695 ///out-degree of the digraph. 1673 1674 1696 void refresh() 1675 1697 { … … 1679 1701 ///Find an arc between two nodes. 1680 1702 1681 ///Find an arc between two nodes in time <em>O (</em>log<em>d)</em>, where1682 /// <em>d</em> is the number of outgoing arcs of \c s.1683 ///\param s The source node 1684 ///\param t The target node 1703 ///Find an arc between two nodes in time <em>O</em>(log<em>d</em>), 1704 ///where <em>d</em> is the number of outgoing arcs of \c s. 1705 ///\param s The source node. 1706 ///\param t The target node. 1685 1707 ///\return An arc from \c s to \c t if there exists, 1686 1708 ///\ref INVALID otherwise. … … 1688 1710 ///\warning If you change the digraph, refresh() must be called before using 1689 1711 ///this operator. If you change the outgoing arcs of 1690 ///a single node \c n, then 1691 ///\ref refresh(Node) "refresh(n)" is enough. 1692 /// 1712 ///a single node \c n, then \ref refresh(Node) "refresh(n)" is enough. 1693 1713 Arc operator()(Node s, Node t) const 1694 1714 { … … 1702 1722 }; 1703 1723 1704 ///Fast look 1724 ///Fast look-up of all arcs between given endpoints. 1705 1725 1706 1726 ///This class is the same as \ref ArcLookUp, with the addition 1707 ///that it makes it possible to find all arcs between given endpoints. 1708 /// 1709 ///\warning This class is static, so you should refresh() (or at least 1710 ///refresh(Node)) this data structure 1711 ///whenever the digraph changes. This is a time consuming (superlinearly 1712 ///proportional (<em>O(m</em>log<em>m)</em>) to the number of arcs). 1727 ///that it makes it possible to find all parallel arcs between given 1728 ///endpoints. 1729 /// 1730 ///\warning This class is static, so you should call refresh() (or at 1731 ///least refresh(Node)) to refresh this data structure whenever the 1732 ///digraph changes. This is a time consuming (superlinearly proportional 1733 ///(<em>O</em>(<em>m</em> log<em>m</em>)) to the number of arcs). 1713 1734 /// 1714 1735 ///\tparam G The type of the underlying digraph. … … 1734 1755 else { 1735 1756 next=refreshNext(_right[head],next); 1736 // _next[head]=next;1737 1757 _next[head]=( next!=INVALID && _g.target(next)==_g.target(head)) 1738 1758 ? next : INVALID; … … 1759 1779 ///Build up the search database of node \c n. 1760 1780 /// 1761 ///It runs in time <em>O (d</em>log<em>d)</em>, where <em>d</em> is1781 ///It runs in time <em>O</em>(<em>d</em> log<em>d</em>), where <em>d</em> is 1762 1782 ///the number of the outgoing arcs of \c n. 1763 1764 1783 void refresh(Node n) 1765 1784 { … … 1773 1792 ///\ref refresh(Node) "refresh(n)" for each node \c n. 1774 1793 /// 1775 ///It runs in time <em>O (m</em>log<em>D)</em>, where <em>m</em> is1776 ///the number of the arcs of \c nand <em>D</em> is the maximum1794 ///It runs in time <em>O</em>(<em>m</em> log<em>D</em>), where <em>m</em> is 1795 ///the number of the arcs in the digraph and <em>D</em> is the maximum 1777 1796 ///out-degree of the digraph. 1778 1779 1797 void refresh() 1780 1798 { … … 1785 1803 1786 1804 ///Find an arc between two nodes. 1787 ///\param s The source node 1788 ///\param t The target node 1805 ///\param s The source node. 1806 ///\param t The target node. 1789 1807 ///\param prev The previous arc between \c s and \c t. It it is INVALID or 1790 1808 ///not given, the operator finds the first appropriate arc. … … 1797 1815 ///AllArcLookUp<ListDigraph> ae(g); 1798 1816 ///... 1799 ///int n =0;1800 ///for(Arc e=ae(u,v);e!=INVALID;e=ae(u,v,e)) n++;1817 ///int n = 0; 1818 ///for(Arc a = ae(u,v); a != INVALID; a=ae(u,v,a)) n++; 1801 1819 ///\endcode 1802 1820 /// 1803 ///Finding the first arc take <em>O (</em>log<em>d)</em> time, where1804 /// <em>d</em> is the number of outgoing arcs of \c s. Then,the1821 ///Finding the first arc take <em>O</em>(log<em>d</em>) time, 1822 ///where <em>d</em> is the number of outgoing arcs of \c s. Then the 1805 1823 ///consecutive arcs are found in constant time. 1806 1824 /// 1807 1825 ///\warning If you change the digraph, refresh() must be called before using 1808 1826 ///this operator. If you change the outgoing arcs of 1809 ///a single node \c n, then 1810 ///\ref refresh(Node) "refresh(n)" is enough. 1827 ///a single node \c n, then \ref refresh(Node) "refresh(n)" is enough. 1811 1828 /// 1812 1829 #ifdef DOXYGEN -
lemon/dfs.h
r247 r319 28 28 #include <lemon/core.h> 29 29 #include <lemon/error.h> 30 #include <lemon/assert.h>31 30 #include <lemon/maps.h> 31 #include <lemon/path.h> 32 32 33 33 namespace lemon { … … 50 50 ///It must meet the \ref concepts::WriteMap "WriteMap" concept. 51 51 typedef typename Digraph::template NodeMap<typename Digraph::Arc> PredMap; 52 ///Instantiates a \refPredMap.53 54 ///This function instantiates a \refPredMap.52 ///Instantiates a PredMap. 53 54 ///This function instantiates a PredMap. 55 55 ///\param g is the digraph, to which we would like to define the 56 ///\ref PredMap. 57 ///\todo The digraph alone may be insufficient to initialize 56 ///PredMap. 58 57 static PredMap *createPredMap(const Digraph &g) 59 58 { … … 65 64 ///The type of the map that indicates which nodes are processed. 66 65 ///It must meet the \ref concepts::WriteMap "WriteMap" concept. 67 ///By default it is a NullMap.68 66 typedef NullMap<typename Digraph::Node,bool> ProcessedMap; 69 ///Instantiates a \refProcessedMap.70 71 ///This function instantiates a \refProcessedMap.67 ///Instantiates a ProcessedMap. 68 69 ///This function instantiates a ProcessedMap. 72 70 ///\param g is the digraph, to which 73 ///we would like to define the \refProcessedMap71 ///we would like to define the ProcessedMap 74 72 #ifdef DOXYGEN 75 73 static ProcessedMap *createProcessedMap(const Digraph &g) … … 86 84 ///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept. 87 85 typedef typename Digraph::template NodeMap<bool> ReachedMap; 88 ///Instantiates a \refReachedMap.89 90 ///This function instantiates a \refReachedMap.86 ///Instantiates a ReachedMap. 87 88 ///This function instantiates a ReachedMap. 91 89 ///\param g is the digraph, to which 92 ///we would like to define the \refReachedMap.90 ///we would like to define the ReachedMap. 93 91 static ReachedMap *createReachedMap(const Digraph &g) 94 92 { … … 101 99 ///It must meet the \ref concepts::WriteMap "WriteMap" concept. 102 100 typedef typename Digraph::template NodeMap<int> DistMap; 103 ///Instantiates a \refDistMap.104 105 ///This function instantiates a \refDistMap.101 ///Instantiates a DistMap. 102 103 ///This function instantiates a DistMap. 106 104 ///\param g is the digraph, to which we would like to define the 107 /// \refDistMap.105 ///DistMap. 108 106 static DistMap *createDistMap(const Digraph &g) 109 107 { … … 117 115 ///This class provides an efficient implementation of the %DFS algorithm. 118 116 /// 119 ///There is also a \ref dfs() "function 117 ///There is also a \ref dfs() "function-type interface" for the DFS 120 118 ///algorithm, which is convenient in the simplier cases and it can be 121 119 ///used easier. … … 138 136 class Dfs { 139 137 public: 140 ///\ref Exception for uninitialized parameters.141 142 ///This error represents problems in the initialization of the143 ///parameters of the algorithm.144 class UninitializedParameter : public lemon::UninitializedParameter {145 public:146 virtual const char* what() const throw() {147 return "lemon::Dfs::UninitializedParameter";148 }149 };150 138 151 139 ///The type of the digraph the algorithm runs on. … … 196 184 int _stack_head; 197 185 198 ///Creates the maps if necessary. 199 ///\todo Better memory allocation (instead of new). 186 //Creates the maps if necessary. 200 187 void create_maps() 201 188 { … … 231 218 232 219 template <class T> 233 struct DefPredMapTraits : public Traits {220 struct SetPredMapTraits : public Traits { 234 221 typedef T PredMap; 235 222 static PredMap *createPredMap(const Digraph &) 236 223 { 237 throw UninitializedParameter(); 224 LEMON_ASSERT(false, "PredMap is not initialized"); 225 return 0; // ignore warnings 238 226 } 239 227 }; 240 228 ///\brief \ref named-templ-param "Named parameter" for setting 241 /// \refPredMap type.229 ///PredMap type. 242 230 /// 243 231 ///\ref named-templ-param "Named parameter" for setting 244 /// \refPredMap type.232 ///PredMap type. 245 233 template <class T> 246 struct DefPredMap : public Dfs<Digraph, DefPredMapTraits<T> > {247 typedef Dfs<Digraph, DefPredMapTraits<T> > Create;234 struct SetPredMap : public Dfs<Digraph, SetPredMapTraits<T> > { 235 typedef Dfs<Digraph, SetPredMapTraits<T> > Create; 248 236 }; 249 237 250 238 template <class T> 251 struct DefDistMapTraits : public Traits {239 struct SetDistMapTraits : public Traits { 252 240 typedef T DistMap; 253 241 static DistMap *createDistMap(const Digraph &) 254 242 { 255 throw UninitializedParameter(); 243 LEMON_ASSERT(false, "DistMap is not initialized"); 244 return 0; // ignore warnings 256 245 } 257 246 }; 258 247 ///\brief \ref named-templ-param "Named parameter" for setting 259 /// \refDistMap type.248 ///DistMap type. 260 249 /// 261 250 ///\ref named-templ-param "Named parameter" for setting 262 /// \refDistMap type.251 ///DistMap type. 263 252 template <class T> 264 struct DefDistMap : public Dfs< Digraph, DefDistMapTraits<T> > {265 typedef Dfs<Digraph, DefDistMapTraits<T> > Create;253 struct SetDistMap : public Dfs< Digraph, SetDistMapTraits<T> > { 254 typedef Dfs<Digraph, SetDistMapTraits<T> > Create; 266 255 }; 267 256 268 257 template <class T> 269 struct DefReachedMapTraits : public Traits {258 struct SetReachedMapTraits : public Traits { 270 259 typedef T ReachedMap; 271 260 static ReachedMap *createReachedMap(const Digraph &) 272 261 { 273 throw UninitializedParameter(); 262 LEMON_ASSERT(false, "ReachedMap is not initialized"); 263 return 0; // ignore warnings 274 264 } 275 265 }; 276 266 ///\brief \ref named-templ-param "Named parameter" for setting 277 /// \refReachedMap type.267 ///ReachedMap type. 278 268 /// 279 269 ///\ref named-templ-param "Named parameter" for setting 280 /// \refReachedMap type.270 ///ReachedMap type. 281 271 template <class T> 282 struct DefReachedMap : public Dfs< Digraph, DefReachedMapTraits<T> > {283 typedef Dfs< Digraph, DefReachedMapTraits<T> > Create;272 struct SetReachedMap : public Dfs< Digraph, SetReachedMapTraits<T> > { 273 typedef Dfs< Digraph, SetReachedMapTraits<T> > Create; 284 274 }; 285 275 286 276 template <class T> 287 struct DefProcessedMapTraits : public Traits {277 struct SetProcessedMapTraits : public Traits { 288 278 typedef T ProcessedMap; 289 279 static ProcessedMap *createProcessedMap(const Digraph &) 290 280 { 291 throw UninitializedParameter(); 281 LEMON_ASSERT(false, "ProcessedMap is not initialized"); 282 return 0; // ignore warnings 292 283 } 293 284 }; 294 285 ///\brief \ref named-templ-param "Named parameter" for setting 295 /// \refProcessedMap type.286 ///ProcessedMap type. 296 287 /// 297 288 ///\ref named-templ-param "Named parameter" for setting 298 /// \refProcessedMap type.289 ///ProcessedMap type. 299 290 template <class T> 300 struct DefProcessedMap : public Dfs< Digraph, DefProcessedMapTraits<T> > {301 typedef Dfs< Digraph, DefProcessedMapTraits<T> > Create;302 }; 303 304 struct DefDigraphProcessedMapTraits : public Traits {291 struct SetProcessedMap : public Dfs< Digraph, SetProcessedMapTraits<T> > { 292 typedef Dfs< Digraph, SetProcessedMapTraits<T> > Create; 293 }; 294 295 struct SetStandardProcessedMapTraits : public Traits { 305 296 typedef typename Digraph::template NodeMap<bool> ProcessedMap; 306 297 static ProcessedMap *createProcessedMap(const Digraph &g) … … 310 301 }; 311 302 ///\brief \ref named-templ-param "Named parameter" for setting 312 /// \refProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>.303 ///ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>. 313 304 /// 314 305 ///\ref named-templ-param "Named parameter" for setting 315 /// \refProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>.306 ///ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>. 316 307 ///If you don't set it explicitly, it will be automatically allocated. 317 template <class T> 318 struct DefProcessedMapToBeDefaultMap : 319 public Dfs< Digraph, DefDigraphProcessedMapTraits> { 320 typedef Dfs< Digraph, DefDigraphProcessedMapTraits> Create; 308 struct SetStandardProcessedMap : 309 public Dfs< Digraph, SetStandardProcessedMapTraits > { 310 typedef Dfs< Digraph, SetStandardProcessedMapTraits > Create; 321 311 }; 322 312 … … 559 549 /// 560 550 ///This method runs the %DFS algorithm from the root node 561 ///in order to compute the DFS path to \c dest.551 ///in order to compute the DFS path to \c t. 562 552 /// 563 553 ///The algorithm computes 564 ///- the %DFS path to \c dest,565 ///- the distance of \c dest from the root in the %DFS tree.554 ///- the %DFS path to \c t, 555 ///- the distance of \c t from the root in the %DFS tree. 566 556 /// 567 557 ///\pre init() must be called and a root node should be 568 558 ///added with addSource() before using this function. 569 void start(Node dest)570 { 571 while ( !emptyQueue() && G->target(_stack[_stack_head])!= dest )559 void start(Node t) 560 { 561 while ( !emptyQueue() && G->target(_stack[_stack_head])!=t ) 572 562 processNextArc(); 573 563 } … … 599 589 } 600 590 601 ///Runs the algorithm from the given node.591 ///Runs the algorithm from the given source node. 602 592 603 593 ///This method runs the %DFS algorithm from node \c s … … 623 613 624 614 ///This method runs the %DFS algorithm from node \c s 625 ///in order to compute the DFS path to \c t.626 /// 627 /// \return The length of the <tt>s</tt>--<tt>t</tt> DFS path,628 /// if \c t is reachable form \c s, \c 0 otherwise.615 ///in order to compute the DFS path to node \c t 616 ///(it stops searching when \c t is processed) 617 /// 618 ///\return \c true if \c t is reachable form \c s. 629 619 /// 630 620 ///\note Apart from the return value, <tt>d.run(s,t)</tt> is … …