24 /** |
24 /** |
25 @defgroup graphs Graph Structures |
25 @defgroup graphs Graph Structures |
26 @ingroup datas |
26 @ingroup datas |
27 \brief Graph structures implemented in LEMON. |
27 \brief Graph structures implemented in LEMON. |
28 |
28 |
29 The implementation of combinatorial algorithms heavily relies on |
29 The implementation of combinatorial algorithms heavily relies on |
30 efficient graph implementations. LEMON offers data structures which are |
30 efficient graph implementations. LEMON offers data structures which are |
31 planned to be easily used in an experimental phase of implementation studies, |
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. |
32 and thereafter the program code can be made efficient by small modifications. |
33 |
33 |
34 The most efficient implementation of diverse applications require the |
34 The most efficient implementation of diverse applications require the |
35 usage of different physical graph implementations. These differences |
35 usage of different physical graph implementations. These differences |
36 appear in the size of graph we require to handle, memory or time usage |
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 |
37 limitations or in the set of operations through which the graph can be |
38 accessed. LEMON provides several physical graph structures to meet |
38 accessed. LEMON provides several physical graph structures to meet |
39 the diverging requirements of the possible users. In order to save on |
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 |
40 running time or on memory usage, some structures may fail to provide |
41 some graph features like arc/edge or node deletion. |
41 some graph features like arc/edge or node deletion. |
42 |
42 |
43 Alteration of standard containers need a very limited number of |
43 Alteration of standard containers need a very limited number of |
44 operations, these together satisfy the everyday requirements. |
44 operations, these together satisfy the everyday requirements. |
45 In the case of graph structures, different operations are needed which do |
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 |
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 |
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 |
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 |
49 the residual graph can be accessed by another algorithm, or a node-set |
50 is to be shrunk for another algorithm. |
50 is to be shrunk for another algorithm. |
51 LEMON also provides a variety of graphs for these requirements called |
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 |
52 \ref graph_adaptors "graph adaptors". Adaptors cannot be used alone but only |
53 in conjunction with other graph representations. |
53 in conjunction with other graph representations. |
54 |
54 |
55 You are free to use the graph structure that fit your requirements |
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 |
56 the best, most graph algorithms and auxiliary data structures can be used |
57 with any graph structures. |
57 with any graph structures. |
58 */ |
58 */ |
59 |
59 |
60 /** |
60 /** |
61 @defgroup semi_adaptors Semi-Adaptor Classes for Graphs |
61 @defgroup semi_adaptors Semi-Adaptor Classes for Graphs |
62 @ingroup graphs |
62 @ingroup graphs |
63 \brief Graph types between real graphs and graph adaptors. |
63 \brief Graph types between real graphs and graph adaptors. |
64 |
64 |
65 This group describes some graph types between real graphs and graph adaptors. |
65 This group describes some graph types between real graphs and graph adaptors. |
66 These classes wrap graphs to give new functionality as the adaptors do it. |
66 These classes wrap graphs to give new functionality as the adaptors do it. |
67 On the other hand they are not light-weight structures as the adaptors. |
67 On the other hand they are not light-weight structures as the adaptors. |
68 */ |
68 */ |
69 |
69 |
70 /** |
70 /** |
71 @defgroup maps Maps |
71 @defgroup maps Maps |
72 @ingroup datas |
72 @ingroup datas |
73 \brief Map structures implemented in LEMON. |
73 \brief Map structures implemented in LEMON. |
74 |
74 |
75 This group describes the map structures implemented in LEMON. |
75 This group describes the map structures implemented in LEMON. |
76 |
76 |
77 LEMON provides several special purpose maps that e.g. combine |
77 LEMON provides several special purpose maps that e.g. combine |
78 new maps from existing ones. |
78 new maps from existing ones. |
79 */ |
79 */ |
80 |
80 |
81 /** |
81 /** |
82 @defgroup graph_maps Graph Maps |
82 @defgroup graph_maps Graph Maps |
83 @ingroup maps |
83 @ingroup maps |
84 \brief Special graph-related maps. |
84 \brief Special graph-related maps. |
85 |
85 |
86 This group describes maps that are specifically designed to assign |
86 This group describes maps that are specifically designed to assign |
87 values to the nodes and arcs of graphs. |
87 values to the nodes and arcs of graphs. |
113 return Color(1.0, 0.5, 1.0); |
113 return Color(1.0, 0.5, 1.0); |
114 } else { |
114 } else { |
115 return Color(0.0, 0.0, 0.0); |
115 return Color(0.0, 0.0, 0.0); |
116 } |
116 } |
117 } |
117 } |
118 |
118 |
119 Digraph::NodeMap<int> degree_map(graph); |
119 Digraph::NodeMap<int> degree_map(graph); |
120 |
120 |
121 digraphToEps(graph, "graph.eps") |
121 digraphToEps(graph, "graph.eps") |
122 .coords(coords).scaleToA4().undirected() |
122 .coords(coords).scaleToA4().undirected() |
123 .nodeColors(composeMap(functorToMap(nodeColor), degree_map)) |
123 .nodeColors(composeMap(functorToMap(nodeColor), degree_map)) |
124 .run(); |
124 .run(); |
125 \endcode |
125 \endcode |
126 The \c functorToMap() function makes an \c int to \c Color map from the |
126 The \c functorToMap() function makes an \c int to \c Color map from the |
127 \e nodeColor() function. The \c composeMap() compose the \e degree_map |
127 \e nodeColor() function. The \c composeMap() compose the \e degree_map |
128 and the previously created map. The composed map is a proper function to |
128 and the previously created map. The composed map is a proper function to |
129 get the color of each node. |
129 get the color of each node. |
130 |
130 |
138 DoubleArcMap length(graph); |
138 DoubleArcMap length(graph); |
139 DoubleArcMap speed(graph); |
139 DoubleArcMap speed(graph); |
140 |
140 |
141 typedef DivMap<DoubleArcMap, DoubleArcMap> TimeMap; |
141 typedef DivMap<DoubleArcMap, DoubleArcMap> TimeMap; |
142 TimeMap time(length, speed); |
142 TimeMap time(length, speed); |
143 |
143 |
144 Dijkstra<Digraph, TimeMap> dijkstra(graph, time); |
144 Dijkstra<Digraph, TimeMap> dijkstra(graph, time); |
145 dijkstra.run(source, target); |
145 dijkstra.run(source, target); |
146 \endcode |
146 \endcode |
147 We have a length map and a maximum speed map on the arcs of a digraph. |
147 We have a length map and a maximum speed map on the arcs of a digraph. |
148 The minimum time to pass the arc can be calculated as the division of |
148 The minimum time to pass the arc can be calculated as the division of |
229 \f[ 0 \le f_a \le c_a \f] |
229 \f[ 0 \le f_a \le c_a \f] |
230 \f[ \sum_{v\in\delta^{-}(u)}f_{vu}=\sum_{v\in\delta^{+}(u)}f_{uv} \qquad \forall u \in V \setminus \{s,t\}\f] |
230 \f[ \sum_{v\in\delta^{-}(u)}f_{vu}=\sum_{v\in\delta^{+}(u)}f_{uv} \qquad \forall u \in V \setminus \{s,t\}\f] |
231 \f[ \max \sum_{v\in\delta^{+}(s)}f_{uv} - \sum_{v\in\delta^{-}(s)}f_{vu}\f] |
231 \f[ \max \sum_{v\in\delta^{+}(s)}f_{uv} - \sum_{v\in\delta^{-}(s)}f_{vu}\f] |
232 |
232 |
233 LEMON contains several algorithms for solving maximum flow problems: |
233 LEMON contains several algorithms for solving maximum flow problems: |
234 - \ref lemon::EdmondsKarp "Edmonds-Karp" |
234 - \ref lemon::EdmondsKarp "Edmonds-Karp" |
235 - \ref lemon::Preflow "Goldberg's Preflow algorithm" |
235 - \ref lemon::Preflow "Goldberg's Preflow algorithm" |
236 - \ref lemon::DinitzSleatorTarjan "Dinitz's blocking flow algorithm with dynamic trees" |
236 - \ref lemon::DinitzSleatorTarjan "Dinitz's blocking flow algorithm with dynamic trees" |
237 - \ref lemon::GoldbergTarjan "Preflow algorithm with dynamic trees" |
237 - \ref lemon::GoldbergTarjan "Preflow algorithm with dynamic trees" |
238 |
238 |
239 In most cases the \ref lemon::Preflow "Preflow" algorithm provides the |
239 In most cases the \ref lemon::Preflow "Preflow" algorithm provides the |
305 \image html planar.png |
305 \image html planar.png |
306 \image latex planar.eps "Plane graph" width=\textwidth |
306 \image latex planar.eps "Plane graph" width=\textwidth |
307 */ |
307 */ |
308 |
308 |
309 /** |
309 /** |
310 @defgroup matching Matching algorithms |
310 @defgroup matching Matching algorithms |
311 @ingroup algs |
311 @ingroup algs |
312 \brief Algorithms for finding matchings in graphs and bipartite graphs. |
312 \brief Algorithms for finding matchings in graphs and bipartite graphs. |
313 |
313 |
314 This group contains algorithm objects and functions to calculate |
314 This group contains algorithm objects and functions to calculate |
315 matchings in graphs and bipartite graphs. The general matching problem is |
315 matchings in graphs and bipartite graphs. The general matching problem is |
316 finding a subset of the arcs which does not shares common endpoints. |
316 finding a subset of the arcs which does not shares common endpoints. |
317 |
317 |
318 There are several different algorithms for calculate matchings in |
318 There are several different algorithms for calculate matchings in |
319 graphs. The matching problems in bipartite graphs are generally |
319 graphs. The matching problems in bipartite graphs are generally |
320 easier than in general graphs. The goal of the matching optimization |
320 easier than in general graphs. The goal of the matching optimization |
321 can be the finding maximum cardinality, maximum weight or minimum cost |
321 can be the finding maximum cardinality, maximum weight or minimum cost |
322 matching. The search can be constrained to find perfect or |
322 matching. The search can be constrained to find perfect or |
323 maximum cardinality matching. |
323 maximum cardinality matching. |
324 |
324 |
325 Lemon contains the next algorithms: |
325 Lemon contains the next algorithms: |
326 - \ref lemon::MaxBipartiteMatching "MaxBipartiteMatching" Hopcroft-Karp |
326 - \ref lemon::MaxBipartiteMatching "MaxBipartiteMatching" Hopcroft-Karp |
327 augmenting path algorithm for calculate maximum cardinality matching in |
327 augmenting path algorithm for calculate maximum cardinality matching in |
328 bipartite graphs |
328 bipartite graphs |
329 - \ref lemon::PrBipartiteMatching "PrBipartiteMatching" Push-Relabel |
329 - \ref lemon::PrBipartiteMatching "PrBipartiteMatching" Push-Relabel |
330 algorithm for calculate maximum cardinality matching in bipartite graphs |
330 algorithm for calculate maximum cardinality matching in bipartite graphs |
331 - \ref lemon::MaxWeightedBipartiteMatching "MaxWeightedBipartiteMatching" |
331 - \ref lemon::MaxWeightedBipartiteMatching "MaxWeightedBipartiteMatching" |
332 Successive shortest path algorithm for calculate maximum weighted matching |
332 Successive shortest path algorithm for calculate maximum weighted matching |
333 and maximum weighted bipartite matching in bipartite graph |
333 and maximum weighted bipartite matching in bipartite graph |
334 - \ref lemon::MinCostMaxBipartiteMatching "MinCostMaxBipartiteMatching" |
334 - \ref lemon::MinCostMaxBipartiteMatching "MinCostMaxBipartiteMatching" |
335 Successive shortest path algorithm for calculate minimum cost maximum |
335 Successive shortest path algorithm for calculate minimum cost maximum |
336 matching in bipartite graph |
336 matching in bipartite graph |
337 - \ref lemon::MaxMatching "MaxMatching" Edmond's blossom shrinking algorithm |
337 - \ref lemon::MaxMatching "MaxMatching" Edmond's blossom shrinking algorithm |
338 for calculate maximum cardinality matching in general graph |
338 for calculate maximum cardinality matching in general graph |
339 - \ref lemon::MaxWeightedMatching "MaxWeightedMatching" Edmond's blossom |
339 - \ref lemon::MaxWeightedMatching "MaxWeightedMatching" Edmond's blossom |
340 shrinking algorithm for calculate maximum weighted matching in general |
340 shrinking algorithm for calculate maximum weighted matching in general |