[209] | 1 | /* -*- mode: C++; indent-tabs-mode: nil; -*- |
---|
[40] | 2 | * |
---|
[209] | 3 | * This file is a part of LEMON, a generic C++ optimization library. |
---|
[40] | 4 | * |
---|
| 5 | * Copyright (C) 2003-2008 |
---|
| 6 | * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
---|
| 7 | * (Egervary Research Group on Combinatorial Optimization, EGRES). |
---|
| 8 | * |
---|
| 9 | * Permission to use, modify and distribute this software is granted |
---|
| 10 | * provided that this copyright notice appears in all copies. For |
---|
| 11 | * precise terms see the accompanying LICENSE file. |
---|
| 12 | * |
---|
| 13 | * This software is provided "AS IS" with no warranty of any kind, |
---|
| 14 | * express or implied, and with no claim as to its suitability for any |
---|
| 15 | * purpose. |
---|
| 16 | * |
---|
| 17 | */ |
---|
| 18 | |
---|
| 19 | /** |
---|
| 20 | @defgroup datas Data Structures |
---|
[50] | 21 | This group describes the several data structures implemented in LEMON. |
---|
[40] | 22 | */ |
---|
| 23 | |
---|
| 24 | /** |
---|
| 25 | @defgroup graphs Graph Structures |
---|
| 26 | @ingroup datas |
---|
| 27 | \brief Graph structures implemented in LEMON. |
---|
| 28 | |
---|
[209] | 29 | The implementation of combinatorial algorithms heavily relies on |
---|
| 30 | efficient graph implementations. LEMON offers data structures which are |
---|
| 31 | planned to be easily used in an experimental phase of implementation studies, |
---|
| 32 | and thereafter the program code can be made efficient by small modifications. |
---|
[40] | 33 | |
---|
| 34 | The most efficient implementation of diverse applications require the |
---|
| 35 | usage of different physical graph implementations. These differences |
---|
| 36 | appear in the size of graph we require to handle, memory or time usage |
---|
| 37 | limitations or in the set of operations through which the graph can be |
---|
| 38 | accessed. LEMON provides several physical graph structures to meet |
---|
| 39 | the diverging requirements of the possible users. In order to save on |
---|
| 40 | running time or on memory usage, some structures may fail to provide |
---|
[83] | 41 | some graph features like arc/edge or node deletion. |
---|
[40] | 42 | |
---|
| 43 | You are free to use the graph structure that fit your requirements |
---|
| 44 | the best, most graph algorithms and auxiliary data structures can be used |
---|
[209] | 45 | with any graph structures. |
---|
[40] | 46 | */ |
---|
| 47 | |
---|
| 48 | /** |
---|
[209] | 49 | @defgroup maps Maps |
---|
[40] | 50 | @ingroup datas |
---|
[50] | 51 | \brief Map structures implemented in LEMON. |
---|
[40] | 52 | |
---|
[50] | 53 | This group describes the map structures implemented in LEMON. |
---|
| 54 | |
---|
| 55 | LEMON provides several special purpose maps that e.g. combine |
---|
[40] | 56 | new maps from existing ones. |
---|
| 57 | */ |
---|
| 58 | |
---|
| 59 | /** |
---|
[209] | 60 | @defgroup graph_maps Graph Maps |
---|
[40] | 61 | @ingroup maps |
---|
[83] | 62 | \brief Special graph-related maps. |
---|
[40] | 63 | |
---|
[50] | 64 | This group describes maps that are specifically designed to assign |
---|
[83] | 65 | values to the nodes and arcs of graphs. |
---|
[40] | 66 | */ |
---|
| 67 | |
---|
| 68 | |
---|
| 69 | /** |
---|
| 70 | \defgroup map_adaptors Map Adaptors |
---|
| 71 | \ingroup maps |
---|
| 72 | \brief Tools to create new maps from existing ones |
---|
| 73 | |
---|
[50] | 74 | This group describes map adaptors that are used to create "implicit" |
---|
| 75 | maps from other maps. |
---|
[40] | 76 | |
---|
[83] | 77 | Most of them are \ref lemon::concepts::ReadMap "read-only maps". |
---|
| 78 | They can make arithmetic and logical operations between one or two maps |
---|
| 79 | (negation, shifting, addition, multiplication, logical 'and', 'or', |
---|
| 80 | 'not' etc.) or e.g. convert a map to another one of different Value type. |
---|
[40] | 81 | |
---|
[50] | 82 | The typical usage of this classes is passing implicit maps to |
---|
[40] | 83 | algorithms. If a function type algorithm is called then the function |
---|
| 84 | type map adaptors can be used comfortable. For example let's see the |
---|
[83] | 85 | usage of map adaptors with the \c digraphToEps() function. |
---|
[40] | 86 | \code |
---|
| 87 | Color nodeColor(int deg) { |
---|
| 88 | if (deg >= 2) { |
---|
| 89 | return Color(0.5, 0.0, 0.5); |
---|
| 90 | } else if (deg == 1) { |
---|
| 91 | return Color(1.0, 0.5, 1.0); |
---|
| 92 | } else { |
---|
| 93 | return Color(0.0, 0.0, 0.0); |
---|
| 94 | } |
---|
| 95 | } |
---|
[209] | 96 | |
---|
[83] | 97 | Digraph::NodeMap<int> degree_map(graph); |
---|
[209] | 98 | |
---|
[83] | 99 | digraphToEps(graph, "graph.eps") |
---|
[40] | 100 | .coords(coords).scaleToA4().undirected() |
---|
[83] | 101 | .nodeColors(composeMap(functorToMap(nodeColor), degree_map)) |
---|
[40] | 102 | .run(); |
---|
[209] | 103 | \endcode |
---|
[83] | 104 | The \c functorToMap() function makes an \c int to \c Color map from the |
---|
[40] | 105 | \e nodeColor() function. The \c composeMap() compose the \e degree_map |
---|
[83] | 106 | and the previously created map. The composed map is a proper function to |
---|
| 107 | get the color of each node. |
---|
[40] | 108 | |
---|
| 109 | The usage with class type algorithms is little bit harder. In this |
---|
| 110 | case the function type map adaptors can not be used, because the |
---|
[50] | 111 | function map adaptors give back temporary objects. |
---|
[40] | 112 | \code |
---|
[83] | 113 | Digraph graph; |
---|
| 114 | |
---|
| 115 | typedef Digraph::ArcMap<double> DoubleArcMap; |
---|
| 116 | DoubleArcMap length(graph); |
---|
| 117 | DoubleArcMap speed(graph); |
---|
| 118 | |
---|
| 119 | typedef DivMap<DoubleArcMap, DoubleArcMap> TimeMap; |
---|
[40] | 120 | TimeMap time(length, speed); |
---|
[209] | 121 | |
---|
[83] | 122 | Dijkstra<Digraph, TimeMap> dijkstra(graph, time); |
---|
[40] | 123 | dijkstra.run(source, target); |
---|
| 124 | \endcode |
---|
[83] | 125 | We have a length map and a maximum speed map on the arcs of a digraph. |
---|
| 126 | The minimum time to pass the arc can be calculated as the division of |
---|
| 127 | the two maps which can be done implicitly with the \c DivMap template |
---|
[40] | 128 | class. We use the implicit minimum time map as the length map of the |
---|
| 129 | \c Dijkstra algorithm. |
---|
| 130 | */ |
---|
| 131 | |
---|
| 132 | /** |
---|
| 133 | @defgroup paths Path Structures |
---|
| 134 | @ingroup datas |
---|
| 135 | \brief Path structures implemented in LEMON. |
---|
| 136 | |
---|
[50] | 137 | This group describes the path structures implemented in LEMON. |
---|
[40] | 138 | |
---|
[50] | 139 | LEMON provides flexible data structures to work with paths. |
---|
| 140 | All of them have similar interfaces and they can be copied easily with |
---|
| 141 | assignment operators and copy constructors. This makes it easy and |
---|
[40] | 142 | efficient to have e.g. the Dijkstra algorithm to store its result in |
---|
| 143 | any kind of path structure. |
---|
| 144 | |
---|
| 145 | \sa lemon::concepts::Path |
---|
| 146 | |
---|
| 147 | */ |
---|
| 148 | |
---|
| 149 | /** |
---|
| 150 | @defgroup auxdat Auxiliary Data Structures |
---|
| 151 | @ingroup datas |
---|
[50] | 152 | \brief Auxiliary data structures implemented in LEMON. |
---|
[40] | 153 | |
---|
[50] | 154 | This group describes some data structures implemented in LEMON in |
---|
[40] | 155 | order to make it easier to implement combinatorial algorithms. |
---|
| 156 | */ |
---|
| 157 | |
---|
| 158 | |
---|
| 159 | /** |
---|
| 160 | @defgroup algs Algorithms |
---|
| 161 | \brief This group describes the several algorithms |
---|
| 162 | implemented in LEMON. |
---|
| 163 | |
---|
| 164 | This group describes the several algorithms |
---|
| 165 | implemented in LEMON. |
---|
| 166 | */ |
---|
| 167 | |
---|
| 168 | /** |
---|
| 169 | @defgroup search Graph Search |
---|
| 170 | @ingroup algs |
---|
[50] | 171 | \brief Common graph search algorithms. |
---|
[40] | 172 | |
---|
[209] | 173 | This group describes the common graph search algorithms like |
---|
[50] | 174 | Breadth-first search (Bfs) and Depth-first search (Dfs). |
---|
[40] | 175 | */ |
---|
| 176 | |
---|
| 177 | /** |
---|
| 178 | @defgroup shortest_path Shortest Path algorithms |
---|
| 179 | @ingroup algs |
---|
[50] | 180 | \brief Algorithms for finding shortest paths. |
---|
[40] | 181 | |
---|
[50] | 182 | This group describes the algorithms for finding shortest paths in graphs. |
---|
[40] | 183 | */ |
---|
| 184 | |
---|
[209] | 185 | /** |
---|
[40] | 186 | @defgroup spantree Minimum Spanning Tree algorithms |
---|
| 187 | @ingroup algs |
---|
[50] | 188 | \brief Algorithms for finding a minimum cost spanning tree in a graph. |
---|
[40] | 189 | |
---|
[50] | 190 | This group describes the algorithms for finding a minimum cost spanning |
---|
[40] | 191 | tree in a graph |
---|
| 192 | */ |
---|
| 193 | |
---|
| 194 | /** |
---|
[209] | 195 | @defgroup utils Tools and Utilities |
---|
[50] | 196 | \brief Tools and utilities for programming in LEMON |
---|
[40] | 197 | |
---|
[50] | 198 | Tools and utilities for programming in LEMON. |
---|
[40] | 199 | */ |
---|
| 200 | |
---|
| 201 | /** |
---|
| 202 | @defgroup gutils Basic Graph Utilities |
---|
| 203 | @ingroup utils |
---|
[50] | 204 | \brief Simple basic graph utilities. |
---|
[40] | 205 | |
---|
| 206 | This group describes some simple basic graph utilities. |
---|
| 207 | */ |
---|
| 208 | |
---|
| 209 | /** |
---|
| 210 | @defgroup misc Miscellaneous Tools |
---|
| 211 | @ingroup utils |
---|
[50] | 212 | \brief Tools for development, debugging and testing. |
---|
| 213 | |
---|
| 214 | This group describes several useful tools for development, |
---|
[40] | 215 | debugging and testing. |
---|
| 216 | */ |
---|
| 217 | |
---|
| 218 | /** |
---|
| 219 | @defgroup timecount Time measuring and Counting |
---|
| 220 | @ingroup misc |
---|
[50] | 221 | \brief Simple tools for measuring the performance of algorithms. |
---|
| 222 | |
---|
| 223 | This group describes simple tools for measuring the performance |
---|
[40] | 224 | of algorithms. |
---|
| 225 | */ |
---|
| 226 | |
---|
| 227 | /** |
---|
| 228 | @defgroup exceptions Exceptions |
---|
| 229 | @ingroup utils |
---|
[50] | 230 | \brief Exceptions defined in LEMON. |
---|
| 231 | |
---|
| 232 | This group describes the exceptions defined in LEMON. |
---|
[40] | 233 | */ |
---|
| 234 | |
---|
| 235 | /** |
---|
| 236 | @defgroup io_group Input-Output |
---|
[50] | 237 | \brief Graph Input-Output methods |
---|
[40] | 238 | |
---|
[209] | 239 | This group describes the tools for importing and exporting graphs |
---|
[325] | 240 | and graph related data. Now it supports the LEMON format |
---|
| 241 | and the encapsulated postscript (EPS) format. |
---|
[40] | 242 | */ |
---|
| 243 | |
---|
| 244 | /** |
---|
[236] | 245 | @defgroup lemon_io LEMON Input-Output |
---|
[40] | 246 | @ingroup io_group |
---|
[236] | 247 | \brief Reading and writing \ref lgf-format "LEMON Graph Format". |
---|
[40] | 248 | |
---|
[210] | 249 | This group describes methods for reading and writing |
---|
[236] | 250 | \ref lgf-format "LEMON Graph Format". |
---|
[40] | 251 | */ |
---|
| 252 | |
---|
| 253 | /** |
---|
| 254 | @defgroup eps_io Postscript exporting |
---|
| 255 | @ingroup io_group |
---|
| 256 | \brief General \c EPS drawer and graph exporter |
---|
| 257 | |
---|
[50] | 258 | This group describes general \c EPS drawing methods and special |
---|
[209] | 259 | graph exporting tools. |
---|
[40] | 260 | */ |
---|
| 261 | |
---|
| 262 | |
---|
| 263 | /** |
---|
| 264 | @defgroup concept Concepts |
---|
| 265 | \brief Skeleton classes and concept checking classes |
---|
| 266 | |
---|
| 267 | This group describes the data/algorithm skeletons and concept checking |
---|
| 268 | classes implemented in LEMON. |
---|
| 269 | |
---|
| 270 | The purpose of the classes in this group is fourfold. |
---|
[209] | 271 | |
---|
[40] | 272 | - These classes contain the documentations of the concepts. In order |
---|
| 273 | to avoid document multiplications, an implementation of a concept |
---|
| 274 | simply refers to the corresponding concept class. |
---|
| 275 | |
---|
| 276 | - These classes declare every functions, <tt>typedef</tt>s etc. an |
---|
| 277 | implementation of the concepts should provide, however completely |
---|
| 278 | without implementations and real data structures behind the |
---|
| 279 | interface. On the other hand they should provide nothing else. All |
---|
| 280 | the algorithms working on a data structure meeting a certain concept |
---|
| 281 | should compile with these classes. (Though it will not run properly, |
---|
| 282 | of course.) In this way it is easily to check if an algorithm |
---|
| 283 | doesn't use any extra feature of a certain implementation. |
---|
| 284 | |
---|
| 285 | - The concept descriptor classes also provide a <em>checker class</em> |
---|
[50] | 286 | that makes it possible to check whether a certain implementation of a |
---|
[40] | 287 | concept indeed provides all the required features. |
---|
| 288 | |
---|
| 289 | - Finally, They can serve as a skeleton of a new implementation of a concept. |
---|
| 290 | |
---|
| 291 | */ |
---|
| 292 | |
---|
| 293 | |
---|
| 294 | /** |
---|
| 295 | @defgroup graph_concepts Graph Structure Concepts |
---|
| 296 | @ingroup concept |
---|
| 297 | \brief Skeleton and concept checking classes for graph structures |
---|
| 298 | |
---|
[50] | 299 | This group describes the skeletons and concept checking classes of LEMON's |
---|
[40] | 300 | graph structures and helper classes used to implement these. |
---|
| 301 | */ |
---|
| 302 | |
---|
| 303 | /** |
---|
| 304 | \anchor demoprograms |
---|
| 305 | |
---|
| 306 | @defgroup demos Demo programs |
---|
| 307 | |
---|
| 308 | Some demo programs are listed here. Their full source codes can be found in |
---|
| 309 | the \c demo subdirectory of the source tree. |
---|
| 310 | |
---|
[41] | 311 | It order to compile them, use <tt>--enable-demo</tt> configure option when |
---|
| 312 | build the library. |
---|
[40] | 313 | */ |
---|