lemongraph 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (161) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +8 -0
  3. data/LICENSE +674 -0
  4. data/README.md +6 -0
  5. data/ext/lemon-1.3.1/AUTHORS +26 -0
  6. data/ext/lemon-1.3.1/CMakeLists.txt +371 -0
  7. data/ext/lemon-1.3.1/INSTALL +167 -0
  8. data/ext/lemon-1.3.1/LICENSE +32 -0
  9. data/ext/lemon-1.3.1/NEWS +337 -0
  10. data/ext/lemon-1.3.1/README +50 -0
  11. data/ext/lemon-1.3.1/cmake/FindCOIN.cmake +110 -0
  12. data/ext/lemon-1.3.1/cmake/FindGLPK.cmake +55 -0
  13. data/ext/lemon-1.3.1/cmake/FindGhostscript.cmake +10 -0
  14. data/ext/lemon-1.3.1/cmake/FindILOG.cmake +102 -0
  15. data/ext/lemon-1.3.1/cmake/FindSOPLEX.cmake +23 -0
  16. data/ext/lemon-1.3.1/cmake/LEMONConfig.cmake.in +13 -0
  17. data/ext/lemon-1.3.1/cmake/nsis/lemon.ico +0 -0
  18. data/ext/lemon-1.3.1/cmake/nsis/uninstall.ico +0 -0
  19. data/ext/lemon-1.3.1/cmake/version.cmake +1 -0
  20. data/ext/lemon-1.3.1/cmake/version.cmake.in +1 -0
  21. data/ext/lemon-1.3.1/contrib/CMakeLists.txt +19 -0
  22. data/ext/lemon-1.3.1/lemon/CMakeLists.txt +91 -0
  23. data/ext/lemon-1.3.1/lemon/adaptors.h +3638 -0
  24. data/ext/lemon-1.3.1/lemon/arg_parser.cc +474 -0
  25. data/ext/lemon-1.3.1/lemon/arg_parser.h +440 -0
  26. data/ext/lemon-1.3.1/lemon/assert.h +214 -0
  27. data/ext/lemon-1.3.1/lemon/base.cc +37 -0
  28. data/ext/lemon-1.3.1/lemon/bellman_ford.h +1116 -0
  29. data/ext/lemon-1.3.1/lemon/bfs.h +1754 -0
  30. data/ext/lemon-1.3.1/lemon/bin_heap.h +347 -0
  31. data/ext/lemon-1.3.1/lemon/binomial_heap.h +445 -0
  32. data/ext/lemon-1.3.1/lemon/bits/alteration_notifier.h +472 -0
  33. data/ext/lemon-1.3.1/lemon/bits/array_map.h +351 -0
  34. data/ext/lemon-1.3.1/lemon/bits/bezier.h +174 -0
  35. data/ext/lemon-1.3.1/lemon/bits/default_map.h +182 -0
  36. data/ext/lemon-1.3.1/lemon/bits/edge_set_extender.h +627 -0
  37. data/ext/lemon-1.3.1/lemon/bits/enable_if.h +131 -0
  38. data/ext/lemon-1.3.1/lemon/bits/graph_adaptor_extender.h +401 -0
  39. data/ext/lemon-1.3.1/lemon/bits/graph_extender.h +1332 -0
  40. data/ext/lemon-1.3.1/lemon/bits/lock.h +65 -0
  41. data/ext/lemon-1.3.1/lemon/bits/map_extender.h +332 -0
  42. data/ext/lemon-1.3.1/lemon/bits/path_dump.h +177 -0
  43. data/ext/lemon-1.3.1/lemon/bits/solver_bits.h +194 -0
  44. data/ext/lemon-1.3.1/lemon/bits/traits.h +388 -0
  45. data/ext/lemon-1.3.1/lemon/bits/variant.h +494 -0
  46. data/ext/lemon-1.3.1/lemon/bits/vector_map.h +244 -0
  47. data/ext/lemon-1.3.1/lemon/bits/windows.cc +166 -0
  48. data/ext/lemon-1.3.1/lemon/bits/windows.h +44 -0
  49. data/ext/lemon-1.3.1/lemon/bucket_heap.h +594 -0
  50. data/ext/lemon-1.3.1/lemon/capacity_scaling.h +1014 -0
  51. data/ext/lemon-1.3.1/lemon/cbc.cc +460 -0
  52. data/ext/lemon-1.3.1/lemon/cbc.h +129 -0
  53. data/ext/lemon-1.3.1/lemon/christofides_tsp.h +254 -0
  54. data/ext/lemon-1.3.1/lemon/circulation.h +807 -0
  55. data/ext/lemon-1.3.1/lemon/clp.cc +464 -0
  56. data/ext/lemon-1.3.1/lemon/clp.h +164 -0
  57. data/ext/lemon-1.3.1/lemon/color.cc +44 -0
  58. data/ext/lemon-1.3.1/lemon/color.h +204 -0
  59. data/ext/lemon-1.3.1/lemon/concept_check.h +77 -0
  60. data/ext/lemon-1.3.1/lemon/concepts/bpgraph.h +1029 -0
  61. data/ext/lemon-1.3.1/lemon/concepts/digraph.h +491 -0
  62. data/ext/lemon-1.3.1/lemon/concepts/graph.h +788 -0
  63. data/ext/lemon-1.3.1/lemon/concepts/graph_components.h +2134 -0
  64. data/ext/lemon-1.3.1/lemon/concepts/heap.h +324 -0
  65. data/ext/lemon-1.3.1/lemon/concepts/maps.h +223 -0
  66. data/ext/lemon-1.3.1/lemon/concepts/path.h +312 -0
  67. data/ext/lemon-1.3.1/lemon/config.h.in +22 -0
  68. data/ext/lemon-1.3.1/lemon/connectivity.h +1688 -0
  69. data/ext/lemon-1.3.1/lemon/core.h +2506 -0
  70. data/ext/lemon-1.3.1/lemon/cost_scaling.h +1607 -0
  71. data/ext/lemon-1.3.1/lemon/counter.h +249 -0
  72. data/ext/lemon-1.3.1/lemon/cplex.cc +994 -0
  73. data/ext/lemon-1.3.1/lemon/cplex.h +292 -0
  74. data/ext/lemon-1.3.1/lemon/cycle_canceling.h +1230 -0
  75. data/ext/lemon-1.3.1/lemon/dfs.h +1637 -0
  76. data/ext/lemon-1.3.1/lemon/dheap.h +352 -0
  77. data/ext/lemon-1.3.1/lemon/dijkstra.h +1303 -0
  78. data/ext/lemon-1.3.1/lemon/dim2.h +726 -0
  79. data/ext/lemon-1.3.1/lemon/dimacs.h +448 -0
  80. data/ext/lemon-1.3.1/lemon/edge_set.h +1420 -0
  81. data/ext/lemon-1.3.1/lemon/edmonds_karp.h +556 -0
  82. data/ext/lemon-1.3.1/lemon/elevator.h +982 -0
  83. data/ext/lemon-1.3.1/lemon/error.h +276 -0
  84. data/ext/lemon-1.3.1/lemon/euler.h +287 -0
  85. data/ext/lemon-1.3.1/lemon/fib_heap.h +475 -0
  86. data/ext/lemon-1.3.1/lemon/fractional_matching.h +2139 -0
  87. data/ext/lemon-1.3.1/lemon/full_graph.h +1082 -0
  88. data/ext/lemon-1.3.1/lemon/glpk.cc +1012 -0
  89. data/ext/lemon-1.3.1/lemon/glpk.h +263 -0
  90. data/ext/lemon-1.3.1/lemon/gomory_hu.h +568 -0
  91. data/ext/lemon-1.3.1/lemon/graph_to_eps.h +1186 -0
  92. data/ext/lemon-1.3.1/lemon/greedy_tsp.h +251 -0
  93. data/ext/lemon-1.3.1/lemon/grid_graph.h +699 -0
  94. data/ext/lemon-1.3.1/lemon/grosso_locatelli_pullan_mc.h +840 -0
  95. data/ext/lemon-1.3.1/lemon/hao_orlin.h +1015 -0
  96. data/ext/lemon-1.3.1/lemon/hartmann_orlin_mmc.h +654 -0
  97. data/ext/lemon-1.3.1/lemon/howard_mmc.h +651 -0
  98. data/ext/lemon-1.3.1/lemon/hypercube_graph.h +459 -0
  99. data/ext/lemon-1.3.1/lemon/insertion_tsp.h +533 -0
  100. data/ext/lemon-1.3.1/lemon/karp_mmc.h +590 -0
  101. data/ext/lemon-1.3.1/lemon/kruskal.h +324 -0
  102. data/ext/lemon-1.3.1/lemon/lemon.pc.in +10 -0
  103. data/ext/lemon-1.3.1/lemon/lgf_reader.h +3854 -0
  104. data/ext/lemon-1.3.1/lemon/lgf_writer.h +2687 -0
  105. data/ext/lemon-1.3.1/lemon/list_graph.h +2510 -0
  106. data/ext/lemon-1.3.1/lemon/lp.h +95 -0
  107. data/ext/lemon-1.3.1/lemon/lp_base.cc +30 -0
  108. data/ext/lemon-1.3.1/lemon/lp_base.h +2147 -0
  109. data/ext/lemon-1.3.1/lemon/lp_skeleton.cc +143 -0
  110. data/ext/lemon-1.3.1/lemon/lp_skeleton.h +234 -0
  111. data/ext/lemon-1.3.1/lemon/maps.h +4057 -0
  112. data/ext/lemon-1.3.1/lemon/matching.h +3505 -0
  113. data/ext/lemon-1.3.1/lemon/math.h +77 -0
  114. data/ext/lemon-1.3.1/lemon/max_cardinality_search.h +794 -0
  115. data/ext/lemon-1.3.1/lemon/min_cost_arborescence.h +808 -0
  116. data/ext/lemon-1.3.1/lemon/nagamochi_ibaraki.h +702 -0
  117. data/ext/lemon-1.3.1/lemon/nauty_reader.h +113 -0
  118. data/ext/lemon-1.3.1/lemon/nearest_neighbor_tsp.h +238 -0
  119. data/ext/lemon-1.3.1/lemon/network_simplex.h +1659 -0
  120. data/ext/lemon-1.3.1/lemon/opt2_tsp.h +367 -0
  121. data/ext/lemon-1.3.1/lemon/pairing_heap.h +474 -0
  122. data/ext/lemon-1.3.1/lemon/path.h +1164 -0
  123. data/ext/lemon-1.3.1/lemon/planarity.h +2754 -0
  124. data/ext/lemon-1.3.1/lemon/preflow.h +985 -0
  125. data/ext/lemon-1.3.1/lemon/quad_heap.h +343 -0
  126. data/ext/lemon-1.3.1/lemon/radix_heap.h +438 -0
  127. data/ext/lemon-1.3.1/lemon/radix_sort.h +487 -0
  128. data/ext/lemon-1.3.1/lemon/random.cc +29 -0
  129. data/ext/lemon-1.3.1/lemon/random.h +1005 -0
  130. data/ext/lemon-1.3.1/lemon/smart_graph.h +1344 -0
  131. data/ext/lemon-1.3.1/lemon/soplex.cc +465 -0
  132. data/ext/lemon-1.3.1/lemon/soplex.h +158 -0
  133. data/ext/lemon-1.3.1/lemon/static_graph.h +476 -0
  134. data/ext/lemon-1.3.1/lemon/suurballe.h +776 -0
  135. data/ext/lemon-1.3.1/lemon/time_measure.h +610 -0
  136. data/ext/lemon-1.3.1/lemon/tolerance.h +242 -0
  137. data/ext/lemon-1.3.1/lemon/unionfind.h +1824 -0
  138. data/ext/lemon-1.3.1/scripts/unify-sources.sh +390 -0
  139. data/ext/lemon-1.3.1/scripts/valgrind-wrapper.sh +22 -0
  140. data/ext/lemongraph/arc_map.cc +1007 -0
  141. data/ext/lemongraph/digraph.cc +282 -0
  142. data/ext/lemongraph/digraph_arc.cc +153 -0
  143. data/ext/lemongraph/digraph_node.cc +277 -0
  144. data/ext/lemongraph/edge_map.cc +770 -0
  145. data/ext/lemongraph/extconf.rb +53 -0
  146. data/ext/lemongraph/graph.cc +351 -0
  147. data/ext/lemongraph/graph_arc.cc +95 -0
  148. data/ext/lemongraph/graph_edge.cc +153 -0
  149. data/ext/lemongraph/graph_item.cc +76 -0
  150. data/ext/lemongraph/graph_node.cc +321 -0
  151. data/ext/lemongraph/lemongraph.cc +260 -0
  152. data/ext/lemongraph/lemongraph.hh +295 -0
  153. data/ext/lemongraph/lemongraph.map +6 -0
  154. data/ext/lemongraph/lemongraph_export.hh +31 -0
  155. data/ext/lemongraph/node_map.cc +1011 -0
  156. data/lemongraph.gemspec +176 -0
  157. data/lib/lemongraph/graphviz.rb +240 -0
  158. data/lib/lemongraph/version.rb +4 -0
  159. data/lib/lemongraph.rb +21 -0
  160. data/samples/lemondeps.rb +38 -0
  161. metadata +202 -0
