1 /* -*- mode: C++; indent-tabs-mode: nil; -*-
3 * This file is a part of LEMON, a generic C++ optimization library.
5 * Copyright (C) 2003-2008
6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 * (Egervary Research Group on Combinatorial Optimization, EGRES).
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.
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
20 @defgroup datas Data Structures
21 This group describes the several data structures implemented in LEMON.
25 @defgroup graphs Graph Structures
27 \brief Graph structures implemented in LEMON.
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.
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
41 some graph features like arc/edge or node deletion.
43 Alteration of standard containers need a very limited number of
44 operations, these together satisfy the everyday requirements.
45 In the case of graph structures, different operations are needed which do
46 not alter the physical graph, but gives another view. If some nodes or
47 arcs have to be hidden or the reverse oriented graph have to be used, then
48 this is the case. It also may happen that in a flow implementation
49 the residual graph can be accessed by another algorithm, or a node-set
50 is to be shrunk for another algorithm.
51 LEMON also provides a variety of graphs for these requirements called
52 \ref graph_adaptors "graph adaptors". Adaptors cannot be used alone but only
53 in conjunction with other graph representations.
55 You are free to use the graph structure that fit your requirements
56 the best, most graph algorithms and auxiliary data structures can be used
57 with any graph structure.
59 <b>See also:</b> \ref graph_concepts "Graph Structure Concepts".
63 @defgroup graph_adaptors Adaptor Classes for graphs
65 \brief This group contains several adaptor classes for digraphs and graphs
67 The main parts of LEMON are the different graph structures, generic
68 graph algorithms, graph concepts which couple these, and graph
69 adaptors. While the previous notions are more or less clear, the
70 latter one needs further explanation. Graph adaptors are graph classes
71 which serve for considering graph structures in different ways.
73 A short example makes this much clearer. Suppose that we have an
74 instance \c g of a directed graph type say ListDigraph and an algorithm
76 template <typename Digraph>
77 int algorithm(const Digraph&);
79 is needed to run on the reverse oriented graph. It may be expensive
80 (in time or in memory usage) to copy \c g with the reversed
81 arcs. In this case, an adaptor class is used, which (according
82 to LEMON digraph concepts) works as a digraph. The adaptor uses the
83 original digraph structure and digraph operations when methods of the
84 reversed oriented graph are called. This means that the adaptor have
85 minor memory usage, and do not perform sophisticated algorithmic
86 actions. The purpose of it is to give a tool for the cases when a
87 graph have to be used in a specific alteration. If this alteration is
88 obtained by a usual construction like filtering the arc-set or
89 considering a new orientation, then an adaptor is worthwhile to use.
90 To come back to the reverse oriented graph, in this situation
92 template<typename Digraph> class ReverseDigraph;
94 template class can be used. The code looks as follows
97 ReverseDigraph<ListGraph> rg(g);
98 int result = algorithm(rg);
100 After running the algorithm, the original graph \c g is untouched.
101 This techniques gives rise to an elegant code, and based on stable
102 graph adaptors, complex algorithms can be implemented easily.
104 In flow, circulation and bipartite matching problems, the residual
105 graph is of particular importance. Combining an adaptor implementing
106 this, shortest path algorithms and minimum mean cycle algorithms,
107 a range of weighted and cardinality optimization algorithms can be
108 obtained. For other examples, the interested user is referred to the
109 detailed documentation of particular adaptors.
111 The behavior of graph adaptors can be very different. Some of them keep
112 capabilities of the original graph while in other cases this would be
113 meaningless. This means that the concepts that they are models of depend
114 on the graph adaptor, and the wrapped graph(s).
115 If an arc of \c rg is deleted, this is carried out by deleting the
116 corresponding arc of \c g, thus the adaptor modifies the original graph.
118 But for a residual graph, this operation has no sense.
119 Let us stand one more example here to simplify your work.
120 RevGraphAdaptor has constructor
122 ReverseDigraph(Digraph& digraph);
124 This means that in a situation, when a <tt>const ListDigraph&</tt>
125 reference to a graph is given, then it have to be instantiated with
126 <tt>Digraph=const ListDigraph</tt>.
128 int algorithm1(const ListDigraph& g) {
129 RevGraphAdaptor<const ListDigraph> rg(g);
130 return algorithm2(rg);
136 @defgroup semi_adaptors Semi-Adaptor Classes for Graphs
138 \brief Graph types between real graphs and graph adaptors.
140 This group describes some graph types between real graphs and graph adaptors.
141 These classes wrap graphs to give new functionality as the adaptors do it.
142 On the other hand they are not light-weight structures as the adaptors.
148 \brief Map structures implemented in LEMON.
150 This group describes the map structures implemented in LEMON.
152 LEMON provides several special purpose maps and map adaptors that e.g. combine
153 new maps from existing ones.
155 <b>See also:</b> \ref map_concepts "Map Concepts".
159 @defgroup graph_maps Graph Maps
161 \brief Special graph-related maps.
163 This group describes maps that are specifically designed to assign
164 values to the nodes and arcs of graphs.
168 \defgroup map_adaptors Map Adaptors
170 \brief Tools to create new maps from existing ones
172 This group describes map adaptors that are used to create "implicit"
173 maps from other maps.
175 Most of them are \ref lemon::concepts::ReadMap "read-only maps".
176 They can make arithmetic and logical operations between one or two maps
177 (negation, shifting, addition, multiplication, logical 'and', 'or',
178 'not' etc.) or e.g. convert a map to another one of different Value type.
180 The typical usage of this classes is passing implicit maps to
181 algorithms. If a function type algorithm is called then the function
182 type map adaptors can be used comfortable. For example let's see the
183 usage of map adaptors with the \c graphToEps() function.
185 Color nodeColor(int deg) {
187 return Color(0.5, 0.0, 0.5);
188 } else if (deg == 1) {
189 return Color(1.0, 0.5, 1.0);
191 return Color(0.0, 0.0, 0.0);
195 Digraph::NodeMap<int> degree_map(graph);
197 graphToEps(graph, "graph.eps")
198 .coords(coords).scaleToA4().undirected()
199 .nodeColors(composeMap(functorToMap(nodeColor), degree_map))
202 The \c functorToMap() function makes an \c int to \c Color map from the
203 \c nodeColor() function. The \c composeMap() compose the \c degree_map
204 and the previously created map. The composed map is a proper function to
205 get the color of each node.
207 The usage with class type algorithms is little bit harder. In this
208 case the function type map adaptors can not be used, because the
209 function map adaptors give back temporary objects.
213 typedef Digraph::ArcMap<double> DoubleArcMap;
214 DoubleArcMap length(graph);
215 DoubleArcMap speed(graph);
217 typedef DivMap<DoubleArcMap, DoubleArcMap> TimeMap;
218 TimeMap time(length, speed);
220 Dijkstra<Digraph, TimeMap> dijkstra(graph, time);
221 dijkstra.run(source, target);
223 We have a length map and a maximum speed map on the arcs of a digraph.
224 The minimum time to pass the arc can be calculated as the division of
225 the two maps which can be done implicitly with the \c DivMap template
226 class. We use the implicit minimum time map as the length map of the
227 \c Dijkstra algorithm.
231 @defgroup matrices Matrices
233 \brief Two dimensional data storages implemented in LEMON.
235 This group describes two dimensional data storages implemented in LEMON.
239 @defgroup paths Path Structures
241 \brief %Path structures implemented in LEMON.
243 This group describes the path structures implemented in LEMON.
245 LEMON provides flexible data structures to work with paths.
246 All of them have similar interfaces and they can be copied easily with
247 assignment operators and copy constructors. This makes it easy and
248 efficient to have e.g. the Dijkstra algorithm to store its result in
249 any kind of path structure.
251 \sa lemon::concepts::Path
255 @defgroup auxdat Auxiliary Data Structures
257 \brief Auxiliary data structures implemented in LEMON.
259 This group describes some data structures implemented in LEMON in
260 order to make it easier to implement combinatorial algorithms.
264 @defgroup algs Algorithms
265 \brief This group describes the several algorithms
266 implemented in LEMON.
268 This group describes the several algorithms
269 implemented in LEMON.
273 @defgroup search Graph Search
275 \brief Common graph search algorithms.
277 This group describes the common graph search algorithms like
278 Breadth-First Search (BFS) and Depth-First Search (DFS).
282 @defgroup shortest_path Shortest Path Algorithms
284 \brief Algorithms for finding shortest paths.
286 This group describes the algorithms for finding shortest paths in graphs.
290 @defgroup max_flow Maximum Flow Algorithms
292 \brief Algorithms for finding maximum flows.
294 This group describes the algorithms for finding maximum flows and
295 feasible circulations.
297 The maximum flow problem is to find a flow between a single source and
298 a single target that is maximum. Formally, there is a \f$G=(V,A)\f$
299 directed graph, an \f$c_a:A\rightarrow\mathbf{R}^+_0\f$ capacity
300 function and given \f$s, t \in V\f$ source and target node. The
301 maximum flow is the \f$f_a\f$ solution of the next optimization problem:
303 \f[ 0 \le f_a \le c_a \f]
304 \f[ \sum_{v\in\delta^{-}(u)}f_{vu}=\sum_{v\in\delta^{+}(u)}f_{uv}
305 \qquad \forall u \in V \setminus \{s,t\}\f]
306 \f[ \max \sum_{v\in\delta^{+}(s)}f_{uv} - \sum_{v\in\delta^{-}(s)}f_{vu}\f]
308 LEMON contains several algorithms for solving maximum flow problems:
309 - \ref lemon::EdmondsKarp "Edmonds-Karp"
310 - \ref lemon::Preflow "Goldberg's Preflow algorithm"
311 - \ref lemon::DinitzSleatorTarjan "Dinitz's blocking flow algorithm with dynamic trees"
312 - \ref lemon::GoldbergTarjan "Preflow algorithm with dynamic trees"
314 In most cases the \ref lemon::Preflow "Preflow" algorithm provides the
315 fastest method to compute the maximum flow. All impelementations
316 provides functions to query the minimum cut, which is the dual linear
317 programming problem of the maximum flow.
321 @defgroup min_cost_flow Minimum Cost Flow Algorithms
324 \brief Algorithms for finding minimum cost flows and circulations.
326 This group describes the algorithms for finding minimum cost flows and
331 @defgroup min_cut Minimum Cut Algorithms
334 \brief Algorithms for finding minimum cut in graphs.
336 This group describes the algorithms for finding minimum cut in graphs.
338 The minimum cut problem is to find a non-empty and non-complete
339 \f$X\f$ subset of the vertices with minimum overall capacity on
340 outgoing arcs. Formally, there is \f$G=(V,A)\f$ directed graph, an
341 \f$c_a:A\rightarrow\mathbf{R}^+_0\f$ capacity function. The minimum
342 cut is the \f$X\f$ solution of the next optimization problem:
344 \f[ \min_{X \subset V, X\not\in \{\emptyset, V\}}
345 \sum_{uv\in A, u\in X, v\not\in X}c_{uv}\f]
347 LEMON contains several algorithms related to minimum cut problems:
349 - \ref lemon::HaoOrlin "Hao-Orlin algorithm" to calculate minimum cut
351 - \ref lemon::NagamochiIbaraki "Nagamochi-Ibaraki algorithm" to
352 calculate minimum cut in undirected graphs
353 - \ref lemon::GomoryHuTree "Gomory-Hu tree computation" to calculate all
354 pairs minimum cut in undirected graphs
356 If you want to find minimum cut just between two distinict nodes,
357 please see the \ref max_flow "Maximum Flow page".
361 @defgroup graph_prop Connectivity and Other Graph Properties
363 \brief Algorithms for discovering the graph properties
365 This group describes the algorithms for discovering the graph properties
366 like connectivity, bipartiteness, euler property, simplicity etc.
368 \image html edge_biconnected_components.png
369 \image latex edge_biconnected_components.eps "bi-edge-connected components" width=\textwidth
373 @defgroup planar Planarity Embedding and Drawing
375 \brief Algorithms for planarity checking, embedding and drawing
377 This group describes the algorithms for planarity checking,
378 embedding and drawing.
380 \image html planar.png
381 \image latex planar.eps "Plane graph" width=\textwidth
385 @defgroup matching Matching Algorithms
387 \brief Algorithms for finding matchings in graphs and bipartite graphs.
389 This group contains algorithm objects and functions to calculate
390 matchings in graphs and bipartite graphs. The general matching problem is
391 finding a subset of the arcs which does not shares common endpoints.
393 There are several different algorithms for calculate matchings in
394 graphs. The matching problems in bipartite graphs are generally
395 easier than in general graphs. The goal of the matching optimization
396 can be the finding maximum cardinality, maximum weight or minimum cost
397 matching. The search can be constrained to find perfect or
398 maximum cardinality matching.
400 LEMON contains the next algorithms:
401 - \ref lemon::MaxBipartiteMatching "MaxBipartiteMatching" Hopcroft-Karp
402 augmenting path algorithm for calculate maximum cardinality matching in
404 - \ref lemon::PrBipartiteMatching "PrBipartiteMatching" Push-Relabel
405 algorithm for calculate maximum cardinality matching in bipartite graphs
406 - \ref lemon::MaxWeightedBipartiteMatching "MaxWeightedBipartiteMatching"
407 Successive shortest path algorithm for calculate maximum weighted matching
408 and maximum weighted bipartite matching in bipartite graph
409 - \ref lemon::MinCostMaxBipartiteMatching "MinCostMaxBipartiteMatching"
410 Successive shortest path algorithm for calculate minimum cost maximum
411 matching in bipartite graph
412 - \ref lemon::MaxMatching "MaxMatching" Edmond's blossom shrinking algorithm
413 for calculate maximum cardinality matching in general graph
414 - \ref lemon::MaxWeightedMatching "MaxWeightedMatching" Edmond's blossom
415 shrinking algorithm for calculate maximum weighted matching in general
417 - \ref lemon::MaxWeightedPerfectMatching "MaxWeightedPerfectMatching"
418 Edmond's blossom shrinking algorithm for calculate maximum weighted
419 perfect matching in general graph
421 \image html bipartite_matching.png
422 \image latex bipartite_matching.eps "Bipartite Matching" width=\textwidth
426 @defgroup spantree Minimum Spanning Tree Algorithms
428 \brief Algorithms for finding a minimum cost spanning tree in a graph.
430 This group describes the algorithms for finding a minimum cost spanning
435 @defgroup auxalg Auxiliary Algorithms
437 \brief Auxiliary algorithms implemented in LEMON.
439 This group describes some algorithms implemented in LEMON
440 in order to make it easier to implement complex algorithms.
444 @defgroup approx Approximation Algorithms
446 \brief Approximation algorithms.
448 This group describes the approximation and heuristic algorithms
449 implemented in LEMON.
453 @defgroup gen_opt_group General Optimization Tools
454 \brief This group describes some general optimization frameworks
455 implemented in LEMON.
457 This group describes some general optimization frameworks
458 implemented in LEMON.
462 @defgroup lp_group Lp and Mip Solvers
463 @ingroup gen_opt_group
464 \brief Lp and Mip solver interfaces for LEMON.
466 This group describes Lp and Mip solver interfaces for LEMON. The
467 various LP solvers could be used in the same manner with this
472 @defgroup lp_utils Tools for Lp and Mip Solvers
474 \brief Helper tools to the Lp and Mip solvers.
476 This group adds some helper tools to general optimization framework
477 implemented in LEMON.
481 @defgroup metah Metaheuristics
482 @ingroup gen_opt_group
483 \brief Metaheuristics for LEMON library.
485 This group describes some metaheuristic optimization tools.
489 @defgroup utils Tools and Utilities
490 \brief Tools and utilities for programming in LEMON
492 Tools and utilities for programming in LEMON.
496 @defgroup gutils Basic Graph Utilities
498 \brief Simple basic graph utilities.
500 This group describes some simple basic graph utilities.
504 @defgroup misc Miscellaneous Tools
506 \brief Tools for development, debugging and testing.
508 This group describes several useful tools for development,
509 debugging and testing.
513 @defgroup timecount Time Measuring and Counting
515 \brief Simple tools for measuring the performance of algorithms.
517 This group describes simple tools for measuring the performance
522 @defgroup exceptions Exceptions
524 \brief Exceptions defined in LEMON.
526 This group describes the exceptions defined in LEMON.
530 @defgroup io_group Input-Output
531 \brief Graph Input-Output methods
533 This group describes the tools for importing and exporting graphs
534 and graph related data. Now it supports the \ref lgf-format
535 "LEMON Graph Format", the \c DIMACS format and the encapsulated
536 postscript (EPS) format.
540 @defgroup lemon_io LEMON Graph Format
542 \brief Reading and writing LEMON Graph Format.
544 This group describes methods for reading and writing
545 \ref lgf-format "LEMON Graph Format".
549 @defgroup eps_io Postscript Exporting
551 \brief General \c EPS drawer and graph exporter
553 This group describes general \c EPS drawing methods and special
554 graph exporting tools.
558 @defgroup dimacs_group DIMACS format
560 \brief Read and write files in DIMACS format
562 Tools to read a digraph from or write it to a file in DIMACS format data.
566 @defgroup nauty_group NAUTY Format
568 \brief Read \e Nauty format
570 Tool to read graphs from \e Nauty format data.
574 @defgroup concept Concepts
575 \brief Skeleton classes and concept checking classes
577 This group describes the data/algorithm skeletons and concept checking
578 classes implemented in LEMON.
580 The purpose of the classes in this group is fourfold.
582 - These classes contain the documentations of the %concepts. In order
583 to avoid document multiplications, an implementation of a concept
584 simply refers to the corresponding concept class.
586 - These classes declare every functions, <tt>typedef</tt>s etc. an
587 implementation of the %concepts should provide, however completely
588 without implementations and real data structures behind the
589 interface. On the other hand they should provide nothing else. All
590 the algorithms working on a data structure meeting a certain concept
591 should compile with these classes. (Though it will not run properly,
592 of course.) In this way it is easily to check if an algorithm
593 doesn't use any extra feature of a certain implementation.
595 - The concept descriptor classes also provide a <em>checker class</em>
596 that makes it possible to check whether a certain implementation of a
597 concept indeed provides all the required features.
599 - Finally, They can serve as a skeleton of a new implementation of a concept.
603 @defgroup graph_concepts Graph Structure Concepts
605 \brief Skeleton and concept checking classes for graph structures
607 This group describes the skeletons and concept checking classes of LEMON's
608 graph structures and helper classes used to implement these.
612 @defgroup map_concepts Map Concepts
614 \brief Skeleton and concept checking classes for maps
616 This group describes the skeletons and concept checking classes of maps.
622 @defgroup demos Demo programs
624 Some demo programs are listed here. Their full source codes can be found in
625 the \c demo subdirectory of the source tree.
627 It order to compile them, use <tt>--enable-demo</tt> configure option when
632 @defgroup tools Standalone utility applications
634 Some utility applications are listed here.
636 The standard compilation procedure (<tt>./configure;make</tt>) will compile