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,65 @@
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_BITS_LOCK_H
20
+ #define LEMON_BITS_LOCK_H
21
+
22
+ #include <lemon/config.h>
23
+ #if defined(LEMON_USE_PTHREAD)
24
+ #include <pthread.h>
25
+ #elif defined(LEMON_USE_WIN32_THREADS)
26
+ #include <lemon/bits/windows.h>
27
+ #endif
28
+
29
+ namespace lemon {
30
+ namespace bits {
31
+
32
+ #if defined(LEMON_USE_PTHREAD)
33
+ class Lock {
34
+ public:
35
+ Lock() {
36
+ pthread_mutex_init(&_lock, 0);
37
+ }
38
+ ~Lock() {
39
+ pthread_mutex_destroy(&_lock);
40
+ }
41
+ void lock() {
42
+ pthread_mutex_lock(&_lock);
43
+ }
44
+ void unlock() {
45
+ pthread_mutex_unlock(&_lock);
46
+ }
47
+
48
+ private:
49
+ pthread_mutex_t _lock;
50
+ };
51
+ #elif defined(LEMON_USE_WIN32_THREADS)
52
+ class Lock : public WinLock {};
53
+ #else
54
+ class Lock {
55
+ public:
56
+ Lock() {}
57
+ ~Lock() {}
58
+ void lock() {}
59
+ void unlock() {}
60
+ };
61
+ #endif
62
+ }
63
+ }
64
+
65
+ #endif
@@ -0,0 +1,332 @@
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_BITS_MAP_EXTENDER_H
20
+ #define LEMON_BITS_MAP_EXTENDER_H
21
+
22
+ #include <iterator>
23
+
24
+ #include <lemon/bits/traits.h>
25
+
26
+ #include <lemon/concept_check.h>
27
+ #include <lemon/concepts/maps.h>
28
+
29
+ //\file
30
+ //\brief Extenders for iterable maps.
31
+
32
+ namespace lemon {
33
+
34
+ // \ingroup graphbits
35
+ //
36
+ // \brief Extender for maps
37
+ template <typename _Map>
38
+ class MapExtender : public _Map {
39
+ typedef _Map Parent;
40
+ typedef typename Parent::GraphType GraphType;
41
+
42
+ public:
43
+
44
+ typedef MapExtender Map;
45
+ typedef typename Parent::Key Item;
46
+
47
+ typedef typename Parent::Key Key;
48
+ typedef typename Parent::Value Value;
49
+ typedef typename Parent::Reference Reference;
50
+ typedef typename Parent::ConstReference ConstReference;
51
+
52
+ typedef typename Parent::ReferenceMapTag ReferenceMapTag;
53
+
54
+ class MapIt;
55
+ class ConstMapIt;
56
+
57
+ friend class MapIt;
58
+ friend class ConstMapIt;
59
+
60
+ public:
61
+
62
+ MapExtender(const GraphType& graph)
63
+ : Parent(graph) {}
64
+
65
+ MapExtender(const GraphType& graph, const Value& value)
66
+ : Parent(graph, value) {}
67
+
68
+ private:
69
+ MapExtender& operator=(const MapExtender& cmap) {
70
+ return operator=<MapExtender>(cmap);
71
+ }
72
+
73
+ template <typename CMap>
74
+ MapExtender& operator=(const CMap& cmap) {
75
+ Parent::operator=(cmap);
76
+ return *this;
77
+ }
78
+
79
+ public:
80
+ class MapIt : public Item {
81
+ typedef Item Parent;
82
+
83
+ public:
84
+
85
+ typedef typename Map::Value Value;
86
+
87
+ MapIt() : map(NULL) {}
88
+
89
+ MapIt(Invalid i) : Parent(i), map(NULL) {}
90
+
91
+ explicit MapIt(Map& _map) : map(&_map) {
92
+ map->notifier()->first(*this);
93
+ }
94
+
95
+ MapIt(const Map& _map, const Item& item)
96
+ : Parent(item), map(&_map) {}
97
+
98
+ MapIt& operator++() {
99
+ map->notifier()->next(*this);
100
+ return *this;
101
+ }
102
+
103
+ typename MapTraits<Map>::ConstReturnValue operator*() const {
104
+ return (*map)[*this];
105
+ }
106
+
107
+ typename MapTraits<Map>::ReturnValue operator*() {
108
+ return (*map)[*this];
109
+ }
110
+
111
+ void set(const Value& value) {
112
+ map->set(*this, value);
113
+ }
114
+
115
+ protected:
116
+ Map* map;
117
+
118
+ };
119
+
120
+ class ConstMapIt : public Item {
121
+ typedef Item Parent;
122
+
123
+ public:
124
+
125
+ typedef typename Map::Value Value;
126
+
127
+ ConstMapIt() : map(NULL) {}
128
+
129
+ ConstMapIt(Invalid i) : Parent(i), map(NULL) {}
130
+
131
+ explicit ConstMapIt(Map& _map) : map(&_map) {
132
+ map->notifier()->first(*this);
133
+ }
134
+
135
+ ConstMapIt(const Map& _map, const Item& item)
136
+ : Parent(item), map(_map) {}
137
+
138
+ ConstMapIt& operator++() {
139
+ map->notifier()->next(*this);
140
+ return *this;
141
+ }
142
+
143
+ typename MapTraits<Map>::ConstReturnValue operator*() const {
144
+ return map[*this];
145
+ }
146
+
147
+ protected:
148
+ const Map* map;
149
+ };
150
+
151
+ class ItemIt : public Item {
152
+ typedef Item Parent;
153
+
154
+ public:
155
+ ItemIt() : map(NULL) {}
156
+
157
+
158
+ ItemIt(Invalid i) : Parent(i), map(NULL) {}
159
+
160
+ explicit ItemIt(Map& _map) : map(&_map) {
161
+ map->notifier()->first(*this);
162
+ }
163
+
164
+ ItemIt(const Map& _map, const Item& item)
165
+ : Parent(item), map(&_map) {}
166
+
167
+ ItemIt& operator++() {
168
+ map->notifier()->next(*this);
169
+ return *this;
170
+ }
171
+
172
+ protected:
173
+ const Map* map;
174
+
175
+ };
176
+ };
177
+
178
+ // \ingroup graphbits
179
+ //
180
+ // \brief Extender for maps which use a subset of the items.
181
+ template <typename _Graph, typename _Map>
182
+ class SubMapExtender : public _Map {
183
+ typedef _Map Parent;
184
+ typedef _Graph GraphType;
185
+
186
+ public:
187
+
188
+ typedef SubMapExtender Map;
189
+ typedef typename Parent::Key Item;
190
+
191
+ typedef typename Parent::Key Key;
192
+ typedef typename Parent::Value Value;
193
+ typedef typename Parent::Reference Reference;
194
+ typedef typename Parent::ConstReference ConstReference;
195
+
196
+ typedef typename Parent::ReferenceMapTag ReferenceMapTag;
197
+
198
+ class MapIt;
199
+ class ConstMapIt;
200
+
201
+ friend class MapIt;
202
+ friend class ConstMapIt;
203
+
204
+ public:
205
+
206
+ SubMapExtender(const GraphType& _graph)
207
+ : Parent(_graph), graph(_graph) {}
208
+
209
+ SubMapExtender(const GraphType& _graph, const Value& _value)
210
+ : Parent(_graph, _value), graph(_graph) {}
211
+
212
+ private:
213
+ SubMapExtender& operator=(const SubMapExtender& cmap) {
214
+ return operator=<MapExtender>(cmap);
215
+ }
216
+
217
+ template <typename CMap>
218
+ SubMapExtender& operator=(const CMap& cmap) {
219
+ checkConcept<concepts::ReadMap<Key, Value>, CMap>();
220
+ Item it;
221
+ for (graph.first(it); it != INVALID; graph.next(it)) {
222
+ Parent::set(it, cmap[it]);
223
+ }
224
+ return *this;
225
+ }
226
+
227
+ public:
228
+ class MapIt : public Item {
229
+ typedef Item Parent;
230
+
231
+ public:
232
+ typedef typename Map::Value Value;
233
+
234
+ MapIt() : map(NULL) {}
235
+
236
+ MapIt(Invalid i) : Parent(i), map(NULL) { }
237
+
238
+ explicit MapIt(Map& _map) : map(&_map) {
239
+ map->graph.first(*this);
240
+ }
241
+
242
+ MapIt(const Map& _map, const Item& item)
243
+ : Parent(item), map(&_map) {}
244
+
245
+ MapIt& operator++() {
246
+ map->graph.next(*this);
247
+ return *this;
248
+ }
249
+
250
+ typename MapTraits<Map>::ConstReturnValue operator*() const {
251
+ return (*map)[*this];
252
+ }
253
+
254
+ typename MapTraits<Map>::ReturnValue operator*() {
255
+ return (*map)[*this];
256
+ }
257
+
258
+ void set(const Value& value) {
259
+ map->set(*this, value);
260
+ }
261
+
262
+ protected:
263
+ Map* map;
264
+
265
+ };
266
+
267
+ class ConstMapIt : public Item {
268
+ typedef Item Parent;
269
+
270
+ public:
271
+
272
+ typedef typename Map::Value Value;
273
+
274
+ ConstMapIt() : map(NULL) {}
275
+
276
+ ConstMapIt(Invalid i) : Parent(i), map(NULL) { }
277
+
278
+ explicit ConstMapIt(Map& _map) : map(&_map) {
279
+ map->graph.first(*this);
280
+ }
281
+
282
+ ConstMapIt(const Map& _map, const Item& item)
283
+ : Parent(item), map(&_map) {}
284
+
285
+ ConstMapIt& operator++() {
286
+ map->graph.next(*this);
287
+ return *this;
288
+ }
289
+
290
+ typename MapTraits<Map>::ConstReturnValue operator*() const {
291
+ return (*map)[*this];
292
+ }
293
+
294
+ protected:
295
+ const Map* map;
296
+ };
297
+
298
+ class ItemIt : public Item {
299
+ typedef Item Parent;
300
+
301
+ public:
302
+ ItemIt() : map(NULL) {}
303
+
304
+
305
+ ItemIt(Invalid i) : Parent(i), map(NULL) { }
306
+
307
+ explicit ItemIt(Map& _map) : map(&_map) {
308
+ map->graph.first(*this);
309
+ }
310
+
311
+ ItemIt(const Map& _map, const Item& item)
312
+ : Parent(item), map(&_map) {}
313
+
314
+ ItemIt& operator++() {
315
+ map->graph.next(*this);
316
+ return *this;
317
+ }
318
+
319
+ protected:
320
+ const Map* map;
321
+
322
+ };
323
+
324
+ private:
325
+
326
+ const GraphType& graph;
327
+
328
+ };
329
+
330
+ }
331
+
332
+ #endif
@@ -0,0 +1,177 @@
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_BITS_PATH_DUMP_H
20
+ #define LEMON_BITS_PATH_DUMP_H
21
+
22
+ #include <lemon/core.h>
23
+ #include <lemon/concept_check.h>
24
+
25
+ namespace lemon {
26
+
27
+ template <typename _Digraph, typename _PredMap>
28
+ class PredMapPath {
29
+ public:
30
+ typedef True RevPathTag;
31
+
32
+ typedef _Digraph Digraph;
33
+ typedef typename Digraph::Arc Arc;
34
+ typedef _PredMap PredMap;
35
+
36
+ PredMapPath(const Digraph& _digraph, const PredMap& _predMap,
37
+ typename Digraph::Node _target)
38
+ : digraph(_digraph), predMap(_predMap), target(_target) {}
39
+
40
+ int length() const {
41
+ int len = 0;
42
+ typename Digraph::Node node = target;
43
+ typename Digraph::Arc arc;
44
+ while ((arc = predMap[node]) != INVALID) {
45
+ node = digraph.source(arc);
46
+ ++len;
47
+ }
48
+ return len;
49
+ }
50
+
51
+ bool empty() const {
52
+ return predMap[target] == INVALID;
53
+ }
54
+
55
+ class RevArcIt {
56
+ public:
57
+ RevArcIt() {}
58
+ RevArcIt(Invalid) : path(0), current(INVALID) {}
59
+ RevArcIt(const PredMapPath& _path)
60
+ : path(&_path), current(_path.target) {
61
+ if (path->predMap[current] == INVALID) current = INVALID;
62
+ }
63
+
64
+ operator const typename Digraph::Arc() const {
65
+ return path->predMap[current];
66
+ }
67
+
68
+ RevArcIt& operator++() {
69
+ current = path->digraph.source(path->predMap[current]);
70
+ if (path->predMap[current] == INVALID) current = INVALID;
71
+ return *this;
72
+ }
73
+
74
+ bool operator==(const RevArcIt& e) const {
75
+ return current == e.current;
76
+ }
77
+
78
+ bool operator!=(const RevArcIt& e) const {
79
+ return current != e.current;
80
+ }
81
+
82
+ bool operator<(const RevArcIt& e) const {
83
+ return current < e.current;
84
+ }
85
+
86
+ private:
87
+ const PredMapPath* path;
88
+ typename Digraph::Node current;
89
+ };
90
+
91
+ private:
92
+ const Digraph& digraph;
93
+ const PredMap& predMap;
94
+ typename Digraph::Node target;
95
+ };
96
+
97
+
98
+ template <typename _Digraph, typename _PredMatrixMap>
99
+ class PredMatrixMapPath {
100
+ public:
101
+ typedef True RevPathTag;
102
+
103
+ typedef _Digraph Digraph;
104
+ typedef typename Digraph::Arc Arc;
105
+ typedef _PredMatrixMap PredMatrixMap;
106
+
107
+ PredMatrixMapPath(const Digraph& _digraph,
108
+ const PredMatrixMap& _predMatrixMap,
109
+ typename Digraph::Node _source,
110
+ typename Digraph::Node _target)
111
+ : digraph(_digraph), predMatrixMap(_predMatrixMap),
112
+ source(_source), target(_target) {}
113
+
114
+ int length() const {
115
+ int len = 0;
116
+ typename Digraph::Node node = target;
117
+ typename Digraph::Arc arc;
118
+ while ((arc = predMatrixMap(source, node)) != INVALID) {
119
+ node = digraph.source(arc);
120
+ ++len;
121
+ }
122
+ return len;
123
+ }
124
+
125
+ bool empty() const {
126
+ return predMatrixMap(source, target) == INVALID;
127
+ }
128
+
129
+ class RevArcIt {
130
+ public:
131
+ RevArcIt() {}
132
+ RevArcIt(Invalid) : path(0), current(INVALID) {}
133
+ RevArcIt(const PredMatrixMapPath& _path)
134
+ : path(&_path), current(_path.target) {
135
+ if (path->predMatrixMap(path->source, current) == INVALID)
136
+ current = INVALID;
137
+ }
138
+
139
+ operator const typename Digraph::Arc() const {
140
+ return path->predMatrixMap(path->source, current);
141
+ }
142
+
143
+ RevArcIt& operator++() {
144
+ current =
145
+ path->digraph.source(path->predMatrixMap(path->source, current));
146
+ if (path->predMatrixMap(path->source, current) == INVALID)
147
+ current = INVALID;
148
+ return *this;
149
+ }
150
+
151
+ bool operator==(const RevArcIt& e) const {
152
+ return current == e.current;
153
+ }
154
+
155
+ bool operator!=(const RevArcIt& e) const {
156
+ return current != e.current;
157
+ }
158
+
159
+ bool operator<(const RevArcIt& e) const {
160
+ return current < e.current;
161
+ }
162
+
163
+ private:
164
+ const PredMatrixMapPath* path;
165
+ typename Digraph::Node current;
166
+ };
167
+
168
+ private:
169
+ const Digraph& digraph;
170
+ const PredMatrixMap& predMatrixMap;
171
+ typename Digraph::Node source;
172
+ typename Digraph::Node target;
173
+ };
174
+
175
+ }
176
+
177
+ #endif