@@ -0,0 +1,324 @@
1
+ /* -*- mode: C++; indent-tabs-mode: nil; -*-
2
+ *
3
+ * This file is a part of LEMON, a generic C++ optimization library.
4
+ *
5
+ * Copyright (C) 2003-2013
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
+ #ifndef LEMON_CONCEPTS_HEAP_H
20
+ #define LEMON_CONCEPTS_HEAP_H
21
+
22
+ ///\ingroup concept
23
+ ///\file
24
+ ///\brief The concept of heaps.
25
+
26
+ #include <lemon/core.h>
27
+ #include <lemon/concept_check.h>
28
+
29
+ namespace lemon {
30
+
31
+ namespace concepts {
32
+
33
+ /// \addtogroup concept
34
+ /// @{
35
+
36
+ /// \brief The heap concept.
37
+ ///
38
+ /// This concept class describes the main interface of heaps.
39
+ /// The various \ref heaps "heap structures" are efficient
40
+ /// implementations of the abstract data type \e priority \e queue.
41
+ /// They store items with specified values called \e priorities
42
+ /// in such a way that finding and removing the item with minimum
43
+ /// priority are efficient. The basic operations are adding and
44
+ /// erasing items, changing the priority of an item, etc.
45
+ ///
46
+ /// Heaps are crucial in several algorithms, such as Dijkstra and Prim.
47
+ /// Any class that conforms to this concept can be used easily in such
48
+ /// algorithms.
49
+ ///
50
+ /// \tparam PR Type of the priorities of the items.
51
+ /// \tparam IM A read-writable item map with \c int values, used
52
+ /// internally to handle the cross references.
53
+ /// \tparam CMP A functor class for comparing the priorities.
54
+ /// The default is \c std::less<PR>.
55
+ #ifdef DOXYGEN
56
+ template <typename PR, typename IM, typename CMP>
57
+ #else
58
+ template <typename PR, typename IM, typename CMP = std::less<PR> >
59
+ #endif
60
+ class Heap {
61
+ public:
62
+
63
+ /// Type of the item-int map.
64
+ typedef IM ItemIntMap;
65
+ /// Type of the priorities.
66
+ typedef PR Prio;
67
+ /// Type of the items stored in the heap.
68
+ typedef typename ItemIntMap::Key Item;
69
+
70
+ /// \brief Type to represent the states of the items.
71
+ ///
72
+ /// Each item has a state associated to it. It can be "in heap",
73
+ /// "pre-heap" or "post-heap". The latter two are indifferent from the
74
+ /// heap's point of view, but may be useful to the user.
75
+ ///
76
+ /// The item-int map must be initialized in such way that it assigns
77
+ /// \c PRE_HEAP (<tt>-1</tt>) to any element to be put in the heap.
78
+ enum State {
79
+ IN_HEAP = 0, ///< = 0. The "in heap" state constant.
80
+ PRE_HEAP = -1, ///< = -1. The "pre-heap" state constant.
81
+ POST_HEAP = -2 ///< = -2. The "post-heap" state constant.
82
+ };
83
+
84
+ /// \brief Constructor.
85
+ ///
86
+ /// Constructor.
87
+ /// \param map A map that assigns \c int values to keys of type
88
+ /// \c Item. It is used internally by the heap implementations to
89
+ /// handle the cross references. The assigned value must be
90
+ /// \c PRE_HEAP (<tt>-1</tt>) for each item.
91
+ #ifdef DOXYGEN
92
+ explicit Heap(ItemIntMap &map) {}
93
+ #else
94
+ explicit Heap(ItemIntMap&) {}
95
+ #endif
96
+
97
+ /// \brief Constructor.
98
+ ///
99
+ /// Constructor.
100
+ /// \param map A map that assigns \c int values to keys of type
101
+ /// \c Item. It is used internally by the heap implementations to
102
+ /// handle the cross references. The assigned value must be
103
+ /// \c PRE_HEAP (<tt>-1</tt>) for each item.
104
+ /// \param comp The function object used for comparing the priorities.
105
+ #ifdef DOXYGEN
106
+ explicit Heap(ItemIntMap &map, const CMP &comp) {}
107
+ #else
108
+ explicit Heap(ItemIntMap&, const CMP&) {}
109
+ #endif
110
+
111
+ /// \brief The number of items stored in the heap.
112
+ ///
113
+ /// This function returns the number of items stored in the heap.
114
+ int size() const { return 0; }
115
+
116
+ /// \brief Check if the heap is empty.
117
+ ///
118
+ /// This function returns \c true if the heap is empty.
119
+ bool empty() const { return false; }
120
+
121
+ /// \brief Make the heap empty.
122
+ ///
123
+ /// This functon makes the heap empty.
124
+ /// It does not change the cross reference map. If you want to reuse
125
+ /// a heap that is not surely empty, you should first clear it and
126
+ /// then you should set the cross reference map to \c PRE_HEAP
127
+ /// for each item.
128
+ void clear() {}
129
+
130
+ /// \brief Insert an item into the heap with the given priority.
131
+ ///
132
+ /// This function inserts the given item into the heap with the
133
+ /// given priority.
134
+ /// \param i The item to insert.
135
+ /// \param p The priority of the item.
136
+ /// \pre \e i must not be stored in the heap.
137
+ #ifdef DOXYGEN
138
+ void push(const Item &i, const Prio &p) {}
139
+ #else
140
+ void push(const Item&, const Prio&) {}
141
+ #endif
142
+
143
+ /// \brief Return the item having minimum priority.
144
+ ///
145
+ /// This function returns the item having minimum priority.
146
+ /// \pre The heap must be non-empty.
147
+ Item top() const { return Item(); }
148
+
149
+ /// \brief The minimum priority.
150
+ ///
151
+ /// This function returns the minimum priority.
152
+ /// \pre The heap must be non-empty.
153
+ Prio prio() const { return Prio(); }
154
+
155
+ /// \brief Remove the item having minimum priority.
156
+ ///
157
+ /// This function removes the item having minimum priority.
158
+ /// \pre The heap must be non-empty.
159
+ void pop() {}
160
+
161
+ /// \brief Remove the given item from the heap.
162
+ ///
163
+ /// This function removes the given item from the heap if it is
164
+ /// already stored.
165
+ /// \param i The item to delete.
166
+ /// \pre \e i must be in the heap.
167
+ #ifdef DOXYGEN
168
+ void erase(const Item &i) {}
169
+ #else
170
+ void erase(const Item&) {}
171
+ #endif
172
+
173
+ /// \brief The priority of the given item.
174
+ ///
175
+ /// This function returns the priority of the given item.
176
+ /// \param i The item.
177
+ /// \pre \e i must be in the heap.
178
+ #ifdef DOXYGEN
179
+ Prio operator[](const Item &i) const {}
180
+ #else
181
+ Prio operator[](const Item&) const { return Prio(); }
182
+ #endif
183
+
184
+ /// \brief Set the priority of an item or insert it, if it is
185
+ /// not stored in the heap.
186
+ ///
187
+ /// This method sets the priority of the given item if it is
188
+ /// already stored in the heap. Otherwise it inserts the given
189
+ /// item into the heap with the given priority.
190
+ ///
191
+ /// \param i The item.
192
+ /// \param p The priority.
193
+ #ifdef DOXYGEN
194
+ void set(const Item &i, const Prio &p) {}
195
+ #else
196
+ void set(const Item&, const Prio&) {}
197
+ #endif
198
+
199
+ /// \brief Decrease the priority of an item to the given value.
200
+ ///
201
+ /// This function decreases the priority of an item to the given value.
202
+ /// \param i The item.
203
+ /// \param p The priority.
204
+ /// \pre \e i must be stored in the heap with priority at least \e p.
205
+ #ifdef DOXYGEN
206
+ void decrease(const Item &i, const Prio &p) {}
207
+ #else
208
+ void decrease(const Item&, const Prio&) {}
209
+ #endif
210
+
211
+ /// \brief Increase the priority of an item to the given value.
212
+ ///
213
+ /// This function increases the priority of an item to the given value.
214
+ /// \param i The item.
215
+ /// \param p The priority.
216
+ /// \pre \e i must be stored in the heap with priority at most \e p.
217
+ #ifdef DOXYGEN
218
+ void increase(const Item &i, const Prio &p) {}
219
+ #else
220
+ void increase(const Item&, const Prio&) {}
221
+ #endif
222
+
223
+ /// \brief Return the state of an item.
224
+ ///
225
+ /// This method returns \c PRE_HEAP if the given item has never
226
+ /// been in the heap, \c IN_HEAP if it is in the heap at the moment,
227
+ /// and \c POST_HEAP otherwise.
228
+ /// In the latter case it is possible that the item will get back
229
+ /// to the heap again.
230
+ /// \param i The item.
231
+ #ifdef DOXYGEN
232
+ State state(const Item &i) const {}
233
+ #else
234
+ State state(const Item&) const { return PRE_HEAP; }
235
+ #endif
236
+
237
+ /// \brief Set the state of an item in the heap.
238
+ ///
239
+ /// This function sets the state of the given item in the heap.
240
+ /// It can be used to manually clear the heap when it is important
241
+ /// to achive better time complexity.
242
+ /// \param i The item.
243
+ /// \param st The state. It should not be \c IN_HEAP.
244
+ #ifdef DOXYGEN
245
+ void state(const Item& i, State st) {}
246
+ #else
247
+ void state(const Item&, State) {}
248
+ #endif
249
+
250
+
251
+ template <typename _Heap>
252
+ struct Constraints {
253
+ public:
254
+ void constraints() {
255
+ typedef typename _Heap::Item OwnItem;
256
+ typedef typename _Heap::Prio OwnPrio;
257
+ typedef typename _Heap::State OwnState;
258
+
259
+ Item item;
260
+ Prio prio;
261
+ item=Item();
262
+ prio=Prio();
263
+ ::lemon::ignore_unused_variable_warning(item);
264
+ ::lemon::ignore_unused_variable_warning(prio);
265
+
266
+ OwnItem own_item;
267
+ OwnPrio own_prio;
268
+ OwnState own_state;
269
+ own_item=Item();
270
+ own_prio=Prio();
271
+ ::lemon::ignore_unused_variable_warning(own_item);
272
+ ::lemon::ignore_unused_variable_warning(own_prio);
273
+ ::lemon::ignore_unused_variable_warning(own_state);
274
+
275
+ _Heap heap1(map);
276
+ _Heap heap2 = heap1;
277
+ ::lemon::ignore_unused_variable_warning(heap1);
278
+ ::lemon::ignore_unused_variable_warning(heap2);
279
+
280
+ int s = heap.size();
281
+ ::lemon::ignore_unused_variable_warning(s);
282
+ bool e = heap.empty();
283
+ ::lemon::ignore_unused_variable_warning(e);
284
+
285
+ prio = heap.prio();
286
+ item = heap.top();
287
+ prio = heap[item];
288
+ own_prio = heap.prio();
289
+ own_item = heap.top();
290
+ own_prio = heap[own_item];
291
+
292
+ heap.push(item, prio);
293
+ heap.push(own_item, own_prio);
294
+ heap.pop();
295
+
296
+ heap.set(item, prio);
297
+ heap.decrease(item, prio);
298
+ heap.increase(item, prio);
299
+ heap.set(own_item, own_prio);
300
+ heap.decrease(own_item, own_prio);
301
+ heap.increase(own_item, own_prio);
302
+
303
+ heap.erase(item);
304
+ heap.erase(own_item);
305
+ heap.clear();
306
+
307
+ own_state = heap.state(own_item);
308
+ heap.state(own_item, own_state);
309
+
310
+ own_state = _Heap::PRE_HEAP;
311
+ own_state = _Heap::IN_HEAP;
312
+ own_state = _Heap::POST_HEAP;
313
+ }
314
+
315
+ _Heap& heap;
316
+ ItemIntMap& map;
317
+ Constraints() {}
318
+ };
319
+ };
320
+
321
+ /// @}
322
+ } // namespace lemon
323
+ }
324
+ #endif
@@ -0,0 +1,223 @@
1
+ /* -*- mode: C++; indent-tabs-mode: nil; -*-
2
+ *
3
+ * This file is a part of LEMON, a generic C++ optimization library.
4
+ *
5
+ * Copyright (C) 2003-2013
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
+ #ifndef LEMON_CONCEPTS_MAPS_H
20
+ #define LEMON_CONCEPTS_MAPS_H
21
+
22
+ #include <lemon/core.h>
23
+ #include <lemon/concept_check.h>
24
+
25
+ ///\ingroup map_concepts
26
+ ///\file
27
+ ///\brief The concept of maps.
28
+
29
+ namespace lemon {
30
+
31
+ namespace concepts {
32
+
33
+ /// \addtogroup map_concepts
34
+ /// @{
35
+
36
+ /// Readable map concept
37
+
38
+ /// Readable map concept.
39
+ ///
40
+ template<typename K, typename T>
41
+ class ReadMap
42
+ {
43
+ public:
44
+ /// The key type of the map.
45
+ typedef K Key;
46
+ /// \brief The value type of the map.
47
+ /// (The type of objects associated with the keys).
48
+ typedef T Value;
49
+
50
+ /// Returns the value associated with the given key.
51
+ Value operator[](const Key &) const {
52
+ return *(static_cast<Value *>(0)+1);
53
+ }
54
+
55
+ template<typename _ReadMap>
56
+ struct Constraints {
57
+ void constraints() {
58
+ Value val = m[key];
59
+ val = m[key];
60
+ typename _ReadMap::Value own_val = m[own_key];
61
+ own_val = m[own_key];
62
+
63
+ ::lemon::ignore_unused_variable_warning(key);
64
+ ::lemon::ignore_unused_variable_warning(val);
65
+ ::lemon::ignore_unused_variable_warning(own_key);
66
+ ::lemon::ignore_unused_variable_warning(own_val);
67
+ }
68
+ const Key& key;
69
+ const typename _ReadMap::Key& own_key;
70
+ const _ReadMap& m;
71
+ Constraints() {}
72
+ };
73
+
74
+ };
75
+
76
+
77
+ /// Writable map concept
78
+
79
+ /// Writable map concept.
80
+ ///
81
+ template<typename K, typename T>
82
+ class WriteMap
83
+ {
84
+ public:
85
+ /// The key type of the map.
86
+ typedef K Key;
87
+ /// \brief The value type of the map.
88
+ /// (The type of objects associated with the keys).
89
+ typedef T Value;
90
+
91
+ /// Sets the value associated with the given key.
92
+ void set(const Key &, const Value &) {}
93
+
94
+ /// Default constructor.
95
+ WriteMap() {}
96
+
97
+ template <typename _WriteMap>
98
+ struct Constraints {
99
+ void constraints() {
100
+ m.set(key, val);
101
+ m.set(own_key, own_val);
102
+
103
+ ::lemon::ignore_unused_variable_warning(key);
104
+ ::lemon::ignore_unused_variable_warning(val);
105
+ ::lemon::ignore_unused_variable_warning(own_key);
106
+ ::lemon::ignore_unused_variable_warning(own_val);
107
+ }
108
+ const Key& key;
109
+ const Value& val;
110
+ const typename _WriteMap::Key& own_key;
111
+ const typename _WriteMap::Value& own_val;
112
+ _WriteMap& m;
113
+ Constraints() {}
114
+ };
115
+ };
116
+
117
+ /// Read/writable map concept
118
+
119
+ /// Read/writable map concept.
120
+ ///
121
+ template<typename K, typename T>
122
+ class ReadWriteMap : public ReadMap<K,T>,
123
+ public WriteMap<K,T>
124
+ {
125
+ public:
126
+ /// The key type of the map.
127
+ typedef K Key;
128
+ /// \brief The value type of the map.
129
+ /// (The type of objects associated with the keys).
130
+ typedef T Value;
131
+
132
+ /// Returns the value associated with the given key.
133
+ Value operator[](const Key &) const {
134
+ Value *r = 0;
135
+ return *r;
136
+ }
137
+
138
+ /// Sets the value associated with the given key.
139
+ void set(const Key &, const Value &) {}
140
+
141
+ template<typename _ReadWriteMap>
142
+ struct Constraints {
143
+ void constraints() {
144
+ checkConcept<ReadMap<K, T>, _ReadWriteMap >();
145
+ checkConcept<WriteMap<K, T>, _ReadWriteMap >();
146
+ }
147
+ };
148
+ };
149
+
150
+
151
+ /// Dereferable map concept
152
+
153
+ /// Dereferable map concept.
154
+ ///
155
+ template<typename K, typename T, typename R, typename CR>
156
+ class ReferenceMap : public ReadWriteMap<K,T>
157
+ {
158
+ public:
159
+ /// Tag for reference maps.
160
+ typedef True ReferenceMapTag;
161
+ /// The key type of the map.
162
+ typedef K Key;
163
+ /// \brief The value type of the map.
164
+ /// (The type of objects associated with the keys).
165
+ typedef T Value;
166
+ /// The reference type of the map.
167
+ typedef R Reference;
168
+ /// The const reference type of the map.
169
+ typedef CR ConstReference;
170
+
171
+ public:
172
+
173
+ /// Returns a reference to the value associated with the given key.
174
+ Reference operator[](const Key &) {
175
+ Value *r = 0;
176
+ return *r;
177
+ }
178
+
179
+ /// Returns a const reference to the value associated with the given key.
180
+ ConstReference operator[](const Key &) const {
181
+ Value *r = 0;
182
+ return *r;
183
+ }
184
+
185
+ /// Sets the value associated with the given key.
186
+ void set(const Key &k,const Value &t) { operator[](k)=t; }
187
+
188
+ template<typename _ReferenceMap>
189
+ struct Constraints {
190
+ typename enable_if<typename _ReferenceMap::ReferenceMapTag, void>::type
191
+ constraints() {
192
+ checkConcept<ReadWriteMap<K, T>, _ReferenceMap >();
193
+ ref = m[key];
194
+ m[key] = val;
195
+ m[key] = ref;
196
+ m[key] = cref;
197
+ own_ref = m[own_key];
198
+ m[own_key] = own_val;
199
+ m[own_key] = own_ref;
200
+ m[own_key] = own_cref;
201
+ m[key] = m[own_key];
202
+ m[own_key] = m[key];
203
+ }
204
+ const Key& key;
205
+ Value& val;
206
+ Reference ref;
207
+ ConstReference cref;
208
+ const typename _ReferenceMap::Key& own_key;
209
+ typename _ReferenceMap::Value& own_val;
210
+ typename _ReferenceMap::Reference own_ref;
211
+ typename _ReferenceMap::ConstReference own_cref;
212
+ _ReferenceMap& m;
213
+ Constraints() {}
214
+ };
215
+ };
216
+
217
+ // @}
218
+
219
+ } //namespace concepts
220
+
221
+ } //namespace lemon
222
+
223
+ #endif