gravatar
deba@inf.elte.hu
deba@inf.elte.hu
Fix the naming convention of guards and remove one unnecessary include
0 9 0
default
9 files changed with 23 insertions and 24 deletions:
↑ Collapse diff ↑
Ignore white space 6 line context
1 1
/* -*- mode: C++; indent-tabs-mode: nil; -*-
2 2
 *
3 3
 * This file is a part of LEMON, a generic C++ optimization library.
4 4
 *
5 5
 * Copyright (C) 2003-2009
6 6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8 8
 *
9 9
 * Permission to use, modify and distribute this software is granted
10 10
 * provided that this copyright notice appears in all copies. For
11 11
 * precise terms see the accompanying LICENSE file.
12 12
 *
13 13
 * This software is provided "AS IS" with no warranty of any kind,
14 14
 * express or implied, and with no claim as to its suitability for any
15 15
 * purpose.
16 16
 *
17 17
 */
18 18

	
19
#ifndef LEMON_BITS_PRED_MAP_PATH_H
20
#define LEMON_BITS_PRED_MAP_PATH_H
19
#ifndef LEMON_BITS_PATH_DUMP_H
20
#define LEMON_BITS_PATH_DUMP_H
21 21

	
22 22
#include <lemon/core.h>
23 23
#include <lemon/concept_check.h>
24 24

	
25 25
namespace lemon {
26 26

	
27 27
  template <typename _Digraph, typename _PredMap>
28 28
  class PredMapPath {
29 29
  public:
30 30
    typedef True RevPathTag;
31 31

	
32 32
    typedef _Digraph Digraph;
33 33
    typedef typename Digraph::Arc Arc;
34 34
    typedef _PredMap PredMap;
35 35

	
36 36
    PredMapPath(const Digraph& _digraph, const PredMap& _predMap,
37 37
                typename Digraph::Node _target)
38 38
      : digraph(_digraph), predMap(_predMap), target(_target) {}
39 39

	
40 40
    int length() const {
41 41
      int len = 0;
42 42
      typename Digraph::Node node = target;
43 43
      typename Digraph::Arc arc;
44 44
      while ((arc = predMap[node]) != INVALID) {
45 45
        node = digraph.source(arc);
46 46
        ++len;
47 47
      }
48 48
      return len;
49 49
    }
50 50

	
51 51
    bool empty() const {
52 52
      return predMap[target] != INVALID;
53 53
    }
54 54

	
55 55
    class RevArcIt {
56 56
    public:
57 57
      RevArcIt() {}
58 58
      RevArcIt(Invalid) : path(0), current(INVALID) {}
59 59
      RevArcIt(const PredMapPath& _path)
60 60
        : path(&_path), current(_path.target) {
61 61
        if (path->predMap[current] == INVALID) current = INVALID;
62 62
      }
63 63

	
64 64
      operator const typename Digraph::Arc() const {
65 65
        return path->predMap[current];
66 66
      }
67 67

	
68 68
      RevArcIt& operator++() {
69 69
        current = path->digraph.source(path->predMap[current]);
70 70
        if (path->predMap[current] == INVALID) current = INVALID;
71 71
        return *this;
72 72
      }
73 73

	
74 74
      bool operator==(const RevArcIt& e) const {
75 75
        return current == e.current;
76 76
      }
77 77

	
78 78
      bool operator!=(const RevArcIt& e) const {
79 79
        return current != e.current;
80 80
      }
81 81

	
82 82
      bool operator<(const RevArcIt& e) const {
83 83
        return current < e.current;
84 84
      }
85 85

	
86 86
    private:
87 87
      const PredMapPath* path;
88 88
      typename Digraph::Node current;
89 89
    };
90 90

	
91 91
  private:
92 92
    const Digraph& digraph;
93 93
    const PredMap& predMap;
94 94
    typename Digraph::Node target;
95 95
  };
96 96

	
97 97

	
98 98
  template <typename _Digraph, typename _PredMatrixMap>
99 99
  class PredMatrixMapPath {
100 100
  public:
101 101
    typedef True RevPathTag;
102 102

	
103 103
    typedef _Digraph Digraph;
104 104
    typedef typename Digraph::Arc Arc;
105 105
    typedef _PredMatrixMap PredMatrixMap;
106 106

	
107 107
    PredMatrixMapPath(const Digraph& _digraph,
108 108
                      const PredMatrixMap& _predMatrixMap,
109 109
                      typename Digraph::Node _source,
110 110
                      typename Digraph::Node _target)
111 111
      : digraph(_digraph), predMatrixMap(_predMatrixMap),
112 112
        source(_source), target(_target) {}
113 113

	
114 114
    int length() const {
115 115
      int len = 0;
116 116
      typename Digraph::Node node = target;
117 117
      typename Digraph::Arc arc;
118 118
      while ((arc = predMatrixMap(source, node)) != INVALID) {
119 119
        node = digraph.source(arc);
120 120
        ++len;
121 121
      }
122 122
      return len;
123 123
    }
124 124

	
125 125
    bool empty() const {
126 126
      return source != target;
127 127
    }
128 128

	
129 129
    class RevArcIt {
130 130
    public:
131 131
      RevArcIt() {}
132 132
      RevArcIt(Invalid) : path(0), current(INVALID) {}
133 133
      RevArcIt(const PredMatrixMapPath& _path)
134 134
        : path(&_path), current(_path.target) {
135 135
        if (path->predMatrixMap(path->source, current) == INVALID)
136 136
          current = INVALID;
137 137
      }
138 138

	
139 139
      operator const typename Digraph::Arc() const {
140 140
        return path->predMatrixMap(path->source, current);
141 141
      }
142 142

	
143 143
      RevArcIt& operator++() {
144 144
        current =
145 145
          path->digraph.source(path->predMatrixMap(path->source, current));
146 146
        if (path->predMatrixMap(path->source, current) == INVALID)
147 147
          current = INVALID;
148 148
        return *this;
149 149
      }
150 150

	
151 151
      bool operator==(const RevArcIt& e) const {
152 152
        return current == e.current;
153 153
      }
154 154

	
155 155
      bool operator!=(const RevArcIt& e) const {
156 156
        return current != e.current;
157 157
      }
158 158

	
159 159
      bool operator<(const RevArcIt& e) const {
160 160
        return current < e.current;
161 161
      }
162 162

	
163 163
    private:
164 164
      const PredMatrixMapPath* path;
165 165
      typename Digraph::Node current;
166 166
    };
167 167

	
168 168
  private:
169 169
    const Digraph& digraph;
170 170
    const PredMatrixMap& predMatrixMap;
171 171
    typename Digraph::Node source;
172 172
    typename Digraph::Node target;
173 173
  };
174 174

	
175 175
}
176 176

	
177 177
#endif
Ignore white space 6 line context
1 1
/* -*- mode: C++; indent-tabs-mode: nil; -*-
2 2
 *
3 3
 * This file is a part of LEMON, a generic C++ optimization library.
4 4
 *
5 5
 * Copyright (C) 2003-2009
6 6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8 8
 *
9 9
 * Permission to use, modify and distribute this software is granted
10 10
 * provided that this copyright notice appears in all copies. For
11 11
 * precise terms see the accompanying LICENSE file.
12 12
 *
13 13
 * This software is provided "AS IS" with no warranty of any kind,
14 14
 * express or implied, and with no claim as to its suitability for any
15 15
 * purpose.
16 16
 *
17 17
 */
18 18

	
19
#ifndef LEMON_WINDOWS_H
20
#define LEMON_WINDOWS_H
19
#ifndef LEMON_BITS_WINDOWS_H
20
#define LEMON_BITS_WINDOWS_H
21 21

	
22 22
#include <string>
23 23

	
24 24
namespace lemon {
25 25
  namespace bits {
26 26
    void getWinProcTimes(double &rtime,
27 27
                         double &utime, double &stime,
28 28
                         double &cutime, double &cstime);
29 29
    std::string getWinFormattedDate();
30 30
    int getWinRndSeed();
31 31
  }
32 32
}
33 33

	
34 34
#endif
Ignore white space 6 line context
1 1
/* -*- mode: C++; indent-tabs-mode: nil; -*-
2 2
 *
3 3
 * This file is a part of LEMON, a generic C++ optimization library.
4 4
 *
5 5
 * Copyright (C) 2003-2009
6 6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8 8
 *
9 9
 * Permission to use, modify and distribute this software is granted
10 10
 * provided that this copyright notice appears in all copies. For
11 11
 * precise terms see the accompanying LICENSE file.
12 12
 *
13 13
 * This software is provided "AS IS" with no warranty of any kind,
14 14
 * express or implied, and with no claim as to its suitability for any
15 15
 * purpose.
16 16
 *
17 17
 */
18 18

	
19
#ifndef LEMON_CONCEPT_DIGRAPH_H
20
#define LEMON_CONCEPT_DIGRAPH_H
19
#ifndef LEMON_CONCEPTS_DIGRAPH_H
20
#define LEMON_CONCEPTS_DIGRAPH_H
21 21

	
22 22
///\ingroup graph_concepts
23 23
///\file
24 24
///\brief The concept of directed graphs.
25 25

	
26 26
#include <lemon/core.h>
27 27
#include <lemon/concepts/maps.h>
28 28
#include <lemon/concept_check.h>
29 29
#include <lemon/concepts/graph_components.h>
30 30

	
31 31
namespace lemon {
32 32
  namespace concepts {
33 33

	
34 34
    /// \ingroup graph_concepts
35 35
    ///
36 36
    /// \brief Class describing the concept of directed graphs.
37 37
    ///
38 38
    /// This class describes the \ref concept "concept" of the
39 39
    /// immutable directed digraphs.
40 40
    ///
41 41
    /// Note that actual digraph implementation like @ref ListDigraph or
42 42
    /// @ref SmartDigraph may have several additional functionality.
43 43
    ///
44 44
    /// \sa concept
45 45
    class Digraph {
46 46
    private:
47 47
      ///Digraphs are \e not copy constructible. Use DigraphCopy() instead.
48 48

	
49 49
      ///Digraphs are \e not copy constructible. Use DigraphCopy() instead.
50 50
      ///
51 51
      Digraph(const Digraph &) {};
52 52
      ///\brief Assignment of \ref Digraph "Digraph"s to another ones are
53 53
      ///\e not allowed. Use DigraphCopy() instead.
54 54

	
55 55
      ///Assignment of \ref Digraph "Digraph"s to another ones are
56 56
      ///\e not allowed.  Use DigraphCopy() instead.
57 57

	
58 58
      void operator=(const Digraph &) {}
59 59
    public:
60 60
      ///\e
61 61

	
62 62
      /// Defalult constructor.
63 63

	
64 64
      /// Defalult constructor.
65 65
      ///
66 66
      Digraph() { }
67 67
      /// Class for identifying a node of the digraph
68 68

	
69 69
      /// This class identifies a node of the digraph. It also serves
70 70
      /// as a base class of the node iterators,
71 71
      /// thus they will convert to this type.
72 72
      class Node {
73 73
      public:
74 74
        /// Default constructor
75 75

	
76 76
        /// @warning The default constructor sets the iterator
77 77
        /// to an undefined value.
78 78
        Node() { }
79 79
        /// Copy constructor.
80 80

	
81 81
        /// Copy constructor.
82 82
        ///
83 83
        Node(const Node&) { }
84 84

	
85 85
        /// Invalid constructor \& conversion.
86 86

	
87 87
        /// This constructor initializes the iterator to be invalid.
88 88
        /// \sa Invalid for more details.
89 89
        Node(Invalid) { }
90 90
        /// Equality operator
91 91

	
92 92
        /// Two iterators are equal if and only if they point to the
93 93
        /// same object or both are invalid.
94 94
        bool operator==(Node) const { return true; }
95 95

	
96 96
        /// Inequality operator
97 97

	
98 98
        /// \sa operator==(Node n)
99 99
        ///
100 100
        bool operator!=(Node) const { return true; }
101 101

	
102 102
        /// Artificial ordering operator.
103 103

	
104 104
        /// To allow the use of digraph descriptors as key type in std::map or
105 105
        /// similar associative container we require this.
106 106
        ///
107 107
        /// \note This operator only have to define some strict ordering of
108 108
        /// the items; this order has nothing to do with the iteration
109 109
        /// ordering of the items.
110 110
        bool operator<(Node) const { return false; }
111 111

	
112 112
      };
113 113

	
114 114
      /// This iterator goes through each node.
115 115

	
116 116
      /// This iterator goes through each node.
117 117
      /// Its usage is quite simple, for example you can count the number
118 118
      /// of nodes in digraph \c g of type \c Digraph like this:
119 119
      ///\code
120 120
      /// int count=0;
121 121
      /// for (Digraph::NodeIt n(g); n!=INVALID; ++n) ++count;
122 122
      ///\endcode
123 123
      class NodeIt : public Node {
124 124
      public:
125 125
        /// Default constructor
126 126

	
127 127
        /// @warning The default constructor sets the iterator
128 128
        /// to an undefined value.
129 129
        NodeIt() { }
130 130
        /// Copy constructor.
131 131

	
132 132
        /// Copy constructor.
133 133
        ///
134 134
        NodeIt(const NodeIt& n) : Node(n) { }
135 135
        /// Invalid constructor \& conversion.
136 136

	
137 137
        /// Initialize the iterator to be invalid.
138 138
        /// \sa Invalid for more details.
139 139
        NodeIt(Invalid) { }
140 140
        /// Sets the iterator to the first node.
141 141

	
142 142
        /// Sets the iterator to the first node of \c g.
143 143
        ///
144 144
        NodeIt(const Digraph&) { }
145 145
        /// Node -> NodeIt conversion.
146 146

	
147 147
        /// Sets the iterator to the node of \c the digraph pointed by
148 148
        /// the trivial iterator.
149 149
        /// This feature necessitates that each time we
150 150
        /// iterate the arc-set, the iteration order is the same.
151 151
        NodeIt(const Digraph&, const Node&) { }
152 152
        /// Next node.
153 153

	
154 154
        /// Assign the iterator to the next node.
155 155
        ///
156 156
        NodeIt& operator++() { return *this; }
157 157
      };
158 158

	
159 159

	
160 160
      /// Class for identifying an arc of the digraph
161 161

	
162 162
      /// This class identifies an arc of the digraph. It also serves
163 163
      /// as a base class of the arc iterators,
164 164
      /// thus they will convert to this type.
165 165
      class Arc {
166 166
      public:
167 167
        /// Default constructor
168 168

	
169 169
        /// @warning The default constructor sets the iterator
170 170
        /// to an undefined value.
171 171
        Arc() { }
172 172
        /// Copy constructor.
173 173

	
174 174
        /// Copy constructor.
175 175
        ///
176 176
        Arc(const Arc&) { }
177 177
        /// Initialize the iterator to be invalid.
178 178

	
179 179
        /// Initialize the iterator to be invalid.
180 180
        ///
181 181
        Arc(Invalid) { }
182 182
        /// Equality operator
183 183

	
184 184
        /// Two iterators are equal if and only if they point to the
185 185
        /// same object or both are invalid.
186 186
        bool operator==(Arc) const { return true; }
187 187
        /// Inequality operator
188 188

	
189 189
        /// \sa operator==(Arc n)
190 190
        ///
191 191
        bool operator!=(Arc) const { return true; }
192 192

	
193 193
        /// Artificial ordering operator.
194 194

	
195 195
        /// To allow the use of digraph descriptors as key type in std::map or
196 196
        /// similar associative container we require this.
197 197
        ///
198 198
        /// \note This operator only have to define some strict ordering of
199 199
        /// the items; this order has nothing to do with the iteration
200 200
        /// ordering of the items.
201 201
        bool operator<(Arc) const { return false; }
202 202
      };
203 203

	
204 204
      /// This iterator goes trough the outgoing arcs of a node.
205 205

	
206 206
      /// This iterator goes trough the \e outgoing arcs of a certain node
207 207
      /// of a digraph.
208 208
      /// Its usage is quite simple, for example you can count the number
209 209
      /// of outgoing arcs of a node \c n
210 210
      /// in digraph \c g of type \c Digraph as follows.
211 211
      ///\code
212 212
      /// int count=0;
213 213
      /// for (Digraph::OutArcIt e(g, n); e!=INVALID; ++e) ++count;
214 214
      ///\endcode
215 215

	
216 216
      class OutArcIt : public Arc {
217 217
      public:
218 218
        /// Default constructor
219 219

	
220 220
        /// @warning The default constructor sets the iterator
221 221
        /// to an undefined value.
222 222
        OutArcIt() { }
223 223
        /// Copy constructor.
224 224

	
225 225
        /// Copy constructor.
226 226
        ///
227 227
        OutArcIt(const OutArcIt& e) : Arc(e) { }
228 228
        /// Initialize the iterator to be invalid.
229 229

	
230 230
        /// Initialize the iterator to be invalid.
231 231
        ///
232 232
        OutArcIt(Invalid) { }
233 233
        /// This constructor sets the iterator to the first outgoing arc.
234 234

	
235 235
        /// This constructor sets the iterator to the first outgoing arc of
236 236
        /// the node.
237 237
        OutArcIt(const Digraph&, const Node&) { }
238 238
        /// Arc -> OutArcIt conversion
239 239

	
240 240
        /// Sets the iterator to the value of the trivial iterator.
241 241
        /// This feature necessitates that each time we
242 242
        /// iterate the arc-set, the iteration order is the same.
243 243
        OutArcIt(const Digraph&, const Arc&) { }
244 244
        ///Next outgoing arc
245 245

	
246 246
        /// Assign the iterator to the next
247 247
        /// outgoing arc of the corresponding node.
248 248
        OutArcIt& operator++() { return *this; }
249 249
      };
250 250

	
251 251
      /// This iterator goes trough the incoming arcs of a node.
252 252

	
253 253
      /// This iterator goes trough the \e incoming arcs of a certain node
254 254
      /// of a digraph.
255 255
      /// Its usage is quite simple, for example you can count the number
256 256
      /// of outgoing arcs of a node \c n
257 257
      /// in digraph \c g of type \c Digraph as follows.
258 258
      ///\code
259 259
      /// int count=0;
260 260
      /// for(Digraph::InArcIt e(g, n); e!=INVALID; ++e) ++count;
261 261
      ///\endcode
262 262

	
263 263
      class InArcIt : public Arc {
264 264
      public:
265 265
        /// Default constructor
266 266

	
267 267
        /// @warning The default constructor sets the iterator
268 268
        /// to an undefined value.
269 269
        InArcIt() { }
270 270
        /// Copy constructor.
271 271

	
272 272
        /// Copy constructor.
273 273
        ///
274 274
        InArcIt(const InArcIt& e) : Arc(e) { }
275 275
        /// Initialize the iterator to be invalid.
276 276

	
277 277
        /// Initialize the iterator to be invalid.
278 278
        ///
279 279
        InArcIt(Invalid) { }
280 280
        /// This constructor sets the iterator to first incoming arc.
281 281

	
282 282
        /// This constructor set the iterator to the first incoming arc of
283 283
        /// the node.
284 284
        InArcIt(const Digraph&, const Node&) { }
285 285
        /// Arc -> InArcIt conversion
286 286

	
287 287
        /// Sets the iterator to the value of the trivial iterator \c e.
288 288
        /// This feature necessitates that each time we
289 289
        /// iterate the arc-set, the iteration order is the same.
290 290
        InArcIt(const Digraph&, const Arc&) { }
291 291
        /// Next incoming arc
292 292

	
293 293
        /// Assign the iterator to the next inarc of the corresponding node.
294 294
        ///
295 295
        InArcIt& operator++() { return *this; }
296 296
      };
297 297
      /// This iterator goes through each arc.
298 298

	
299 299
      /// This iterator goes through each arc of a digraph.
300 300
      /// Its usage is quite simple, for example you can count the number
301 301
      /// of arcs in a digraph \c g of type \c Digraph as follows:
302 302
      ///\code
303 303
      /// int count=0;
304 304
      /// for(Digraph::ArcIt e(g); e!=INVALID; ++e) ++count;
305 305
      ///\endcode
306 306
      class ArcIt : public Arc {
307 307
      public:
308 308
        /// Default constructor
309 309

	
310 310
        /// @warning The default constructor sets the iterator
311 311
        /// to an undefined value.
312 312
        ArcIt() { }
313 313
        /// Copy constructor.
314 314

	
315 315
        /// Copy constructor.
316 316
        ///
317 317
        ArcIt(const ArcIt& e) : Arc(e) { }
318 318
        /// Initialize the iterator to be invalid.
319 319

	
320 320
        /// Initialize the iterator to be invalid.
321 321
        ///
322 322
        ArcIt(Invalid) { }
323 323
        /// This constructor sets the iterator to the first arc.
324 324

	
325 325
        /// This constructor sets the iterator to the first arc of \c g.
326 326
        ///@param g the digraph
327 327
        ArcIt(const Digraph& g) { ignore_unused_variable_warning(g); }
328 328
        /// Arc -> ArcIt conversion
329 329

	
330 330
        /// Sets the iterator to the value of the trivial iterator \c e.
331 331
        /// This feature necessitates that each time we
332 332
        /// iterate the arc-set, the iteration order is the same.
333 333
        ArcIt(const Digraph&, const Arc&) { }
334 334
        ///Next arc
335 335

	
336 336
        /// Assign the iterator to the next arc.
337 337
        ArcIt& operator++() { return *this; }
338 338
      };
339 339
      ///Gives back the target node of an arc.
340 340

	
341 341
      ///Gives back the target node of an arc.
342 342
      ///
343 343
      Node target(Arc) const { return INVALID; }
344 344
      ///Gives back the source node of an arc.
345 345

	
346 346
      ///Gives back the source node of an arc.
347 347
      ///
348 348
      Node source(Arc) const { return INVALID; }
349 349

	
350 350
      /// \brief Returns the ID of the node.
351 351
      int id(Node) const { return -1; }
352 352

	
353 353
      /// \brief Returns the ID of the arc.
354 354
      int id(Arc) const { return -1; }
355 355

	
356 356
      /// \brief Returns the node with the given ID.
357 357
      ///
358 358
      /// \pre The argument should be a valid node ID in the graph.
359 359
      Node nodeFromId(int) const { return INVALID; }
360 360

	
361 361
      /// \brief Returns the arc with the given ID.
362 362
      ///
363 363
      /// \pre The argument should be a valid arc ID in the graph.
364 364
      Arc arcFromId(int) const { return INVALID; }
365 365

	
366 366
      /// \brief Returns an upper bound on the node IDs.
367 367
      int maxNodeId() const { return -1; }
368 368

	
369 369
      /// \brief Returns an upper bound on the arc IDs.
370 370
      int maxArcId() const { return -1; }
371 371

	
372 372
      void first(Node&) const {}
373 373
      void next(Node&) const {}
374 374

	
375 375
      void first(Arc&) const {}
376 376
      void next(Arc&) const {}
377 377

	
378 378

	
379 379
      void firstIn(Arc&, const Node&) const {}
380 380
      void nextIn(Arc&) const {}
381 381

	
382 382
      void firstOut(Arc&, const Node&) const {}
383 383
      void nextOut(Arc&) const {}
384 384

	
385 385
      // The second parameter is dummy.
386 386
      Node fromId(int, Node) const { return INVALID; }
387 387
      // The second parameter is dummy.
388 388
      Arc fromId(int, Arc) const { return INVALID; }
389 389

	
390 390
      // Dummy parameter.
391 391
      int maxId(Node) const { return -1; }
392 392
      // Dummy parameter.
393 393
      int maxId(Arc) const { return -1; }
394 394

	
395 395
      /// \brief The base node of the iterator.
396 396
      ///
397 397
      /// Gives back the base node of the iterator.
398 398
      /// It is always the target of the pointed arc.
399 399
      Node baseNode(const InArcIt&) const { return INVALID; }
400 400

	
401 401
      /// \brief The running node of the iterator.
402 402
      ///
403 403
      /// Gives back the running node of the iterator.
404 404
      /// It is always the source of the pointed arc.
405 405
      Node runningNode(const InArcIt&) const { return INVALID; }
406 406

	
407 407
      /// \brief The base node of the iterator.
408 408
      ///
409 409
      /// Gives back the base node of the iterator.
410 410
      /// It is always the source of the pointed arc.
411 411
      Node baseNode(const OutArcIt&) const { return INVALID; }
412 412

	
413 413
      /// \brief The running node of the iterator.
414 414
      ///
415 415
      /// Gives back the running node of the iterator.
416 416
      /// It is always the target of the pointed arc.
417 417
      Node runningNode(const OutArcIt&) const { return INVALID; }
418 418

	
419 419
      /// \brief The opposite node on the given arc.
420 420
      ///
421 421
      /// Gives back the opposite node on the given arc.
422 422
      Node oppositeNode(const Node&, const Arc&) const { return INVALID; }
423 423

	
424 424
      /// \brief Read write map of the nodes to type \c T.
425 425
      ///
426 426
      /// ReadWrite map of the nodes to type \c T.
427 427
      /// \sa Reference
428 428
      template<class T>
429 429
      class NodeMap : public ReadWriteMap< Node, T > {
430 430
      public:
431 431

	
432 432
        ///\e
433 433
        NodeMap(const Digraph&) { }
434 434
        ///\e
435 435
        NodeMap(const Digraph&, T) { }
436 436

	
437 437
      private:
438 438
        ///Copy constructor
439 439
        NodeMap(const NodeMap& nm) : ReadWriteMap< Node, T >(nm) { }
440 440
        ///Assignment operator
441 441
        template <typename CMap>
442 442
        NodeMap& operator=(const CMap&) {
443 443
          checkConcept<ReadMap<Node, T>, CMap>();
444 444
          return *this;
445 445
        }
446 446
      };
447 447

	
448 448
      /// \brief Read write map of the arcs to type \c T.
449 449
      ///
450 450
      /// Reference map of the arcs to type \c T.
451 451
      /// \sa Reference
452 452
      template<class T>
453 453
      class ArcMap : public ReadWriteMap<Arc,T> {
454 454
      public:
455 455

	
456 456
        ///\e
457 457
        ArcMap(const Digraph&) { }
458 458
        ///\e
459 459
        ArcMap(const Digraph&, T) { }
460 460
      private:
461 461
        ///Copy constructor
462 462
        ArcMap(const ArcMap& em) : ReadWriteMap<Arc,T>(em) { }
463 463
        ///Assignment operator
464 464
        template <typename CMap>
465 465
        ArcMap& operator=(const CMap&) {
466 466
          checkConcept<ReadMap<Arc, T>, CMap>();
467 467
          return *this;
468 468
        }
469 469
      };
470 470

	
471 471
      template <typename _Digraph>
472 472
      struct Constraints {
473 473
        void constraints() {
474 474
          checkConcept<IterableDigraphComponent<>, _Digraph>();
475 475
          checkConcept<IDableDigraphComponent<>, _Digraph>();
476 476
          checkConcept<MappableDigraphComponent<>, _Digraph>();
477 477
        }
478 478
      };
479 479

	
480 480
    };
481 481

	
482 482
  } //namespace concepts
483 483
} //namespace lemon
484 484

	
485 485

	
486 486

	
487
#endif // LEMON_CONCEPT_DIGRAPH_H
487
#endif
Ignore white space 3072 line context
1 1
/* -*- mode: C++; indent-tabs-mode: nil; -*-
2 2
 *
3 3
 * This file is a part of LEMON, a generic C++ optimization library.
4 4
 *
5 5
 * Copyright (C) 2003-2009
6 6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8 8
 *
9 9
 * Permission to use, modify and distribute this software is granted
10 10
 * provided that this copyright notice appears in all copies. For
11 11
 * precise terms see the accompanying LICENSE file.
12 12
 *
13 13
 * This software is provided "AS IS" with no warranty of any kind,
14 14
 * express or implied, and with no claim as to its suitability for any
15 15
 * purpose.
16 16
 *
17 17
 */
18 18

	
19 19
///\ingroup graph_concepts
20 20
///\file
21 21
///\brief The concept of Undirected Graphs.
22 22

	
23
#ifndef LEMON_CONCEPT_GRAPH_H
24
#define LEMON_CONCEPT_GRAPH_H
23
#ifndef LEMON_CONCEPTS_GRAPH_H
24
#define LEMON_CONCEPTS_GRAPH_H
25 25

	
26 26
#include <lemon/concepts/graph_components.h>
27
#include <lemon/concepts/graph.h>
28 27
#include <lemon/core.h>
29 28

	
30 29
namespace lemon {
31 30
  namespace concepts {
32 31

	
33 32
    /// \ingroup graph_concepts
34 33
    ///
35 34
    /// \brief Class describing the concept of Undirected Graphs.
36 35
    ///
37 36
    /// This class describes the common interface of all Undirected
38 37
    /// Graphs.
39 38
    ///
40 39
    /// As all concept describing classes it provides only interface
41 40
    /// without any sensible implementation. So any algorithm for
42 41
    /// undirected graph should compile with this class, but it will not
43 42
    /// run properly, of course.
44 43
    ///
45 44
    /// The LEMON undirected graphs also fulfill the concept of
46 45
    /// directed graphs (\ref lemon::concepts::Digraph "Digraph
47 46
    /// Concept"). Each edges can be seen as two opposite
48 47
    /// directed arc and consequently the undirected graph can be
49 48
    /// seen as the direceted graph of these directed arcs. The
50 49
    /// Graph has the Edge inner class for the edges and
51 50
    /// the Arc type for the directed arcs. The Arc type is
52 51
    /// convertible to Edge or inherited from it so from a directed
53 52
    /// arc we can get the represented edge.
54 53
    ///
55 54
    /// In the sense of the LEMON each edge has a default
56 55
    /// direction (it should be in every computer implementation,
57 56
    /// because the order of edge's nodes defines an
58 57
    /// orientation). With the default orientation we can define that
59 58
    /// the directed arc is forward or backward directed. With the \c
60 59
    /// direction() and \c direct() function we can get the direction
61 60
    /// of the directed arc and we can direct an edge.
62 61
    ///
63 62
    /// The EdgeIt is an iterator for the edges. We can use
64 63
    /// the EdgeMap to map values for the edges. The InArcIt and
65 64
    /// OutArcIt iterates on the same edges but with opposite
66 65
    /// direction. The IncEdgeIt iterates also on the same edges
67 66
    /// as the OutArcIt and InArcIt but it is not convertible to Arc just
68 67
    /// to Edge.
69 68
    class Graph {
70 69
    public:
71 70
      /// \brief The undirected graph should be tagged by the
72 71
      /// UndirectedTag.
73 72
      ///
74 73
      /// The undirected graph should be tagged by the UndirectedTag. This
75 74
      /// tag helps the enable_if technics to make compile time
76 75
      /// specializations for undirected graphs.
77 76
      typedef True UndirectedTag;
78 77

	
79 78
      /// \brief The base type of node iterators,
80 79
      /// or in other words, the trivial node iterator.
81 80
      ///
82 81
      /// This is the base type of each node iterator,
83 82
      /// thus each kind of node iterator converts to this.
84 83
      /// More precisely each kind of node iterator should be inherited
85 84
      /// from the trivial node iterator.
86 85
      class Node {
87 86
      public:
88 87
        /// Default constructor
89 88

	
90 89
        /// @warning The default constructor sets the iterator
91 90
        /// to an undefined value.
92 91
        Node() { }
93 92
        /// Copy constructor.
94 93

	
95 94
        /// Copy constructor.
96 95
        ///
97 96
        Node(const Node&) { }
98 97

	
99 98
        /// Invalid constructor \& conversion.
100 99

	
101 100
        /// This constructor initializes the iterator to be invalid.
102 101
        /// \sa Invalid for more details.
103 102
        Node(Invalid) { }
104 103
        /// Equality operator
105 104

	
106 105
        /// Two iterators are equal if and only if they point to the
107 106
        /// same object or both are invalid.
108 107
        bool operator==(Node) const { return true; }
109 108

	
110 109
        /// Inequality operator
111 110

	
112 111
        /// \sa operator==(Node n)
113 112
        ///
114 113
        bool operator!=(Node) const { return true; }
115 114

	
116 115
        /// Artificial ordering operator.
117 116

	
118 117
        /// To allow the use of graph descriptors as key type in std::map or
119 118
        /// similar associative container we require this.
120 119
        ///
121 120
        /// \note This operator only have to define some strict ordering of
122 121
        /// the items; this order has nothing to do with the iteration
123 122
        /// ordering of the items.
124 123
        bool operator<(Node) const { return false; }
125 124

	
126 125
      };
127 126

	
128 127
      /// This iterator goes through each node.
129 128

	
130 129
      /// This iterator goes through each node.
131 130
      /// Its usage is quite simple, for example you can count the number
132 131
      /// of nodes in graph \c g of type \c Graph like this:
133 132
      ///\code
134 133
      /// int count=0;
135 134
      /// for (Graph::NodeIt n(g); n!=INVALID; ++n) ++count;
136 135
      ///\endcode
137 136
      class NodeIt : public Node {
138 137
      public:
139 138
        /// Default constructor
140 139

	
141 140
        /// @warning The default constructor sets the iterator
142 141
        /// to an undefined value.
143 142
        NodeIt() { }
144 143
        /// Copy constructor.
145 144

	
146 145
        /// Copy constructor.
147 146
        ///
148 147
        NodeIt(const NodeIt& n) : Node(n) { }
149 148
        /// Invalid constructor \& conversion.
150 149

	
151 150
        /// Initialize the iterator to be invalid.
152 151
        /// \sa Invalid for more details.
153 152
        NodeIt(Invalid) { }
154 153
        /// Sets the iterator to the first node.
155 154

	
156 155
        /// Sets the iterator to the first node of \c g.
157 156
        ///
158 157
        NodeIt(const Graph&) { }
159 158
        /// Node -> NodeIt conversion.
160 159

	
161 160
        /// Sets the iterator to the node of \c the graph pointed by
162 161
        /// the trivial iterator.
163 162
        /// This feature necessitates that each time we
164 163
        /// iterate the arc-set, the iteration order is the same.
165 164
        NodeIt(const Graph&, const Node&) { }
166 165
        /// Next node.
167 166

	
168 167
        /// Assign the iterator to the next node.
169 168
        ///
170 169
        NodeIt& operator++() { return *this; }
171 170
      };
172 171

	
173 172

	
174 173
      /// The base type of the edge iterators.
175 174

	
176 175
      /// The base type of the edge iterators.
177 176
      ///
178 177
      class Edge {
179 178
      public:
180 179
        /// Default constructor
181 180

	
182 181
        /// @warning The default constructor sets the iterator
183 182
        /// to an undefined value.
184 183
        Edge() { }
185 184
        /// Copy constructor.
186 185

	
187 186
        /// Copy constructor.
188 187
        ///
189 188
        Edge(const Edge&) { }
190 189
        /// Initialize the iterator to be invalid.
191 190

	
192 191
        /// Initialize the iterator to be invalid.
193 192
        ///
194 193
        Edge(Invalid) { }
195 194
        /// Equality operator
196 195

	
197 196
        /// Two iterators are equal if and only if they point to the
198 197
        /// same object or both are invalid.
199 198
        bool operator==(Edge) const { return true; }
200 199
        /// Inequality operator
201 200

	
202 201
        /// \sa operator==(Edge n)
203 202
        ///
204 203
        bool operator!=(Edge) const { return true; }
205 204

	
206 205
        /// Artificial ordering operator.
207 206

	
208 207
        /// To allow the use of graph descriptors as key type in std::map or
209 208
        /// similar associative container we require this.
210 209
        ///
211 210
        /// \note This operator only have to define some strict ordering of
212 211
        /// the items; this order has nothing to do with the iteration
213 212
        /// ordering of the items.
214 213
        bool operator<(Edge) const { return false; }
215 214
      };
216 215

	
217 216
      /// This iterator goes through each edge.
218 217

	
219 218
      /// This iterator goes through each edge of a graph.
220 219
      /// Its usage is quite simple, for example you can count the number
221 220
      /// of edges in a graph \c g of type \c Graph as follows:
222 221
      ///\code
223 222
      /// int count=0;
224 223
      /// for(Graph::EdgeIt e(g); e!=INVALID; ++e) ++count;
225 224
      ///\endcode
226 225
      class EdgeIt : public Edge {
227 226
      public:
228 227
        /// Default constructor
229 228

	
230 229
        /// @warning The default constructor sets the iterator
231 230
        /// to an undefined value.
232 231
        EdgeIt() { }
233 232
        /// Copy constructor.
234 233

	
235 234
        /// Copy constructor.
236 235
        ///
237 236
        EdgeIt(const EdgeIt& e) : Edge(e) { }
238 237
        /// Initialize the iterator to be invalid.
239 238

	
240 239
        /// Initialize the iterator to be invalid.
241 240
        ///
242 241
        EdgeIt(Invalid) { }
243 242
        /// This constructor sets the iterator to the first edge.
244 243

	
245 244
        /// This constructor sets the iterator to the first edge.
246 245
        EdgeIt(const Graph&) { }
247 246
        /// Edge -> EdgeIt conversion
248 247

	
249 248
        /// Sets the iterator to the value of the trivial iterator.
250 249
        /// This feature necessitates that each time we
251 250
        /// iterate the edge-set, the iteration order is the
252 251
        /// same.
253 252
        EdgeIt(const Graph&, const Edge&) { }
254 253
        /// Next edge
255 254

	
256 255
        /// Assign the iterator to the next edge.
257 256
        EdgeIt& operator++() { return *this; }
258 257
      };
259 258

	
260 259
      /// \brief This iterator goes trough the incident undirected
261 260
      /// arcs of a node.
262 261
      ///
263 262
      /// This iterator goes trough the incident edges
264 263
      /// of a certain node of a graph. You should assume that the
265 264
      /// loop arcs will be iterated twice.
266 265
      ///
267 266
      /// Its usage is quite simple, for example you can compute the
268 267
      /// degree (i.e. count the number of incident arcs of a node \c n
269 268
      /// in graph \c g of type \c Graph as follows.
270 269
      ///
271 270
      ///\code
272 271
      /// int count=0;
273 272
      /// for(Graph::IncEdgeIt e(g, n); e!=INVALID; ++e) ++count;
274 273
      ///\endcode
275 274
      class IncEdgeIt : public Edge {
276 275
      public:
277 276
        /// Default constructor
278 277

	
279 278
        /// @warning The default constructor sets the iterator
280 279
        /// to an undefined value.
281 280
        IncEdgeIt() { }
282 281
        /// Copy constructor.
283 282

	
284 283
        /// Copy constructor.
285 284
        ///
286 285
        IncEdgeIt(const IncEdgeIt& e) : Edge(e) { }
287 286
        /// Initialize the iterator to be invalid.
288 287

	
289 288
        /// Initialize the iterator to be invalid.
290 289
        ///
291 290
        IncEdgeIt(Invalid) { }
292 291
        /// This constructor sets the iterator to first incident arc.
293 292

	
294 293
        /// This constructor set the iterator to the first incident arc of
295 294
        /// the node.
296 295
        IncEdgeIt(const Graph&, const Node&) { }
297 296
        /// Edge -> IncEdgeIt conversion
298 297

	
299 298
        /// Sets the iterator to the value of the trivial iterator \c e.
300 299
        /// This feature necessitates that each time we
301 300
        /// iterate the arc-set, the iteration order is the same.
302 301
        IncEdgeIt(const Graph&, const Edge&) { }
303 302
        /// Next incident arc
304 303

	
305 304
        /// Assign the iterator to the next incident arc
306 305
        /// of the corresponding node.
307 306
        IncEdgeIt& operator++() { return *this; }
308 307
      };
309 308

	
310 309
      /// The directed arc type.
311 310

	
312 311
      /// The directed arc type. It can be converted to the
313 312
      /// edge or it should be inherited from the undirected
314 313
      /// arc.
315 314
      class Arc : public Edge {
316 315
      public:
317 316
        /// Default constructor
318 317

	
319 318
        /// @warning The default constructor sets the iterator
320 319
        /// to an undefined value.
321 320
        Arc() { }
322 321
        /// Copy constructor.
323 322

	
324 323
        /// Copy constructor.
325 324
        ///
326 325
        Arc(const Arc& e) : Edge(e) { }
327 326
        /// Initialize the iterator to be invalid.
328 327

	
329 328
        /// Initialize the iterator to be invalid.
330 329
        ///
331 330
        Arc(Invalid) { }
332 331
        /// Equality operator
333 332

	
334 333
        /// Two iterators are equal if and only if they point to the
335 334
        /// same object or both are invalid.
336 335
        bool operator==(Arc) const { return true; }
337 336
        /// Inequality operator
338 337

	
339 338
        /// \sa operator==(Arc n)
340 339
        ///
341 340
        bool operator!=(Arc) const { return true; }
342 341

	
343 342
        /// Artificial ordering operator.
344 343

	
345 344
        /// To allow the use of graph descriptors as key type in std::map or
346 345
        /// similar associative container we require this.
347 346
        ///
348 347
        /// \note This operator only have to define some strict ordering of
349 348
        /// the items; this order has nothing to do with the iteration
350 349
        /// ordering of the items.
351 350
        bool operator<(Arc) const { return false; }
352 351

	
353 352
      };
354 353
      /// This iterator goes through each directed arc.
355 354

	
356 355
      /// This iterator goes through each arc of a graph.
357 356
      /// Its usage is quite simple, for example you can count the number
358 357
      /// of arcs in a graph \c g of type \c Graph as follows:
359 358
      ///\code
360 359
      /// int count=0;
361 360
      /// for(Graph::ArcIt e(g); e!=INVALID; ++e) ++count;
362 361
      ///\endcode
363 362
      class ArcIt : public Arc {
364 363
      public:
365 364
        /// Default constructor
366 365

	
367 366
        /// @warning The default constructor sets the iterator
368 367
        /// to an undefined value.
369 368
        ArcIt() { }
370 369
        /// Copy constructor.
371 370

	
372 371
        /// Copy constructor.
373 372
        ///
374 373
        ArcIt(const ArcIt& e) : Arc(e) { }
375 374
        /// Initialize the iterator to be invalid.
376 375

	
377 376
        /// Initialize the iterator to be invalid.
378 377
        ///
379 378
        ArcIt(Invalid) { }
380 379
        /// This constructor sets the iterator to the first arc.
381 380

	
382 381
        /// This constructor sets the iterator to the first arc of \c g.
383 382
        ///@param g the graph
384 383
        ArcIt(const Graph &g) { ignore_unused_variable_warning(g); }
385 384
        /// Arc -> ArcIt conversion
386 385

	
387 386
        /// Sets the iterator to the value of the trivial iterator \c e.
388 387
        /// This feature necessitates that each time we
389 388
        /// iterate the arc-set, the iteration order is the same.
390 389
        ArcIt(const Graph&, const Arc&) { }
391 390
        ///Next arc
392 391

	
393 392
        /// Assign the iterator to the next arc.
394 393
        ArcIt& operator++() { return *this; }
395 394
      };
396 395

	
397 396
      /// This iterator goes trough the outgoing directed arcs of a node.
398 397

	
399 398
      /// This iterator goes trough the \e outgoing arcs of a certain node
400 399
      /// of a graph.
401 400
      /// Its usage is quite simple, for example you can count the number
402 401
      /// of outgoing arcs of a node \c n
403 402
      /// in graph \c g of type \c Graph as follows.
404 403
      ///\code
405 404
      /// int count=0;
406 405
      /// for (Graph::OutArcIt e(g, n); e!=INVALID; ++e) ++count;
407 406
      ///\endcode
408 407

	
409 408
      class OutArcIt : public Arc {
410 409
      public:
411 410
        /// Default constructor
412 411

	
413 412
        /// @warning The default constructor sets the iterator
414 413
        /// to an undefined value.
415 414
        OutArcIt() { }
416 415
        /// Copy constructor.
417 416

	
418 417
        /// Copy constructor.
419 418
        ///
420 419
        OutArcIt(const OutArcIt& e) : Arc(e) { }
421 420
        /// Initialize the iterator to be invalid.
422 421

	
423 422
        /// Initialize the iterator to be invalid.
424 423
        ///
425 424
        OutArcIt(Invalid) { }
426 425
        /// This constructor sets the iterator to the first outgoing arc.
427 426

	
428 427
        /// This constructor sets the iterator to the first outgoing arc of
429 428
        /// the node.
430 429
        ///@param n the node
431 430
        ///@param g the graph
432 431
        OutArcIt(const Graph& n, const Node& g) {
433 432
          ignore_unused_variable_warning(n);
434 433
          ignore_unused_variable_warning(g);
435 434
        }
436 435
        /// Arc -> OutArcIt conversion
437 436

	
438 437
        /// Sets the iterator to the value of the trivial iterator.
439 438
        /// This feature necessitates that each time we
440 439
        /// iterate the arc-set, the iteration order is the same.
441 440
        OutArcIt(const Graph&, const Arc&) { }
442 441
        ///Next outgoing arc
443 442

	
444 443
        /// Assign the iterator to the next
445 444
        /// outgoing arc of the corresponding node.
446 445
        OutArcIt& operator++() { return *this; }
447 446
      };
448 447

	
449 448
      /// This iterator goes trough the incoming directed arcs of a node.
450 449

	
451 450
      /// This iterator goes trough the \e incoming arcs of a certain node
452 451
      /// of a graph.
453 452
      /// Its usage is quite simple, for example you can count the number
454 453
      /// of outgoing arcs of a node \c n
455 454
      /// in graph \c g of type \c Graph as follows.
456 455
      ///\code
457 456
      /// int count=0;
458 457
      /// for(Graph::InArcIt e(g, n); e!=INVALID; ++e) ++count;
459 458
      ///\endcode
460 459

	
461 460
      class InArcIt : public Arc {
462 461
      public:
463 462
        /// Default constructor
464 463

	
465 464
        /// @warning The default constructor sets the iterator
466 465
        /// to an undefined value.
467 466
        InArcIt() { }
468 467
        /// Copy constructor.
469 468

	
470 469
        /// Copy constructor.
471 470
        ///
472 471
        InArcIt(const InArcIt& e) : Arc(e) { }
473 472
        /// Initialize the iterator to be invalid.
474 473

	
475 474
        /// Initialize the iterator to be invalid.
476 475
        ///
477 476
        InArcIt(Invalid) { }
478 477
        /// This constructor sets the iterator to first incoming arc.
479 478

	
480 479
        /// This constructor set the iterator to the first incoming arc of
481 480
        /// the node.
482 481
        ///@param n the node
483 482
        ///@param g the graph
484 483
        InArcIt(const Graph& g, const Node& n) {
485 484
          ignore_unused_variable_warning(n);
486 485
          ignore_unused_variable_warning(g);
487 486
        }
488 487
        /// Arc -> InArcIt conversion
489 488

	
490 489
        /// Sets the iterator to the value of the trivial iterator \c e.
491 490
        /// This feature necessitates that each time we
492 491
        /// iterate the arc-set, the iteration order is the same.
493 492
        InArcIt(const Graph&, const Arc&) { }
494 493
        /// Next incoming arc
495 494

	
496 495
        /// Assign the iterator to the next inarc of the corresponding node.
497 496
        ///
498 497
        InArcIt& operator++() { return *this; }
499 498
      };
500 499

	
501 500
      /// \brief Read write map of the nodes to type \c T.
502 501
      ///
503 502
      /// ReadWrite map of the nodes to type \c T.
504 503
      /// \sa Reference
505 504
      template<class T>
506 505
      class NodeMap : public ReadWriteMap< Node, T >
507 506
      {
508 507
      public:
509 508

	
510 509
        ///\e
511 510
        NodeMap(const Graph&) { }
512 511
        ///\e
513 512
        NodeMap(const Graph&, T) { }
514 513

	
515 514
      private:
516 515
        ///Copy constructor
517 516
        NodeMap(const NodeMap& nm) : ReadWriteMap< Node, T >(nm) { }
518 517
        ///Assignment operator
519 518
        template <typename CMap>
520 519
        NodeMap& operator=(const CMap&) {
521 520
          checkConcept<ReadMap<Node, T>, CMap>();
522 521
          return *this;
523 522
        }
524 523
      };
525 524

	
526 525
      /// \brief Read write map of the directed arcs to type \c T.
527 526
      ///
528 527
      /// Reference map of the directed arcs to type \c T.
529 528
      /// \sa Reference
530 529
      template<class T>
531 530
      class ArcMap : public ReadWriteMap<Arc,T>
532 531
      {
533 532
      public:
534 533

	
535 534
        ///\e
536 535
        ArcMap(const Graph&) { }
537 536
        ///\e
538 537
        ArcMap(const Graph&, T) { }
539 538
      private:
540 539
        ///Copy constructor
541 540
        ArcMap(const ArcMap& em) : ReadWriteMap<Arc,T>(em) { }
542 541
        ///Assignment operator
543 542
        template <typename CMap>
544 543
        ArcMap& operator=(const CMap&) {
545 544
          checkConcept<ReadMap<Arc, T>, CMap>();
546 545
          return *this;
547 546
        }
548 547
      };
549 548

	
550 549
      /// Read write map of the edges to type \c T.
551 550

	
552 551
      /// Reference map of the arcs to type \c T.
553 552
      /// \sa Reference
554 553
      template<class T>
555 554
      class EdgeMap : public ReadWriteMap<Edge,T>
556 555
      {
557 556
      public:
558 557

	
559 558
        ///\e
560 559
        EdgeMap(const Graph&) { }
561 560
        ///\e
562 561
        EdgeMap(const Graph&, T) { }
563 562
      private:
564 563
        ///Copy constructor
565 564
        EdgeMap(const EdgeMap& em) : ReadWriteMap<Edge,T>(em) {}
566 565
        ///Assignment operator
567 566
        template <typename CMap>
568 567
        EdgeMap& operator=(const CMap&) {
569 568
          checkConcept<ReadMap<Edge, T>, CMap>();
570 569
          return *this;
571 570
        }
572 571
      };
573 572

	
574 573
      /// \brief Direct the given edge.
575 574
      ///
576 575
      /// Direct the given edge. The returned arc source
577 576
      /// will be the given node.
578 577
      Arc direct(const Edge&, const Node&) const {
579 578
        return INVALID;
580 579
      }
581 580

	
582 581
      /// \brief Direct the given edge.
583 582
      ///
584 583
      /// Direct the given edge. The returned arc
585 584
      /// represents the given edge and the direction comes
586 585
      /// from the bool parameter. The source of the edge and
587 586
      /// the directed arc is the same when the given bool is true.
588 587
      Arc direct(const Edge&, bool) const {
589 588
        return INVALID;
590 589
      }
591 590

	
592 591
      /// \brief Returns true if the arc has default orientation.
593 592
      ///
594 593
      /// Returns whether the given directed arc is same orientation as
595 594
      /// the corresponding edge's default orientation.
596 595
      bool direction(Arc) const { return true; }
597 596

	
598 597
      /// \brief Returns the opposite directed arc.
599 598
      ///
600 599
      /// Returns the opposite directed arc.
601 600
      Arc oppositeArc(Arc) const { return INVALID; }
602 601

	
603 602
      /// \brief Opposite node on an arc
604 603
      ///
605 604
      /// \return the opposite of the given Node on the given Edge
606 605
      Node oppositeNode(Node, Edge) const { return INVALID; }
607 606

	
608 607
      /// \brief First node of the edge.
609 608
      ///
610 609
      /// \return the first node of the given Edge.
611 610
      ///
612 611
      /// Naturally edges don't have direction and thus
613 612
      /// don't have source and target node. But we use these two methods
614 613
      /// to query the two nodes of the arc. The direction of the arc
615 614
      /// which arises this way is called the inherent direction of the
616 615
      /// edge, and is used to define the "default" direction
617 616
      /// of the directed versions of the arcs.
618 617
      /// \sa direction
619 618
      Node u(Edge) const { return INVALID; }
620 619

	
621 620
      /// \brief Second node of the edge.
622 621
      Node v(Edge) const { return INVALID; }
623 622

	
624 623
      /// \brief Source node of the directed arc.
625 624
      Node source(Arc) const { return INVALID; }
626 625

	
627 626
      /// \brief Target node of the directed arc.
628 627
      Node target(Arc) const { return INVALID; }
629 628

	
630 629
      /// \brief Returns the id of the node.
631 630
      int id(Node) const { return -1; }
632 631

	
633 632
      /// \brief Returns the id of the edge.
634 633
      int id(Edge) const { return -1; }
635 634

	
636 635
      /// \brief Returns the id of the arc.
637 636
      int id(Arc) const { return -1; }
638 637

	
639 638
      /// \brief Returns the node with the given id.
640 639
      ///
641 640
      /// \pre The argument should be a valid node id in the graph.
642 641
      Node nodeFromId(int) const { return INVALID; }
643 642

	
644 643
      /// \brief Returns the edge with the given id.
645 644
      ///
646 645
      /// \pre The argument should be a valid edge id in the graph.
647 646
      Edge edgeFromId(int) const { return INVALID; }
648 647

	
649 648
      /// \brief Returns the arc with the given id.
650 649
      ///
651 650
      /// \pre The argument should be a valid arc id in the graph.
652 651
      Arc arcFromId(int) const { return INVALID; }
653 652

	
654 653
      /// \brief Returns an upper bound on the node IDs.
655 654
      int maxNodeId() const { return -1; }
656 655

	
657 656
      /// \brief Returns an upper bound on the edge IDs.
658 657
      int maxEdgeId() const { return -1; }
659 658

	
660 659
      /// \brief Returns an upper bound on the arc IDs.
661 660
      int maxArcId() const { return -1; }
662 661

	
663 662
      void first(Node&) const {}
664 663
      void next(Node&) const {}
665 664

	
666 665
      void first(Edge&) const {}
667 666
      void next(Edge&) const {}
668 667

	
669 668
      void first(Arc&) const {}
670 669
      void next(Arc&) const {}
671 670

	
672 671
      void firstOut(Arc&, Node) const {}
673 672
      void nextOut(Arc&) const {}
674 673

	
675 674
      void firstIn(Arc&, Node) const {}
676 675
      void nextIn(Arc&) const {}
677 676

	
678 677
      void firstInc(Edge &, bool &, const Node &) const {}
679 678
      void nextInc(Edge &, bool &) const {}
680 679

	
681 680
      // The second parameter is dummy.
682 681
      Node fromId(int, Node) const { return INVALID; }
683 682
      // The second parameter is dummy.
684 683
      Edge fromId(int, Edge) const { return INVALID; }
685 684
      // The second parameter is dummy.
686 685
      Arc fromId(int, Arc) const { return INVALID; }
687 686

	
688 687
      // Dummy parameter.
689 688
      int maxId(Node) const { return -1; }
690 689
      // Dummy parameter.
691 690
      int maxId(Edge) const { return -1; }
692 691
      // Dummy parameter.
693 692
      int maxId(Arc) const { return -1; }
694 693

	
695 694
      /// \brief Base node of the iterator
696 695
      ///
697 696
      /// Returns the base node (the source in this case) of the iterator
698 697
      Node baseNode(OutArcIt e) const {
699 698
        return source(e);
700 699
      }
701 700
      /// \brief Running node of the iterator
702 701
      ///
703 702
      /// Returns the running node (the target in this case) of the
704 703
      /// iterator
705 704
      Node runningNode(OutArcIt e) const {
706 705
        return target(e);
707 706
      }
708 707

	
709 708
      /// \brief Base node of the iterator
710 709
      ///
711 710
      /// Returns the base node (the target in this case) of the iterator
712 711
      Node baseNode(InArcIt e) const {
713 712
        return target(e);
714 713
      }
715 714
      /// \brief Running node of the iterator
716 715
      ///
717 716
      /// Returns the running node (the source in this case) of the
718 717
      /// iterator
719 718
      Node runningNode(InArcIt e) const {
720 719
        return source(e);
721 720
      }
722 721

	
723 722
      /// \brief Base node of the iterator
724 723
      ///
725 724
      /// Returns the base node of the iterator
726 725
      Node baseNode(IncEdgeIt) const {
727 726
        return INVALID;
728 727
      }
729 728

	
730 729
      /// \brief Running node of the iterator
731 730
      ///
732 731
      /// Returns the running node of the iterator
733 732
      Node runningNode(IncEdgeIt) const {
734 733
        return INVALID;
735 734
      }
736 735

	
737 736
      template <typename _Graph>
738 737
      struct Constraints {
739 738
        void constraints() {
740 739
          checkConcept<IterableGraphComponent<>, _Graph>();
741 740
          checkConcept<IDableGraphComponent<>, _Graph>();
742 741
          checkConcept<MappableGraphComponent<>, _Graph>();
743 742
        }
744 743
      };
745 744

	
746 745
    };
747 746

	
748 747
  }
749 748

	
750 749
}
751 750

	
752 751
#endif
Ignore white space 6 line context
1 1
/* -*- mode: C++; indent-tabs-mode: nil; -*-
2 2
 *
3 3
 * This file is a part of LEMON, a generic C++ optimization library.
4 4
 *
5 5
 * Copyright (C) 2003-2009
6 6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8 8
 *
9 9
 * Permission to use, modify and distribute this software is granted
10 10
 * provided that this copyright notice appears in all copies. For
11 11
 * precise terms see the accompanying LICENSE file.
12 12
 *
13 13
 * This software is provided "AS IS" with no warranty of any kind,
14 14
 * express or implied, and with no claim as to its suitability for any
15 15
 * purpose.
16 16
 *
17 17
 */
18 18

	
19 19
///\ingroup graph_concepts
20 20
///\file
21 21
///\brief The concept of graph components.
22 22

	
23 23

	
24
#ifndef LEMON_CONCEPT_GRAPH_COMPONENTS_H
25
#define LEMON_CONCEPT_GRAPH_COMPONENTS_H
24
#ifndef LEMON_CONCEPTS_GRAPH_COMPONENTS_H
25
#define LEMON_CONCEPTS_GRAPH_COMPONENTS_H
26 26

	
27 27
#include <lemon/core.h>
28 28
#include <lemon/concepts/maps.h>
29 29

	
30 30
#include <lemon/bits/alteration_notifier.h>
31 31

	
32 32
namespace lemon {
33 33
  namespace concepts {
34 34

	
35 35
    /// \brief Skeleton class for graph Node and Arc types
36 36
    ///
37 37
    /// This class describes the interface of Node and Arc (and Edge
38 38
    /// in undirected graphs) subtypes of graph types.
39 39
    ///
40 40
    /// \note This class is a template class so that we can use it to
41 41
    /// create graph skeleton classes. The reason for this is than Node
42 42
    /// and Arc types should \em not derive from the same base class.
43 43
    /// For Node you should instantiate it with character 'n' and for Arc
44 44
    /// with 'a'.
45 45

	
46 46
#ifndef DOXYGEN
47 47
    template <char _selector = '0'>
48 48
#endif
49 49
    class GraphItem {
50 50
    public:
51 51
      /// \brief Default constructor.
52 52
      ///
53 53
      /// \warning The default constructor is not required to set
54 54
      /// the item to some well-defined value. So you should consider it
55 55
      /// as uninitialized.
56 56
      GraphItem() {}
57 57
      /// \brief Copy constructor.
58 58
      ///
59 59
      /// Copy constructor.
60 60
      ///
61 61
      GraphItem(const GraphItem &) {}
62 62
      /// \brief Invalid constructor \& conversion.
63 63
      ///
64 64
      /// This constructor initializes the item to be invalid.
65 65
      /// \sa Invalid for more details.
66 66
      GraphItem(Invalid) {}
67 67
      /// \brief Assign operator for nodes.
68 68
      ///
69 69
      /// The nodes are assignable.
70 70
      ///
71 71
      GraphItem& operator=(GraphItem const&) { return *this; }
72 72
      /// \brief Equality operator.
73 73
      ///
74 74
      /// Two iterators are equal if and only if they represents the
75 75
      /// same node in the graph or both are invalid.
76 76
      bool operator==(GraphItem) const { return false; }
77 77
      /// \brief Inequality operator.
78 78
      ///
79 79
      /// \sa operator==(const Node& n)
80 80
      ///
81 81
      bool operator!=(GraphItem) const { return false; }
82 82

	
83 83
      /// \brief Artificial ordering operator.
84 84
      ///
85 85
      /// To allow the use of graph descriptors as key type in std::map or
86 86
      /// similar associative container we require this.
87 87
      ///
88 88
      /// \note This operator only have to define some strict ordering of
89 89
      /// the items; this order has nothing to do with the iteration
90 90
      /// ordering of the items.
91 91
      bool operator<(GraphItem) const { return false; }
92 92

	
93 93
      template<typename _GraphItem>
94 94
      struct Constraints {
95 95
        void constraints() {
96 96
          _GraphItem i1;
97 97
          _GraphItem i2 = i1;
98 98
          _GraphItem i3 = INVALID;
99 99

	
100 100
          i1 = i2 = i3;
101 101

	
102 102
          bool b;
103 103
          //          b = (ia == ib) && (ia != ib) && (ia < ib);
104 104
          b = (ia == ib) && (ia != ib);
105 105
          b = (ia == INVALID) && (ib != INVALID);
106 106
          b = (ia < ib);
107 107
        }
108 108

	
109 109
        const _GraphItem &ia;
110 110
        const _GraphItem &ib;
111 111
      };
112 112
    };
113 113

	
114 114
    /// \brief An empty base directed graph class.
115 115
    ///
116 116
    /// This class provides the minimal set of features needed for a
117 117
    /// directed graph structure. All digraph concepts have to be
118 118
    /// conform to this base directed graph. It just provides types
119 119
    /// for nodes and arcs and functions to get the source and the
120 120
    /// target of the arcs.
121 121
    class BaseDigraphComponent {
122 122
    public:
123 123

	
124 124
      typedef BaseDigraphComponent Digraph;
125 125

	
126 126
      /// \brief Node class of the digraph.
127 127
      ///
128 128
      /// This class represents the Nodes of the digraph.
129 129
      ///
130 130
      typedef GraphItem<'n'> Node;
131 131

	
132 132
      /// \brief Arc class of the digraph.
133 133
      ///
134 134
      /// This class represents the Arcs of the digraph.
135 135
      ///
136 136
      typedef GraphItem<'e'> Arc;
137 137

	
138 138
      /// \brief Gives back the target node of an arc.
139 139
      ///
140 140
      /// Gives back the target node of an arc.
141 141
      ///
142 142
      Node target(const Arc&) const { return INVALID;}
143 143

	
144 144
      /// \brief Gives back the source node of an arc.
145 145
      ///
146 146
      /// Gives back the source node of an arc.
147 147
      ///
148 148
      Node source(const Arc&) const { return INVALID;}
149 149

	
150 150
      /// \brief Gives back the opposite node on the given arc.
151 151
      ///
152 152
      /// Gives back the opposite node on the given arc.
153 153
      Node oppositeNode(const Node&, const Arc&) const {
154 154
        return INVALID;
155 155
      }
156 156

	
157 157
      template <typename _Digraph>
158 158
      struct Constraints {
159 159
        typedef typename _Digraph::Node Node;
160 160
        typedef typename _Digraph::Arc Arc;
161 161

	
162 162
        void constraints() {
163 163
          checkConcept<GraphItem<'n'>, Node>();
164 164
          checkConcept<GraphItem<'a'>, Arc>();
165 165
          {
166 166
            Node n;
167 167
            Arc e(INVALID);
168 168
            n = digraph.source(e);
169 169
            n = digraph.target(e);
170 170
            n = digraph.oppositeNode(n, e);
171 171
          }
172 172
        }
173 173

	
174 174
        const _Digraph& digraph;
175 175
      };
176 176
    };
177 177

	
178 178
    /// \brief An empty base undirected graph class.
179 179
    ///
180 180
    /// This class provides the minimal set of features needed for an
181 181
    /// undirected graph structure. All undirected graph concepts have
182 182
    /// to be conform to this base graph. It just provides types for
183 183
    /// nodes, arcs and edges and functions to get the
184 184
    /// source and the target of the arcs and edges,
185 185
    /// conversion from arcs to edges and function to get
186 186
    /// both direction of the edges.
187 187
    class BaseGraphComponent : public BaseDigraphComponent {
188 188
    public:
189 189
      typedef BaseDigraphComponent::Node Node;
190 190
      typedef BaseDigraphComponent::Arc Arc;
191 191
      /// \brief Undirected arc class of the graph.
192 192
      ///
193 193
      /// This class represents the edges of the graph.
194 194
      /// The undirected graphs can be used as a directed graph which
195 195
      /// for each arc contains the opposite arc too so the graph is
196 196
      /// bidirected. The edge represents two opposite
197 197
      /// directed arcs.
198 198
      class Edge : public GraphItem<'u'> {
199 199
      public:
200 200
        typedef GraphItem<'u'> Parent;
201 201
        /// \brief Default constructor.
202 202
        ///
203 203
        /// \warning The default constructor is not required to set
204 204
        /// the item to some well-defined value. So you should consider it
205 205
        /// as uninitialized.
206 206
        Edge() {}
207 207
        /// \brief Copy constructor.
208 208
        ///
209 209
        /// Copy constructor.
210 210
        ///
211 211
        Edge(const Edge &) : Parent() {}
212 212
        /// \brief Invalid constructor \& conversion.
213 213
        ///
214 214
        /// This constructor initializes the item to be invalid.
215 215
        /// \sa Invalid for more details.
216 216
        Edge(Invalid) {}
217 217
        /// \brief Converter from arc to edge.
218 218
        ///
219 219
        /// Besides the core graph item functionality each arc should
220 220
        /// be convertible to the represented edge.
221 221
        Edge(const Arc&) {}
222 222
        /// \brief Assign arc to edge.
223 223
        ///
224 224
        /// Besides the core graph item functionality each arc should
225 225
        /// be convertible to the represented edge.
226 226
        Edge& operator=(const Arc&) { return *this; }
227 227
      };
228 228

	
229 229
      /// \brief Returns the direction of the arc.
230 230
      ///
231 231
      /// Returns the direction of the arc. Each arc represents an
232 232
      /// edge with a direction. It gives back the
233 233
      /// direction.
234 234
      bool direction(const Arc&) const { return true; }
235 235

	
236 236
      /// \brief Returns the directed arc.
237 237
      ///
238 238
      /// Returns the directed arc from its direction and the
239 239
      /// represented edge.
240 240
      Arc direct(const Edge&, bool) const { return INVALID;}
241 241

	
242 242
      /// \brief Returns the directed arc.
243 243
      ///
244 244
      /// Returns the directed arc from its source and the
245 245
      /// represented edge.
246 246
      Arc direct(const Edge&, const Node&) const { return INVALID;}
247 247

	
248 248
      /// \brief Returns the opposite arc.
249 249
      ///
250 250
      /// Returns the opposite arc. It is the arc representing the
251 251
      /// same edge and has opposite direction.
252 252
      Arc oppositeArc(const Arc&) const { return INVALID;}
253 253

	
254 254
      /// \brief Gives back one ending of an edge.
255 255
      ///
256 256
      /// Gives back one ending of an edge.
257 257
      Node u(const Edge&) const { return INVALID;}
258 258

	
259 259
      /// \brief Gives back the other ending of an edge.
260 260
      ///
261 261
      /// Gives back the other ending of an edge.
262 262
      Node v(const Edge&) const { return INVALID;}
263 263

	
264 264
      template <typename _Graph>
265 265
      struct Constraints {
266 266
        typedef typename _Graph::Node Node;
267 267
        typedef typename _Graph::Arc Arc;
268 268
        typedef typename _Graph::Edge Edge;
269 269

	
270 270
        void constraints() {
271 271
          checkConcept<BaseDigraphComponent, _Graph>();
272 272
          checkConcept<GraphItem<'u'>, Edge>();
273 273
          {
274 274
            Node n;
275 275
            Edge ue(INVALID);
276 276
            Arc e;
277 277
            n = graph.u(ue);
278 278
            n = graph.v(ue);
279 279
            e = graph.direct(ue, true);
280 280
            e = graph.direct(ue, n);
281 281
            e = graph.oppositeArc(e);
282 282
            ue = e;
283 283
            bool d = graph.direction(e);
284 284
            ignore_unused_variable_warning(d);
285 285
          }
286 286
        }
287 287

	
288 288
        const _Graph& graph;
289 289
      };
290 290

	
291 291
    };
292 292

	
293 293
    /// \brief An empty idable base digraph class.
294 294
    ///
295 295
    /// This class provides beside the core digraph features
296 296
    /// core id functions for the digraph structure.
297 297
    /// The most of the base digraphs should be conform to this concept.
298 298
    /// The id's are unique and immutable.
299 299
    template <typename _Base = BaseDigraphComponent>
300 300
    class IDableDigraphComponent : public _Base {
301 301
    public:
302 302

	
303 303
      typedef _Base Base;
304 304
      typedef typename Base::Node Node;
305 305
      typedef typename Base::Arc Arc;
306 306

	
307 307
      /// \brief Gives back an unique integer id for the Node.
308 308
      ///
309 309
      /// Gives back an unique integer id for the Node.
310 310
      ///
311 311
      int id(const Node&) const { return -1;}
312 312

	
313 313
      /// \brief Gives back the node by the unique id.
314 314
      ///
315 315
      /// Gives back the node by the unique id.
316 316
      /// If the digraph does not contain node with the given id
317 317
      /// then the result of the function is undetermined.
318 318
      Node nodeFromId(int) const { return INVALID;}
319 319

	
320 320
      /// \brief Gives back an unique integer id for the Arc.
321 321
      ///
322 322
      /// Gives back an unique integer id for the Arc.
323 323
      ///
324 324
      int id(const Arc&) const { return -1;}
325 325

	
326 326
      /// \brief Gives back the arc by the unique id.
327 327
      ///
328 328
      /// Gives back the arc by the unique id.
329 329
      /// If the digraph does not contain arc with the given id
330 330
      /// then the result of the function is undetermined.
331 331
      Arc arcFromId(int) const { return INVALID;}
332 332

	
333 333
      /// \brief Gives back an integer greater or equal to the maximum
334 334
      /// Node id.
335 335
      ///
336 336
      /// Gives back an integer greater or equal to the maximum Node
337 337
      /// id.
338 338
      int maxNodeId() const { return -1;}
339 339

	
340 340
      /// \brief Gives back an integer greater or equal to the maximum
341 341
      /// Arc id.
342 342
      ///
343 343
      /// Gives back an integer greater or equal to the maximum Arc
344 344
      /// id.
345 345
      int maxArcId() const { return -1;}
346 346

	
347 347
      template <typename _Digraph>
348 348
      struct Constraints {
349 349

	
350 350
        void constraints() {
351 351
          checkConcept<Base, _Digraph >();
352 352
          typename _Digraph::Node node;
353 353
          int nid = digraph.id(node);
354 354
          nid = digraph.id(node);
355 355
          node = digraph.nodeFromId(nid);
356 356
          typename _Digraph::Arc arc;
357 357
          int eid = digraph.id(arc);
358 358
          eid = digraph.id(arc);
359 359
          arc = digraph.arcFromId(eid);
360 360

	
361 361
          nid = digraph.maxNodeId();
362 362
          ignore_unused_variable_warning(nid);
363 363
          eid = digraph.maxArcId();
364 364
          ignore_unused_variable_warning(eid);
365 365
        }
366 366

	
367 367
        const _Digraph& digraph;
368 368
      };
369 369
    };
370 370

	
371 371
    /// \brief An empty idable base undirected graph class.
372 372
    ///
373 373
    /// This class provides beside the core undirected graph features
374 374
    /// core id functions for the undirected graph structure.  The
375 375
    /// most of the base undirected graphs should be conform to this
376 376
    /// concept.  The id's are unique and immutable.
377 377
    template <typename _Base = BaseGraphComponent>
378 378
    class IDableGraphComponent : public IDableDigraphComponent<_Base> {
379 379
    public:
380 380

	
381 381
      typedef _Base Base;
382 382
      typedef typename Base::Edge Edge;
383 383

	
384 384
      using IDableDigraphComponent<_Base>::id;
385 385

	
386 386
      /// \brief Gives back an unique integer id for the Edge.
387 387
      ///
388 388
      /// Gives back an unique integer id for the Edge.
389 389
      ///
390 390
      int id(const Edge&) const { return -1;}
391 391

	
392 392
      /// \brief Gives back the edge by the unique id.
393 393
      ///
394 394
      /// Gives back the edge by the unique id.  If the
395 395
      /// graph does not contain arc with the given id then the
396 396
      /// result of the function is undetermined.
397 397
      Edge edgeFromId(int) const { return INVALID;}
398 398

	
399 399
      /// \brief Gives back an integer greater or equal to the maximum
400 400
      /// Edge id.
401 401
      ///
402 402
      /// Gives back an integer greater or equal to the maximum Edge
403 403
      /// id.
404 404
      int maxEdgeId() const { return -1;}
405 405

	
406 406
      template <typename _Graph>
407 407
      struct Constraints {
408 408

	
409 409
        void constraints() {
410 410
          checkConcept<Base, _Graph >();
411 411
          checkConcept<IDableDigraphComponent<Base>, _Graph >();
412 412
          typename _Graph::Edge edge;
413 413
          int ueid = graph.id(edge);
414 414
          ueid = graph.id(edge);
415 415
          edge = graph.edgeFromId(ueid);
416 416
          ueid = graph.maxEdgeId();
417 417
          ignore_unused_variable_warning(ueid);
418 418
        }
419 419

	
420 420
        const _Graph& graph;
421 421
      };
422 422
    };
423 423

	
424 424
    /// \brief Skeleton class for graph NodeIt and ArcIt
425 425
    ///
426 426
    /// Skeleton class for graph NodeIt and ArcIt.
427 427
    ///
428 428
    template <typename _Graph, typename _Item>
429 429
    class GraphItemIt : public _Item {
430 430
    public:
431 431
      /// \brief Default constructor.
432 432
      ///
433 433
      /// @warning The default constructor sets the iterator
434 434
      /// to an undefined value.
435 435
      GraphItemIt() {}
436 436
      /// \brief Copy constructor.
437 437
      ///
438 438
      /// Copy constructor.
439 439
      ///
440 440
      GraphItemIt(const GraphItemIt& ) {}
441 441
      /// \brief Sets the iterator to the first item.
442 442
      ///
443 443
      /// Sets the iterator to the first item of \c the graph.
444 444
      ///
445 445
      explicit GraphItemIt(const _Graph&) {}
446 446
      /// \brief Invalid constructor \& conversion.
447 447
      ///
448 448
      /// This constructor initializes the item to be invalid.
449 449
      /// \sa Invalid for more details.
450 450
      GraphItemIt(Invalid) {}
451 451
      /// \brief Assign operator for items.
452 452
      ///
453 453
      /// The items are assignable.
454 454
      ///
455 455
      GraphItemIt& operator=(const GraphItemIt&) { return *this; }
456 456
      /// \brief Next item.
457 457
      ///
458 458
      /// Assign the iterator to the next item.
459 459
      ///
460 460
      GraphItemIt& operator++() { return *this; }
461 461
      /// \brief Equality operator
462 462
      ///
463 463
      /// Two iterators are equal if and only if they point to the
464 464
      /// same object or both are invalid.
465 465
      bool operator==(const GraphItemIt&) const { return true;}
466 466
      /// \brief Inequality operator
467 467
      ///
468 468
      /// \sa operator==(Node n)
469 469
      ///
470 470
      bool operator!=(const GraphItemIt&) const { return true;}
471 471

	
472 472
      template<typename _GraphItemIt>
473 473
      struct Constraints {
474 474
        void constraints() {
475 475
          _GraphItemIt it1(g);
476 476
          _GraphItemIt it2;
477 477

	
478 478
          it2 = ++it1;
479 479
          ++it2 = it1;
480 480
          ++(++it1);
481 481

	
482 482
          _Item bi = it1;
483 483
          bi = it2;
484 484
        }
485 485
        _Graph& g;
486 486
      };
487 487
    };
488 488

	
489 489
    /// \brief Skeleton class for graph InArcIt and OutArcIt
490 490
    ///
491 491
    /// \note Because InArcIt and OutArcIt may not inherit from the same
492 492
    /// base class, the _selector is a additional template parameter. For
493 493
    /// InArcIt you should instantiate it with character 'i' and for
494 494
    /// OutArcIt with 'o'.
495 495
    template <typename _Graph,
496 496
              typename _Item = typename _Graph::Arc,
497 497
              typename _Base = typename _Graph::Node,
498 498
              char _selector = '0'>
499 499
    class GraphIncIt : public _Item {
500 500
    public:
501 501
      /// \brief Default constructor.
502 502
      ///
503 503
      /// @warning The default constructor sets the iterator
504 504
      /// to an undefined value.
505 505
      GraphIncIt() {}
506 506
      /// \brief Copy constructor.
507 507
      ///
508 508
      /// Copy constructor.
509 509
      ///
510 510
      GraphIncIt(GraphIncIt const& gi) : _Item(gi) {}
511 511
      /// \brief Sets the iterator to the first arc incoming into or outgoing
512 512
      /// from the node.
513 513
      ///
514 514
      /// Sets the iterator to the first arc incoming into or outgoing
515 515
      /// from the node.
516 516
      ///
517 517
      explicit GraphIncIt(const _Graph&, const _Base&) {}
518 518
      /// \brief Invalid constructor \& conversion.
519 519
      ///
520 520
      /// This constructor initializes the item to be invalid.
521 521
      /// \sa Invalid for more details.
522 522
      GraphIncIt(Invalid) {}
523 523
      /// \brief Assign operator for iterators.
524 524
      ///
525 525
      /// The iterators are assignable.
526 526
      ///
527 527
      GraphIncIt& operator=(GraphIncIt const&) { return *this; }
528 528
      /// \brief Next item.
529 529
      ///
530 530
      /// Assign the iterator to the next item.
531 531
      ///
532 532
      GraphIncIt& operator++() { return *this; }
533 533

	
534 534
      /// \brief Equality operator
535 535
      ///
536 536
      /// Two iterators are equal if and only if they point to the
537 537
      /// same object or both are invalid.
538 538
      bool operator==(const GraphIncIt&) const { return true;}
539 539

	
540 540
      /// \brief Inequality operator
541 541
      ///
542 542
      /// \sa operator==(Node n)
543 543
      ///
544 544
      bool operator!=(const GraphIncIt&) const { return true;}
545 545

	
546 546
      template <typename _GraphIncIt>
547 547
      struct Constraints {
548 548
        void constraints() {
549 549
          checkConcept<GraphItem<_selector>, _GraphIncIt>();
550 550
          _GraphIncIt it1(graph, node);
551 551
          _GraphIncIt it2;
552 552

	
553 553
          it2 = ++it1;
554 554
          ++it2 = it1;
555 555
          ++(++it1);
556 556
          _Item e = it1;
557 557
          e = it2;
558 558

	
559 559
        }
560 560

	
561 561
        _Item arc;
562 562
        _Base node;
563 563
        _Graph graph;
564 564
        _GraphIncIt it;
565 565
      };
566 566
    };
567 567

	
568 568

	
569 569
    /// \brief An empty iterable digraph class.
570 570
    ///
571 571
    /// This class provides beside the core digraph features
572 572
    /// iterator based iterable interface for the digraph structure.
573 573
    /// This concept is part of the Digraph concept.
574 574
    template <typename _Base = BaseDigraphComponent>
575 575
    class IterableDigraphComponent : public _Base {
576 576

	
577 577
    public:
578 578

	
579 579
      typedef _Base Base;
580 580
      typedef typename Base::Node Node;
581 581
      typedef typename Base::Arc Arc;
582 582

	
583 583
      typedef IterableDigraphComponent Digraph;
584 584

	
585 585
      /// \name Base iteration
586 586
      ///
587 587
      /// This interface provides functions for iteration on digraph items
588 588
      ///
589 589
      /// @{
590 590

	
591 591
      /// \brief Gives back the first node in the iterating order.
592 592
      ///
593 593
      /// Gives back the first node in the iterating order.
594 594
      ///
595 595
      void first(Node&) const {}
596 596

	
597 597
      /// \brief Gives back the next node in the iterating order.
598 598
      ///
599 599
      /// Gives back the next node in the iterating order.
600 600
      ///
601 601
      void next(Node&) const {}
602 602

	
603 603
      /// \brief Gives back the first arc in the iterating order.
604 604
      ///
605 605
      /// Gives back the first arc in the iterating order.
606 606
      ///
607 607
      void first(Arc&) const {}
608 608

	
609 609
      /// \brief Gives back the next arc in the iterating order.
610 610
      ///
611 611
      /// Gives back the next arc in the iterating order.
612 612
      ///
613 613
      void next(Arc&) const {}
614 614

	
615 615

	
616 616
      /// \brief Gives back the first of the arcs point to the given
617 617
      /// node.
618 618
      ///
619 619
      /// Gives back the first of the arcs point to the given node.
620 620
      ///
621 621
      void firstIn(Arc&, const Node&) const {}
622 622

	
623 623
      /// \brief Gives back the next of the arcs points to the given
624 624
      /// node.
625 625
      ///
626 626
      /// Gives back the next of the arcs points to the given node.
627 627
      ///
628 628
      void nextIn(Arc&) const {}
629 629

	
630 630
      /// \brief Gives back the first of the arcs start from the
631 631
      /// given node.
632 632
      ///
633 633
      /// Gives back the first of the arcs start from the given node.
634 634
      ///
635 635
      void firstOut(Arc&, const Node&) const {}
636 636

	
637 637
      /// \brief Gives back the next of the arcs start from the given
638 638
      /// node.
639 639
      ///
640 640
      /// Gives back the next of the arcs start from the given node.
641 641
      ///
642 642
      void nextOut(Arc&) const {}
643 643

	
644 644
      /// @}
645 645

	
646 646
      /// \name Class based iteration
647 647
      ///
648 648
      /// This interface provides functions for iteration on digraph items
649 649
      ///
650 650
      /// @{
651 651

	
652 652
      /// \brief This iterator goes through each node.
653 653
      ///
654 654
      /// This iterator goes through each node.
655 655
      ///
656 656
      typedef GraphItemIt<Digraph, Node> NodeIt;
657 657

	
658 658
      /// \brief This iterator goes through each node.
659 659
      ///
660 660
      /// This iterator goes through each node.
661 661
      ///
662 662
      typedef GraphItemIt<Digraph, Arc> ArcIt;
663 663

	
664 664
      /// \brief This iterator goes trough the incoming arcs of a node.
665 665
      ///
666 666
      /// This iterator goes trough the \e inccoming arcs of a certain node
667 667
      /// of a digraph.
668 668
      typedef GraphIncIt<Digraph, Arc, Node, 'i'> InArcIt;
669 669

	
670 670
      /// \brief This iterator goes trough the outgoing arcs of a node.
671 671
      ///
672 672
      /// This iterator goes trough the \e outgoing arcs of a certain node
673 673
      /// of a digraph.
674 674
      typedef GraphIncIt<Digraph, Arc, Node, 'o'> OutArcIt;
675 675

	
676 676
      /// \brief The base node of the iterator.
677 677
      ///
678 678
      /// Gives back the base node of the iterator.
679 679
      /// It is always the target of the pointed arc.
680 680
      Node baseNode(const InArcIt&) const { return INVALID; }
681 681

	
682 682
      /// \brief The running node of the iterator.
683 683
      ///
684 684
      /// Gives back the running node of the iterator.
685 685
      /// It is always the source of the pointed arc.
686 686
      Node runningNode(const InArcIt&) const { return INVALID; }
687 687

	
688 688
      /// \brief The base node of the iterator.
689 689
      ///
690 690
      /// Gives back the base node of the iterator.
691 691
      /// It is always the source of the pointed arc.
692 692
      Node baseNode(const OutArcIt&) const { return INVALID; }
693 693

	
694 694
      /// \brief The running node of the iterator.
695 695
      ///
696 696
      /// Gives back the running node of the iterator.
697 697
      /// It is always the target of the pointed arc.
698 698
      Node runningNode(const OutArcIt&) const { return INVALID; }
699 699

	
700 700
      /// @}
701 701

	
702 702
      template <typename _Digraph>
703 703
      struct Constraints {
704 704
        void constraints() {
705 705
          checkConcept<Base, _Digraph>();
706 706

	
707 707
          {
708 708
            typename _Digraph::Node node(INVALID);
709 709
            typename _Digraph::Arc arc(INVALID);
710 710
            {
711 711
              digraph.first(node);
712 712
              digraph.next(node);
713 713
            }
714 714
            {
715 715
              digraph.first(arc);
716 716
              digraph.next(arc);
717 717
            }
718 718
            {
719 719
              digraph.firstIn(arc, node);
720 720
              digraph.nextIn(arc);
721 721
            }
722 722
            {
723 723
              digraph.firstOut(arc, node);
724 724
              digraph.nextOut(arc);
725 725
            }
726 726
          }
727 727

	
728 728
          {
729 729
            checkConcept<GraphItemIt<_Digraph, typename _Digraph::Arc>,
730 730
              typename _Digraph::ArcIt >();
731 731
            checkConcept<GraphItemIt<_Digraph, typename _Digraph::Node>,
732 732
              typename _Digraph::NodeIt >();
733 733
            checkConcept<GraphIncIt<_Digraph, typename _Digraph::Arc,
734 734
              typename _Digraph::Node, 'i'>, typename _Digraph::InArcIt>();
735 735
            checkConcept<GraphIncIt<_Digraph, typename _Digraph::Arc,
736 736
              typename _Digraph::Node, 'o'>, typename _Digraph::OutArcIt>();
737 737

	
738 738
            typename _Digraph::Node n;
739 739
            typename _Digraph::InArcIt ieit(INVALID);
740 740
            typename _Digraph::OutArcIt oeit(INVALID);
741 741
            n = digraph.baseNode(ieit);
742 742
            n = digraph.runningNode(ieit);
743 743
            n = digraph.baseNode(oeit);
744 744
            n = digraph.runningNode(oeit);
745 745
            ignore_unused_variable_warning(n);
746 746
          }
747 747
        }
748 748

	
749 749
        const _Digraph& digraph;
750 750

	
751 751
      };
752 752
    };
753 753

	
754 754
    /// \brief An empty iterable undirected graph class.
755 755
    ///
756 756
    /// This class provides beside the core graph features iterator
757 757
    /// based iterable interface for the undirected graph structure.
758 758
    /// This concept is part of the Graph concept.
759 759
    template <typename _Base = BaseGraphComponent>
760 760
    class IterableGraphComponent : public IterableDigraphComponent<_Base> {
761 761
    public:
762 762

	
763 763
      typedef _Base Base;
764 764
      typedef typename Base::Node Node;
765 765
      typedef typename Base::Arc Arc;
766 766
      typedef typename Base::Edge Edge;
767 767

	
768 768

	
769 769
      typedef IterableGraphComponent Graph;
770 770

	
771 771
      /// \name Base iteration
772 772
      ///
773 773
      /// This interface provides functions for iteration on graph items
774 774
      /// @{
775 775

	
776 776
      using IterableDigraphComponent<_Base>::first;
777 777
      using IterableDigraphComponent<_Base>::next;
778 778

	
779 779
      /// \brief Gives back the first edge in the iterating
780 780
      /// order.
781 781
      ///
782 782
      /// Gives back the first edge in the iterating order.
783 783
      ///
784 784
      void first(Edge&) const {}
785 785

	
786 786
      /// \brief Gives back the next edge in the iterating
787 787
      /// order.
788 788
      ///
789 789
      /// Gives back the next edge in the iterating order.
790 790
      ///
791 791
      void next(Edge&) const {}
792 792

	
793 793

	
794 794
      /// \brief Gives back the first of the edges from the
795 795
      /// given node.
796 796
      ///
797 797
      /// Gives back the first of the edges from the given
798 798
      /// node. The bool parameter gives back that direction which
799 799
      /// gives a good direction of the edge so the source of the
800 800
      /// directed arc is the given node.
801 801
      void firstInc(Edge&, bool&, const Node&) const {}
802 802

	
803 803
      /// \brief Gives back the next of the edges from the
804 804
      /// given node.
805 805
      ///
806 806
      /// Gives back the next of the edges from the given
807 807
      /// node. The bool parameter should be used as the \c firstInc()
808 808
      /// use it.
809 809
      void nextInc(Edge&, bool&) const {}
810 810

	
811 811
      using IterableDigraphComponent<_Base>::baseNode;
812 812
      using IterableDigraphComponent<_Base>::runningNode;
813 813

	
814 814
      /// @}
815 815

	
816 816
      /// \name Class based iteration
817 817
      ///
818 818
      /// This interface provides functions for iteration on graph items
819 819
      ///
820 820
      /// @{
821 821

	
822 822
      /// \brief This iterator goes through each node.
823 823
      ///
824 824
      /// This iterator goes through each node.
825 825
      typedef GraphItemIt<Graph, Edge> EdgeIt;
826 826
      /// \brief This iterator goes trough the incident arcs of a
827 827
      /// node.
828 828
      ///
829 829
      /// This iterator goes trough the incident arcs of a certain
830 830
      /// node of a graph.
831 831
      typedef GraphIncIt<Graph, Edge, Node, 'u'> IncEdgeIt;
832 832
      /// \brief The base node of the iterator.
833 833
      ///
834 834
      /// Gives back the base node of the iterator.
835 835
      Node baseNode(const IncEdgeIt&) const { return INVALID; }
836 836

	
837 837
      /// \brief The running node of the iterator.
838 838
      ///
839 839
      /// Gives back the running node of the iterator.
840 840
      Node runningNode(const IncEdgeIt&) const { return INVALID; }
841 841

	
842 842
      /// @}
843 843

	
844 844
      template <typename _Graph>
845 845
      struct Constraints {
846 846
        void constraints() {
847 847
          checkConcept<IterableDigraphComponent<Base>, _Graph>();
848 848

	
849 849
          {
850 850
            typename _Graph::Node node(INVALID);
851 851
            typename _Graph::Edge edge(INVALID);
852 852
            bool dir;
853 853
            {
854 854
              graph.first(edge);
855 855
              graph.next(edge);
856 856
            }
857 857
            {
858 858
              graph.firstInc(edge, dir, node);
859 859
              graph.nextInc(edge, dir);
860 860
            }
861 861

	
862 862
          }
863 863

	
864 864
          {
865 865
            checkConcept<GraphItemIt<_Graph, typename _Graph::Edge>,
866 866
              typename _Graph::EdgeIt >();
867 867
            checkConcept<GraphIncIt<_Graph, typename _Graph::Edge,
868 868
              typename _Graph::Node, 'u'>, typename _Graph::IncEdgeIt>();
869 869

	
870 870
            typename _Graph::Node n;
871 871
            typename _Graph::IncEdgeIt ueit(INVALID);
872 872
            n = graph.baseNode(ueit);
873 873
            n = graph.runningNode(ueit);
874 874
          }
875 875
        }
876 876

	
877 877
        const _Graph& graph;
878 878

	
879 879
      };
880 880
    };
881 881

	
882 882
    /// \brief An empty alteration notifier digraph class.
883 883
    ///
884 884
    /// This class provides beside the core digraph features alteration
885 885
    /// notifier interface for the digraph structure.  This implements
886 886
    /// an observer-notifier pattern for each digraph item. More
887 887
    /// obsevers can be registered into the notifier and whenever an
888 888
    /// alteration occured in the digraph all the observers will
889 889
    /// notified about it.
890 890
    template <typename _Base = BaseDigraphComponent>
891 891
    class AlterableDigraphComponent : public _Base {
892 892
    public:
893 893

	
894 894
      typedef _Base Base;
895 895
      typedef typename Base::Node Node;
896 896
      typedef typename Base::Arc Arc;
897 897

	
898 898

	
899 899
      /// The node observer registry.
900 900
      typedef AlterationNotifier<AlterableDigraphComponent, Node>
901 901
      NodeNotifier;
902 902
      /// The arc observer registry.
903 903
      typedef AlterationNotifier<AlterableDigraphComponent, Arc>
904 904
      ArcNotifier;
905 905

	
906 906
      /// \brief Gives back the node alteration notifier.
907 907
      ///
908 908
      /// Gives back the node alteration notifier.
909 909
      NodeNotifier& notifier(Node) const {
910 910
        return NodeNotifier();
911 911
      }
912 912

	
913 913
      /// \brief Gives back the arc alteration notifier.
914 914
      ///
915 915
      /// Gives back the arc alteration notifier.
916 916
      ArcNotifier& notifier(Arc) const {
917 917
        return ArcNotifier();
918 918
      }
919 919

	
920 920
      template <typename _Digraph>
921 921
      struct Constraints {
922 922
        void constraints() {
923 923
          checkConcept<Base, _Digraph>();
924 924
          typename _Digraph::NodeNotifier& nn
925 925
            = digraph.notifier(typename _Digraph::Node());
926 926

	
927 927
          typename _Digraph::ArcNotifier& en
928 928
            = digraph.notifier(typename _Digraph::Arc());
929 929

	
930 930
          ignore_unused_variable_warning(nn);
931 931
          ignore_unused_variable_warning(en);
932 932
        }
933 933

	
934 934
        const _Digraph& digraph;
935 935

	
936 936
      };
937 937

	
938 938
    };
939 939

	
940 940
    /// \brief An empty alteration notifier undirected graph class.
941 941
    ///
942 942
    /// This class provides beside the core graph features alteration
943 943
    /// notifier interface for the graph structure.  This implements
944 944
    /// an observer-notifier pattern for each graph item. More
945 945
    /// obsevers can be registered into the notifier and whenever an
946 946
    /// alteration occured in the graph all the observers will
947 947
    /// notified about it.
948 948
    template <typename _Base = BaseGraphComponent>
949 949
    class AlterableGraphComponent : public AlterableDigraphComponent<_Base> {
950 950
    public:
951 951

	
952 952
      typedef _Base Base;
953 953
      typedef typename Base::Edge Edge;
954 954

	
955 955

	
956 956
      /// The arc observer registry.
957 957
      typedef AlterationNotifier<AlterableGraphComponent, Edge>
958 958
      EdgeNotifier;
959 959

	
960 960
      /// \brief Gives back the arc alteration notifier.
961 961
      ///
962 962
      /// Gives back the arc alteration notifier.
963 963
      EdgeNotifier& notifier(Edge) const {
964 964
        return EdgeNotifier();
965 965
      }
966 966

	
967 967
      template <typename _Graph>
968 968
      struct Constraints {
969 969
        void constraints() {
970 970
          checkConcept<AlterableGraphComponent<Base>, _Graph>();
971 971
          typename _Graph::EdgeNotifier& uen
972 972
            = graph.notifier(typename _Graph::Edge());
973 973
          ignore_unused_variable_warning(uen);
974 974
        }
975 975

	
976 976
        const _Graph& graph;
977 977

	
978 978
      };
979 979

	
980 980
    };
981 981

	
982 982
    /// \brief Class describing the concept of graph maps
983 983
    ///
984 984
    /// This class describes the common interface of the graph maps
985 985
    /// (NodeMap, ArcMap), that is maps that can be used to
986 986
    /// associate data to graph descriptors (nodes or arcs).
987 987
    template <typename _Graph, typename _Item, typename _Value>
988 988
    class GraphMap : public ReadWriteMap<_Item, _Value> {
989 989
    public:
990 990

	
991 991
      typedef ReadWriteMap<_Item, _Value> Parent;
992 992

	
993 993
      /// The graph type of the map.
994 994
      typedef _Graph Graph;
995 995
      /// The key type of the map.
996 996
      typedef _Item Key;
997 997
      /// The value type of the map.
998 998
      typedef _Value Value;
999 999

	
1000 1000
      /// \brief Construct a new map.
1001 1001
      ///
1002 1002
      /// Construct a new map for the graph.
1003 1003
      explicit GraphMap(const Graph&) {}
1004 1004
      /// \brief Construct a new map with default value.
1005 1005
      ///
1006 1006
      /// Construct a new map for the graph and initalise the values.
1007 1007
      GraphMap(const Graph&, const Value&) {}
1008 1008

	
1009 1009
    private:
1010 1010
      /// \brief Copy constructor.
1011 1011
      ///
1012 1012
      /// Copy Constructor.
1013 1013
      GraphMap(const GraphMap&) : Parent() {}
1014 1014

	
1015 1015
      /// \brief Assign operator.
1016 1016
      ///
1017 1017
      /// Assign operator. It does not mofify the underlying graph,
1018 1018
      /// it just iterates on the current item set and set the  map
1019 1019
      /// with the value returned by the assigned map.
1020 1020
      template <typename CMap>
1021 1021
      GraphMap& operator=(const CMap&) {
1022 1022
        checkConcept<ReadMap<Key, Value>, CMap>();
1023 1023
        return *this;
1024 1024
      }
1025 1025

	
1026 1026
    public:
1027 1027
      template<typename _Map>
1028 1028
      struct Constraints {
1029 1029
        void constraints() {
1030 1030
          checkConcept<ReadWriteMap<Key, Value>, _Map >();
1031 1031
          // Construction with a graph parameter
1032 1032
          _Map a(g);
1033 1033
          // Constructor with a graph and a default value parameter
1034 1034
          _Map a2(g,t);
1035 1035
          // Copy constructor.
1036 1036
          // _Map b(c);
1037 1037

	
1038 1038
          // ReadMap<Key, Value> cmap;
1039 1039
          // b = cmap;
1040 1040

	
1041 1041
          ignore_unused_variable_warning(a);
1042 1042
          ignore_unused_variable_warning(a2);
1043 1043
          // ignore_unused_variable_warning(b);
1044 1044
        }
1045 1045

	
1046 1046
        const _Map &c;
1047 1047
        const Graph &g;
1048 1048
        const typename GraphMap::Value &t;
1049 1049
      };
1050 1050

	
1051 1051
    };
1052 1052

	
1053 1053
    /// \brief An empty mappable digraph class.
1054 1054
    ///
1055 1055
    /// This class provides beside the core digraph features
1056 1056
    /// map interface for the digraph structure.
1057 1057
    /// This concept is part of the Digraph concept.
1058 1058
    template <typename _Base = BaseDigraphComponent>
1059 1059
    class MappableDigraphComponent : public _Base  {
1060 1060
    public:
1061 1061

	
1062 1062
      typedef _Base Base;
1063 1063
      typedef typename Base::Node Node;
1064 1064
      typedef typename Base::Arc Arc;
1065 1065

	
1066 1066
      typedef MappableDigraphComponent Digraph;
1067 1067

	
1068 1068
      /// \brief ReadWrite map of the nodes.
1069 1069
      ///
1070 1070
      /// ReadWrite map of the nodes.
1071 1071
      ///
1072 1072
      template <typename _Value>
1073 1073
      class NodeMap : public GraphMap<Digraph, Node, _Value> {
1074 1074
      public:
1075 1075
        typedef GraphMap<MappableDigraphComponent, Node, _Value> Parent;
1076 1076

	
1077 1077
        /// \brief Construct a new map.
1078 1078
        ///
1079 1079
        /// Construct a new map for the digraph.
1080 1080
        explicit NodeMap(const MappableDigraphComponent& digraph)
1081 1081
          : Parent(digraph) {}
1082 1082

	
1083 1083
        /// \brief Construct a new map with default value.
1084 1084
        ///
1085 1085
        /// Construct a new map for the digraph and initalise the values.
1086 1086
        NodeMap(const MappableDigraphComponent& digraph, const _Value& value)
1087 1087
          : Parent(digraph, value) {}
1088 1088

	
1089 1089
      private:
1090 1090
        /// \brief Copy constructor.
1091 1091
        ///
1092 1092
        /// Copy Constructor.
1093 1093
        NodeMap(const NodeMap& nm) : Parent(nm) {}
1094 1094

	
1095 1095
        /// \brief Assign operator.
1096 1096
        ///
1097 1097
        /// Assign operator.
1098 1098
        template <typename CMap>
1099 1099
        NodeMap& operator=(const CMap&) {
1100 1100
          checkConcept<ReadMap<Node, _Value>, CMap>();
1101 1101
          return *this;
1102 1102
        }
1103 1103

	
1104 1104
      };
1105 1105

	
1106 1106
      /// \brief ReadWrite map of the arcs.
1107 1107
      ///
1108 1108
      /// ReadWrite map of the arcs.
1109 1109
      ///
1110 1110
      template <typename _Value>
1111 1111
      class ArcMap : public GraphMap<Digraph, Arc, _Value> {
1112 1112
      public:
1113 1113
        typedef GraphMap<MappableDigraphComponent, Arc, _Value> Parent;
1114 1114

	
1115 1115
        /// \brief Construct a new map.
1116 1116
        ///
1117 1117
        /// Construct a new map for the digraph.
1118 1118
        explicit ArcMap(const MappableDigraphComponent& digraph)
1119 1119
          : Parent(digraph) {}
1120 1120

	
1121 1121
        /// \brief Construct a new map with default value.
1122 1122
        ///
1123 1123
        /// Construct a new map for the digraph and initalise the values.
1124 1124
        ArcMap(const MappableDigraphComponent& digraph, const _Value& value)
1125 1125
          : Parent(digraph, value) {}
1126 1126

	
1127 1127
      private:
1128 1128
        /// \brief Copy constructor.
1129 1129
        ///
1130 1130
        /// Copy Constructor.
1131 1131
        ArcMap(const ArcMap& nm) : Parent(nm) {}
1132 1132

	
1133 1133
        /// \brief Assign operator.
1134 1134
        ///
1135 1135
        /// Assign operator.
1136 1136
        template <typename CMap>
1137 1137
        ArcMap& operator=(const CMap&) {
1138 1138
          checkConcept<ReadMap<Arc, _Value>, CMap>();
1139 1139
          return *this;
1140 1140
        }
1141 1141

	
1142 1142
      };
1143 1143

	
1144 1144

	
1145 1145
      template <typename _Digraph>
1146 1146
      struct Constraints {
1147 1147

	
1148 1148
        struct Dummy {
1149 1149
          int value;
1150 1150
          Dummy() : value(0) {}
1151 1151
          Dummy(int _v) : value(_v) {}
1152 1152
        };
1153 1153

	
1154 1154
        void constraints() {
1155 1155
          checkConcept<Base, _Digraph>();
1156 1156
          { // int map test
1157 1157
            typedef typename _Digraph::template NodeMap<int> IntNodeMap;
1158 1158
            checkConcept<GraphMap<_Digraph, typename _Digraph::Node, int>,
1159 1159
              IntNodeMap >();
1160 1160
          } { // bool map test
1161 1161
            typedef typename _Digraph::template NodeMap<bool> BoolNodeMap;
1162 1162
            checkConcept<GraphMap<_Digraph, typename _Digraph::Node, bool>,
1163 1163
              BoolNodeMap >();
1164 1164
          } { // Dummy map test
1165 1165
            typedef typename _Digraph::template NodeMap<Dummy> DummyNodeMap;
1166 1166
            checkConcept<GraphMap<_Digraph, typename _Digraph::Node, Dummy>,
1167 1167
              DummyNodeMap >();
1168 1168
          }
1169 1169

	
1170 1170
          { // int map test
1171 1171
            typedef typename _Digraph::template ArcMap<int> IntArcMap;
1172 1172
            checkConcept<GraphMap<_Digraph, typename _Digraph::Arc, int>,
1173 1173
              IntArcMap >();
1174 1174
          } { // bool map test
1175 1175
            typedef typename _Digraph::template ArcMap<bool> BoolArcMap;
1176 1176
            checkConcept<GraphMap<_Digraph, typename _Digraph::Arc, bool>,
1177 1177
              BoolArcMap >();
1178 1178
          } { // Dummy map test
1179 1179
            typedef typename _Digraph::template ArcMap<Dummy> DummyArcMap;
1180 1180
            checkConcept<GraphMap<_Digraph, typename _Digraph::Arc, Dummy>,
1181 1181
              DummyArcMap >();
1182 1182
          }
1183 1183
        }
1184 1184

	
1185 1185
        _Digraph& digraph;
1186 1186
      };
1187 1187
    };
1188 1188

	
1189 1189
    /// \brief An empty mappable base bipartite graph class.
1190 1190
    ///
1191 1191
    /// This class provides beside the core graph features
1192 1192
    /// map interface for the graph structure.
1193 1193
    /// This concept is part of the Graph concept.
1194 1194
    template <typename _Base = BaseGraphComponent>
1195 1195
    class MappableGraphComponent : public MappableDigraphComponent<_Base>  {
1196 1196
    public:
1197 1197

	
1198 1198
      typedef _Base Base;
1199 1199
      typedef typename Base::Edge Edge;
1200 1200

	
1201 1201
      typedef MappableGraphComponent Graph;
1202 1202

	
1203 1203
      /// \brief ReadWrite map of the edges.
1204 1204
      ///
1205 1205
      /// ReadWrite map of the edges.
1206 1206
      ///
1207 1207
      template <typename _Value>
1208 1208
      class EdgeMap : public GraphMap<Graph, Edge, _Value> {
1209 1209
      public:
1210 1210
        typedef GraphMap<MappableGraphComponent, Edge, _Value> Parent;
1211 1211

	
1212 1212
        /// \brief Construct a new map.
1213 1213
        ///
1214 1214
        /// Construct a new map for the graph.
1215 1215
        explicit EdgeMap(const MappableGraphComponent& graph)
1216 1216
          : Parent(graph) {}
1217 1217

	
1218 1218
        /// \brief Construct a new map with default value.
1219 1219
        ///
1220 1220
        /// Construct a new map for the graph and initalise the values.
1221 1221
        EdgeMap(const MappableGraphComponent& graph, const _Value& value)
1222 1222
          : Parent(graph, value) {}
1223 1223

	
1224 1224
      private:
1225 1225
        /// \brief Copy constructor.
1226 1226
        ///
1227 1227
        /// Copy Constructor.
1228 1228
        EdgeMap(const EdgeMap& nm) : Parent(nm) {}
1229 1229

	
1230 1230
        /// \brief Assign operator.
1231 1231
        ///
1232 1232
        /// Assign operator.
1233 1233
        template <typename CMap>
1234 1234
        EdgeMap& operator=(const CMap&) {
1235 1235
          checkConcept<ReadMap<Edge, _Value>, CMap>();
1236 1236
          return *this;
1237 1237
        }
1238 1238

	
1239 1239
      };
1240 1240

	
1241 1241

	
1242 1242
      template <typename _Graph>
1243 1243
      struct Constraints {
1244 1244

	
1245 1245
        struct Dummy {
1246 1246
          int value;
1247 1247
          Dummy() : value(0) {}
1248 1248
          Dummy(int _v) : value(_v) {}
1249 1249
        };
1250 1250

	
1251 1251
        void constraints() {
1252 1252
          checkConcept<MappableGraphComponent<Base>, _Graph>();
1253 1253

	
1254 1254
          { // int map test
1255 1255
            typedef typename _Graph::template EdgeMap<int> IntEdgeMap;
1256 1256
            checkConcept<GraphMap<_Graph, typename _Graph::Edge, int>,
1257 1257
              IntEdgeMap >();
1258 1258
          } { // bool map test
1259 1259
            typedef typename _Graph::template EdgeMap<bool> BoolEdgeMap;
1260 1260
            checkConcept<GraphMap<_Graph, typename _Graph::Edge, bool>,
1261 1261
              BoolEdgeMap >();
1262 1262
          } { // Dummy map test
1263 1263
            typedef typename _Graph::template EdgeMap<Dummy> DummyEdgeMap;
1264 1264
            checkConcept<GraphMap<_Graph, typename _Graph::Edge, Dummy>,
1265 1265
              DummyEdgeMap >();
1266 1266
          }
1267 1267
        }
1268 1268

	
1269 1269
        _Graph& graph;
1270 1270
      };
1271 1271
    };
1272 1272

	
1273 1273
    /// \brief An empty extendable digraph class.
1274 1274
    ///
1275 1275
    /// This class provides beside the core digraph features digraph
1276 1276
    /// extendable interface for the digraph structure.  The main
1277 1277
    /// difference between the base and this interface is that the
1278 1278
    /// digraph alterations should handled already on this level.
1279 1279
    template <typename _Base = BaseDigraphComponent>
1280 1280
    class ExtendableDigraphComponent : public _Base {
1281 1281
    public:
1282 1282
      typedef _Base Base;
1283 1283

	
1284 1284
      typedef typename _Base::Node Node;
1285 1285
      typedef typename _Base::Arc Arc;
1286 1286

	
1287 1287
      /// \brief Adds a new node to the digraph.
1288 1288
      ///
1289 1289
      /// Adds a new node to the digraph.
1290 1290
      ///
1291 1291
      Node addNode() {
1292 1292
        return INVALID;
1293 1293
      }
1294 1294

	
1295 1295
      /// \brief Adds a new arc connects the given two nodes.
1296 1296
      ///
1297 1297
      /// Adds a new arc connects the the given two nodes.
1298 1298
      Arc addArc(const Node&, const Node&) {
1299 1299
        return INVALID;
1300 1300
      }
1301 1301

	
1302 1302
      template <typename _Digraph>
1303 1303
      struct Constraints {
1304 1304
        void constraints() {
1305 1305
          checkConcept<Base, _Digraph>();
1306 1306
          typename _Digraph::Node node_a, node_b;
1307 1307
          node_a = digraph.addNode();
1308 1308
          node_b = digraph.addNode();
1309 1309
          typename _Digraph::Arc arc;
1310 1310
          arc = digraph.addArc(node_a, node_b);
1311 1311
        }
1312 1312

	
1313 1313
        _Digraph& digraph;
1314 1314
      };
1315 1315
    };
1316 1316

	
1317 1317
    /// \brief An empty extendable base undirected graph class.
1318 1318
    ///
1319 1319
    /// This class provides beside the core undirected graph features
1320 1320
    /// core undircted graph extend interface for the graph structure.
1321 1321
    /// The main difference between the base and this interface is
1322 1322
    /// that the graph alterations should handled already on this
1323 1323
    /// level.
1324 1324
    template <typename _Base = BaseGraphComponent>
1325 1325
    class ExtendableGraphComponent : public _Base {
1326 1326
    public:
1327 1327

	
1328 1328
      typedef _Base Base;
1329 1329
      typedef typename _Base::Node Node;
1330 1330
      typedef typename _Base::Edge Edge;
1331 1331

	
1332 1332
      /// \brief Adds a new node to the graph.
1333 1333
      ///
1334 1334
      /// Adds a new node to the graph.
1335 1335
      ///
1336 1336
      Node addNode() {
1337 1337
        return INVALID;
1338 1338
      }
1339 1339

	
1340 1340
      /// \brief Adds a new arc connects the given two nodes.
1341 1341
      ///
1342 1342
      /// Adds a new arc connects the the given two nodes.
1343 1343
      Edge addArc(const Node&, const Node&) {
1344 1344
        return INVALID;
1345 1345
      }
1346 1346

	
1347 1347
      template <typename _Graph>
1348 1348
      struct Constraints {
1349 1349
        void constraints() {
1350 1350
          checkConcept<Base, _Graph>();
1351 1351
          typename _Graph::Node node_a, node_b;
1352 1352
          node_a = graph.addNode();
1353 1353
          node_b = graph.addNode();
1354 1354
          typename _Graph::Edge edge;
1355 1355
          edge = graph.addEdge(node_a, node_b);
1356 1356
        }
1357 1357

	
1358 1358
        _Graph& graph;
1359 1359
      };
1360 1360
    };
1361 1361

	
1362 1362
    /// \brief An empty erasable digraph class.
1363 1363
    ///
1364 1364
    /// This class provides beside the core digraph features core erase
1365 1365
    /// functions for the digraph structure. The main difference between
1366 1366
    /// the base and this interface is that the digraph alterations
1367 1367
    /// should handled already on this level.
1368 1368
    template <typename _Base = BaseDigraphComponent>
1369 1369
    class ErasableDigraphComponent : public _Base {
1370 1370
    public:
1371 1371

	
1372 1372
      typedef _Base Base;
1373 1373
      typedef typename Base::Node Node;
1374 1374
      typedef typename Base::Arc Arc;
1375 1375

	
1376 1376
      /// \brief Erase a node from the digraph.
1377 1377
      ///
1378 1378
      /// Erase a node from the digraph. This function should
1379 1379
      /// erase all arcs connecting to the node.
1380 1380
      void erase(const Node&) {}
1381 1381

	
1382 1382
      /// \brief Erase an arc from the digraph.
1383 1383
      ///
1384 1384
      /// Erase an arc from the digraph.
1385 1385
      ///
1386 1386
      void erase(const Arc&) {}
1387 1387

	
1388 1388
      template <typename _Digraph>
1389 1389
      struct Constraints {
1390 1390
        void constraints() {
1391 1391
          checkConcept<Base, _Digraph>();
1392 1392
          typename _Digraph::Node node;
1393 1393
          digraph.erase(node);
1394 1394
          typename _Digraph::Arc arc;
1395 1395
          digraph.erase(arc);
1396 1396
        }
1397 1397

	
1398 1398
        _Digraph& digraph;
1399 1399
      };
1400 1400
    };
1401 1401

	
1402 1402
    /// \brief An empty erasable base undirected graph class.
1403 1403
    ///
1404 1404
    /// This class provides beside the core undirected graph features
1405 1405
    /// core erase functions for the undirceted graph structure. The
1406 1406
    /// main difference between the base and this interface is that
1407 1407
    /// the graph alterations should handled already on this level.
1408 1408
    template <typename _Base = BaseGraphComponent>
1409 1409
    class ErasableGraphComponent : public _Base {
1410 1410
    public:
1411 1411

	
1412 1412
      typedef _Base Base;
1413 1413
      typedef typename Base::Node Node;
1414 1414
      typedef typename Base::Edge Edge;
1415 1415

	
1416 1416
      /// \brief Erase a node from the graph.
1417 1417
      ///
1418 1418
      /// Erase a node from the graph. This function should erase
1419 1419
      /// arcs connecting to the node.
1420 1420
      void erase(const Node&) {}
1421 1421

	
1422 1422
      /// \brief Erase an arc from the graph.
1423 1423
      ///
1424 1424
      /// Erase an arc from the graph.
1425 1425
      ///
1426 1426
      void erase(const Edge&) {}
1427 1427

	
1428 1428
      template <typename _Graph>
1429 1429
      struct Constraints {
1430 1430
        void constraints() {
1431 1431
          checkConcept<Base, _Graph>();
1432 1432
          typename _Graph::Node node;
1433 1433
          graph.erase(node);
1434 1434
          typename _Graph::Edge edge;
1435 1435
          graph.erase(edge);
1436 1436
        }
1437 1437

	
1438 1438
        _Graph& graph;
1439 1439
      };
1440 1440
    };
1441 1441

	
1442 1442
    /// \brief An empty clearable base digraph class.
1443 1443
    ///
1444 1444
    /// This class provides beside the core digraph features core clear
1445 1445
    /// functions for the digraph structure. The main difference between
1446 1446
    /// the base and this interface is that the digraph alterations
1447 1447
    /// should handled already on this level.
1448 1448
    template <typename _Base = BaseDigraphComponent>
1449 1449
    class ClearableDigraphComponent : public _Base {
1450 1450
    public:
1451 1451

	
1452 1452
      typedef _Base Base;
1453 1453

	
1454 1454
      /// \brief Erase all nodes and arcs from the digraph.
1455 1455
      ///
1456 1456
      /// Erase all nodes and arcs from the digraph.
1457 1457
      ///
1458 1458
      void clear() {}
1459 1459

	
1460 1460
      template <typename _Digraph>
1461 1461
      struct Constraints {
1462 1462
        void constraints() {
1463 1463
          checkConcept<Base, _Digraph>();
1464 1464
          digraph.clear();
1465 1465
        }
1466 1466

	
1467 1467
        _Digraph digraph;
1468 1468
      };
1469 1469
    };
1470 1470

	
1471 1471
    /// \brief An empty clearable base undirected graph class.
1472 1472
    ///
1473 1473
    /// This class provides beside the core undirected graph features
1474 1474
    /// core clear functions for the undirected graph structure. The
1475 1475
    /// main difference between the base and this interface is that
1476 1476
    /// the graph alterations should handled already on this level.
1477 1477
    template <typename _Base = BaseGraphComponent>
1478 1478
    class ClearableGraphComponent : public ClearableDigraphComponent<_Base> {
1479 1479
    public:
1480 1480

	
1481 1481
      typedef _Base Base;
1482 1482

	
1483 1483
      template <typename _Graph>
1484 1484
      struct Constraints {
1485 1485
        void constraints() {
1486 1486
          checkConcept<ClearableGraphComponent<Base>, _Graph>();
1487 1487
        }
1488 1488

	
1489 1489
        _Graph graph;
1490 1490
      };
1491 1491
    };
1492 1492

	
1493 1493
  }
1494 1494

	
1495 1495
}
1496 1496

	
1497 1497
#endif
Ignore white space 6 line context
1 1
/* -*- mode: C++; indent-tabs-mode: nil; -*-
2 2
 *
3 3
 * This file is a part of LEMON, a generic C++ optimization library.
4 4
 *
5 5
 * Copyright (C) 2003-2009
6 6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8 8
 *
9 9
 * Permission to use, modify and distribute this software is granted
10 10
 * provided that this copyright notice appears in all copies. For
11 11
 * precise terms see the accompanying LICENSE file.
12 12
 *
13 13
 * This software is provided "AS IS" with no warranty of any kind,
14 14
 * express or implied, and with no claim as to its suitability for any
15 15
 * purpose.
16 16
 *
17 17
 */
18 18

	
19 19
///\ingroup concept
20 20
///\file
21 21
///\brief The concept of heaps.
22 22

	
23
#ifndef LEMON_CONCEPT_HEAP_H
24
#define LEMON_CONCEPT_HEAP_H
23
#ifndef LEMON_CONCEPTS_HEAP_H
24
#define LEMON_CONCEPTS_HEAP_H
25 25

	
26 26
#include <lemon/core.h>
27 27
#include <lemon/concept_check.h>
28 28

	
29 29
namespace lemon {
30 30

	
31 31
  namespace concepts {
32 32

	
33 33
    /// \addtogroup concept
34 34
    /// @{
35 35

	
36 36
    /// \brief The heap concept.
37 37
    ///
38 38
    /// Concept class describing the main interface of heaps.
39 39
    template <typename Priority, typename ItemIntMap>
40 40
    class Heap {
41 41
    public:
42 42

	
43 43
      /// Type of the items stored in the heap.
44 44
      typedef typename ItemIntMap::Key Item;
45 45

	
46 46
      /// Type of the priorities.
47 47
      typedef Priority Prio;
48 48

	
49 49
      /// \brief Type to represent the states of the items.
50 50
      ///
51 51
      /// Each item has a state associated to it. It can be "in heap",
52 52
      /// "pre heap" or "post heap". The later two are indifferent
53 53
      /// from the point of view of the heap, but may be useful for
54 54
      /// the user.
55 55
      ///
56 56
      /// The \c ItemIntMap must be initialized in such a way, that it
57 57
      /// assigns \c PRE_HEAP (<tt>-1</tt>) to every item.
58 58
      enum State {
59 59
        IN_HEAP = 0,
60 60
        PRE_HEAP = -1,
61 61
        POST_HEAP = -2
62 62
      };
63 63

	
64 64
      /// \brief The constructor.
65 65
      ///
66 66
      /// The constructor.
67 67
      /// \param map A map that assigns \c int values to keys of type
68 68
      /// \c Item. It is used internally by the heap implementations to
69 69
      /// handle the cross references. The assigned value must be
70 70
      /// \c PRE_HEAP (<tt>-1</tt>) for every item.
71 71
      explicit Heap(ItemIntMap &map) {}
72 72

	
73 73
      /// \brief The number of items stored in the heap.
74 74
      ///
75 75
      /// Returns the number of items stored in the heap.
76 76
      int size() const { return 0; }
77 77

	
78 78
      /// \brief Checks if the heap is empty.
79 79
      ///
80 80
      /// Returns \c true if the heap is empty.
81 81
      bool empty() const { return false; }
82 82

	
83 83
      /// \brief Makes the heap empty.
84 84
      ///
85 85
      /// Makes the heap empty.
86 86
      void clear();
87 87

	
88 88
      /// \brief Inserts an item into the heap with the given priority.
89 89
      ///
90 90
      /// Inserts the given item into the heap with the given priority.
91 91
      /// \param i The item to insert.
92 92
      /// \param p The priority of the item.
93 93
      void push(const Item &i, const Prio &p) {}
94 94

	
95 95
      /// \brief Returns the item having minimum priority.
96 96
      ///
97 97
      /// Returns the item having minimum priority.
98 98
      /// \pre The heap must be non-empty.
99 99
      Item top() const {}
100 100

	
101 101
      /// \brief The minimum priority.
102 102
      ///
103 103
      /// Returns the minimum priority.
104 104
      /// \pre The heap must be non-empty.
105 105
      Prio prio() const {}
106 106

	
107 107
      /// \brief Removes the item having minimum priority.
108 108
      ///
109 109
      /// Removes the item having minimum priority.
110 110
      /// \pre The heap must be non-empty.
111 111
      void pop() {}
112 112

	
113 113
      /// \brief Removes an item from the heap.
114 114
      ///
115 115
      /// Removes the given item from the heap if it is already stored.
116 116
      /// \param i The item to delete.
117 117
      void erase(const Item &i) {}
118 118

	
119 119
      /// \brief The priority of an item.
120 120
      ///
121 121
      /// Returns the priority of the given item.
122 122
      /// \pre \c i must be in the heap.
123 123
      /// \param i The item.
124 124
      Prio operator[](const Item &i) const {}
125 125

	
126 126
      /// \brief Sets the priority of an item or inserts it, if it is
127 127
      /// not stored in the heap.
128 128
      ///
129 129
      /// This method sets the priority of the given item if it is
130 130
      /// already stored in the heap.
131 131
      /// Otherwise it inserts the given item with the given priority.
132 132
      ///
133 133
      /// \param i The item.
134 134
      /// \param p The priority.
135 135
      void set(const Item &i, const Prio &p) {}
136 136

	
137 137
      /// \brief Decreases the priority of an item to the given value.
138 138
      ///
139 139
      /// Decreases the priority of an item to the given value.
140 140
      /// \pre \c i must be stored in the heap with priority at least \c p.
141 141
      /// \param i The item.
142 142
      /// \param p The priority.
143 143
      void decrease(const Item &i, const Prio &p) {}
144 144

	
145 145
      /// \brief Increases the priority of an item to the given value.
146 146
      ///
147 147
      /// Increases the priority of an item to the given value.
148 148
      /// \pre \c i must be stored in the heap with priority at most \c p.
149 149
      /// \param i The item.
150 150
      /// \param p The priority.
151 151
      void increase(const Item &i, const Prio &p) {}
152 152

	
153 153
      /// \brief Returns if an item is in, has already been in, or has
154 154
      /// never been in the heap.
155 155
      ///
156 156
      /// This method returns \c PRE_HEAP if the given item has never
157 157
      /// been in the heap, \c IN_HEAP if it is in the heap at the moment,
158 158
      /// and \c POST_HEAP otherwise.
159 159
      /// In the latter case it is possible that the item will get back
160 160
      /// to the heap again.
161 161
      /// \param i The item.
162 162
      State state(const Item &i) const {}
163 163

	
164 164
      /// \brief Sets the state of an item in the heap.
165 165
      ///
166 166
      /// Sets the state of the given item in the heap. It can be used
167 167
      /// to manually clear the heap when it is important to achive the
168 168
      /// better time complexity.
169 169
      /// \param i The item.
170 170
      /// \param st The state. It should not be \c IN_HEAP.
171 171
      void state(const Item& i, State st) {}
172 172

	
173 173

	
174 174
      template <typename _Heap>
175 175
      struct Constraints {
176 176
      public:
177 177
        void constraints() {
178 178
          typedef typename _Heap::Item OwnItem;
179 179
          typedef typename _Heap::Prio OwnPrio;
180 180
          typedef typename _Heap::State OwnState;
181 181

	
182 182
          Item item;
183 183
          Prio prio;
184 184
          item=Item();
185 185
          prio=Prio();
186 186
          ignore_unused_variable_warning(item);
187 187
          ignore_unused_variable_warning(prio);
188 188

	
189 189
          OwnItem own_item;
190 190
          OwnPrio own_prio;
191 191
          OwnState own_state;
192 192
          own_item=Item();
193 193
          own_prio=Prio();
194 194
          ignore_unused_variable_warning(own_item);
195 195
          ignore_unused_variable_warning(own_prio);
196 196
          ignore_unused_variable_warning(own_state);
197 197

	
198 198
          _Heap heap1(map);
199 199
          _Heap heap2 = heap1;
200 200
          ignore_unused_variable_warning(heap1);
201 201
          ignore_unused_variable_warning(heap2);
202 202

	
203 203
          int s = heap.size();
204 204
          ignore_unused_variable_warning(s);
205 205
          bool e = heap.empty();
206 206
          ignore_unused_variable_warning(e);
207 207

	
208 208
          prio = heap.prio();
209 209
          item = heap.top();
210 210
          prio = heap[item];
211 211
          own_prio = heap.prio();
212 212
          own_item = heap.top();
213 213
          own_prio = heap[own_item];
214 214

	
215 215
          heap.push(item, prio);
216 216
          heap.push(own_item, own_prio);
217 217
          heap.pop();
218 218

	
219 219
          heap.set(item, prio);
220 220
          heap.decrease(item, prio);
221 221
          heap.increase(item, prio);
222 222
          heap.set(own_item, own_prio);
223 223
          heap.decrease(own_item, own_prio);
224 224
          heap.increase(own_item, own_prio);
225 225

	
226 226
          heap.erase(item);
227 227
          heap.erase(own_item);
228 228
          heap.clear();
229 229

	
230 230
          own_state = heap.state(own_item);
231 231
          heap.state(own_item, own_state);
232 232

	
233 233
          own_state = _Heap::PRE_HEAP;
234 234
          own_state = _Heap::IN_HEAP;
235 235
          own_state = _Heap::POST_HEAP;
236 236
        }
237 237

	
238 238
        _Heap& heap;
239 239
        ItemIntMap& map;
240 240
      };
241 241
    };
242 242

	
243 243
    /// @}
244 244
  } // namespace lemon
245 245
}
246
#endif // LEMON_CONCEPT_PATH_H
246
#endif
Ignore white space 6 line context
1 1
/* -*- mode: C++; indent-tabs-mode: nil; -*-
2 2
 *
3 3
 * This file is a part of LEMON, a generic C++ optimization library.
4 4
 *
5 5
 * Copyright (C) 2003-2009
6 6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8 8
 *
9 9
 * Permission to use, modify and distribute this software is granted
10 10
 * provided that this copyright notice appears in all copies. For
11 11
 * precise terms see the accompanying LICENSE file.
12 12
 *
13 13
 * This software is provided "AS IS" with no warranty of any kind,
14 14
 * express or implied, and with no claim as to its suitability for any
15 15
 * purpose.
16 16
 *
17 17
 */
18 18

	
19
#ifndef LEMON_CONCEPT_MAPS_H
20
#define LEMON_CONCEPT_MAPS_H
19
#ifndef LEMON_CONCEPTS_MAPS_H
20
#define LEMON_CONCEPTS_MAPS_H
21 21

	
22 22
#include <lemon/core.h>
23 23
#include <lemon/concept_check.h>
24 24

	
25 25
///\ingroup map_concepts
26 26
///\file
27 27
///\brief The concept of maps.
28 28

	
29 29
namespace lemon {
30 30

	
31 31
  namespace concepts {
32 32

	
33 33
    /// \addtogroup map_concepts
34 34
    /// @{
35 35

	
36 36
    /// Readable map concept
37 37

	
38 38
    /// Readable map concept.
39 39
    ///
40 40
    template<typename K, typename T>
41 41
    class ReadMap
42 42
    {
43 43
    public:
44 44
      /// The key type of the map.
45 45
      typedef K Key;
46 46
      /// \brief The value type of the map.
47 47
      /// (The type of objects associated with the keys).
48 48
      typedef T Value;
49 49

	
50 50
      /// Returns the value associated with the given key.
51 51
      Value operator[](const Key &) const {
52 52
        return *static_cast<Value *>(0);
53 53
      }
54 54

	
55 55
      template<typename _ReadMap>
56 56
      struct Constraints {
57 57
        void constraints() {
58 58
          Value val = m[key];
59 59
          val = m[key];
60 60
          typename _ReadMap::Value own_val = m[own_key];
61 61
          own_val = m[own_key];
62 62

	
63 63
          ignore_unused_variable_warning(key);
64 64
          ignore_unused_variable_warning(val);
65 65
          ignore_unused_variable_warning(own_key);
66 66
          ignore_unused_variable_warning(own_val);
67 67
        }
68 68
        const Key& key;
69 69
        const typename _ReadMap::Key& own_key;
70 70
        const _ReadMap& m;
71 71
      };
72 72

	
73 73
    };
74 74

	
75 75

	
76 76
    /// Writable map concept
77 77

	
78 78
    /// Writable map concept.
79 79
    ///
80 80
    template<typename K, typename T>
81 81
    class WriteMap
82 82
    {
83 83
    public:
84 84
      /// The key type of the map.
85 85
      typedef K Key;
86 86
      /// \brief The value type of the map.
87 87
      /// (The type of objects associated with the keys).
88 88
      typedef T Value;
89 89

	
90 90
      /// Sets the value associated with the given key.
91 91
      void set(const Key &, const Value &) {}
92 92

	
93 93
      /// Default constructor.
94 94
      WriteMap() {}
95 95

	
96 96
      template <typename _WriteMap>
97 97
      struct Constraints {
98 98
        void constraints() {
99 99
          m.set(key, val);
100 100
          m.set(own_key, own_val);
101 101

	
102 102
          ignore_unused_variable_warning(key);
103 103
          ignore_unused_variable_warning(val);
104 104
          ignore_unused_variable_warning(own_key);
105 105
          ignore_unused_variable_warning(own_val);
106 106
        }
107 107
        const Key& key;
108 108
        const Value& val;
109 109
        const typename _WriteMap::Key& own_key;
110 110
        const typename _WriteMap::Value& own_val;
111 111
        _WriteMap& m;
112 112
      };
113 113
    };
114 114

	
115 115
    /// Read/writable map concept
116 116

	
117 117
    /// Read/writable map concept.
118 118
    ///
119 119
    template<typename K, typename T>
120 120
    class ReadWriteMap : public ReadMap<K,T>,
121 121
                         public WriteMap<K,T>
122 122
    {
123 123
    public:
124 124
      /// The key type of the map.
125 125
      typedef K Key;
126 126
      /// \brief The value type of the map.
127 127
      /// (The type of objects associated with the keys).
128 128
      typedef T Value;
129 129

	
130 130
      /// Returns the value associated with the given key.
131 131
      Value operator[](const Key &) const {
132 132
        return *static_cast<Value *>(0);
133 133
      }
134 134

	
135 135
      /// Sets the value associated with the given key.
136 136
      void set(const Key &, const Value &) {}
137 137

	
138 138
      template<typename _ReadWriteMap>
139 139
      struct Constraints {
140 140
        void constraints() {
141 141
          checkConcept<ReadMap<K, T>, _ReadWriteMap >();
142 142
          checkConcept<WriteMap<K, T>, _ReadWriteMap >();
143 143
        }
144 144
      };
145 145
    };
146 146

	
147 147

	
148 148
    /// Dereferable map concept
149 149

	
150 150
    /// Dereferable map concept.
151 151
    ///
152 152
    template<typename K, typename T, typename R, typename CR>
153 153
    class ReferenceMap : public ReadWriteMap<K,T>
154 154
    {
155 155
    public:
156 156
      /// Tag for reference maps.
157 157
      typedef True ReferenceMapTag;
158 158
      /// The key type of the map.
159 159
      typedef K Key;
160 160
      /// \brief The value type of the map.
161 161
      /// (The type of objects associated with the keys).
162 162
      typedef T Value;
163 163
      /// The reference type of the map.
164 164
      typedef R Reference;
165 165
      /// The const reference type of the map.
166 166
      typedef CR ConstReference;
167 167

	
168 168
    public:
169 169

	
170 170
      /// Returns a reference to the value associated with the given key.
171 171
      Reference operator[](const Key &) {
172 172
        return *static_cast<Value *>(0);
173 173
      }
174 174

	
175 175
      /// Returns a const reference to the value associated with the given key.
176 176
      ConstReference operator[](const Key &) const {
177 177
        return *static_cast<Value *>(0);
178 178
      }
179 179

	
180 180
      /// Sets the value associated with the given key.
181 181
      void set(const Key &k,const Value &t) { operator[](k)=t; }
182 182

	
183 183
      template<typename _ReferenceMap>
184 184
      struct Constraints {
185 185
        void constraints() {
186 186
          checkConcept<ReadWriteMap<K, T>, _ReferenceMap >();
187 187
          ref = m[key];
188 188
          m[key] = val;
189 189
          m[key] = ref;
190 190
          m[key] = cref;
191 191
          own_ref = m[own_key];
192 192
          m[own_key] = own_val;
193 193
          m[own_key] = own_ref;
194 194
          m[own_key] = own_cref;
195 195
          m[key] = m[own_key];
196 196
          m[own_key] = m[key];
197 197
        }
198 198
        const Key& key;
199 199
        Value& val;
200 200
        Reference ref;
201 201
        ConstReference cref;
202 202
        const typename _ReferenceMap::Key& own_key;
203 203
        typename _ReferenceMap::Value& own_val;
204 204
        typename _ReferenceMap::Reference own_ref;
205 205
        typename _ReferenceMap::ConstReference own_cref;
206 206
        _ReferenceMap& m;
207 207
      };
208 208
    };
209 209

	
210 210
    // @}
211 211

	
212 212
  } //namespace concepts
213 213

	
214 214
} //namespace lemon
215 215

	
216
#endif // LEMON_CONCEPT_MAPS_H
216
#endif
Ignore white space 6 line context
1 1
/* -*- mode: C++; indent-tabs-mode: nil; -*-
2 2
 *
3 3
 * This file is a part of LEMON, a generic C++ optimization library.
4 4
 *
5 5
 * Copyright (C) 2003-2009
6 6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8 8
 *
9 9
 * Permission to use, modify and distribute this software is granted
10 10
 * provided that this copyright notice appears in all copies. For
11 11
 * precise terms see the accompanying LICENSE file.
12 12
 *
13 13
 * This software is provided "AS IS" with no warranty of any kind,
14 14
 * express or implied, and with no claim as to its suitability for any
15 15
 * purpose.
16 16
 *
17 17
 */
18 18

	
19 19
///\ingroup concept
20 20
///\file
21 21
///\brief Classes for representing paths in digraphs.
22 22
///
23 23

	
24
#ifndef LEMON_CONCEPT_PATH_H
25
#define LEMON_CONCEPT_PATH_H
24
#ifndef LEMON_CONCEPTS_PATH_H
25
#define LEMON_CONCEPTS_PATH_H
26 26

	
27 27
#include <lemon/core.h>
28 28
#include <lemon/concept_check.h>
29 29

	
30 30
namespace lemon {
31 31
  namespace concepts {
32 32

	
33 33
    /// \addtogroup concept
34 34
    /// @{
35 35

	
36 36
    /// \brief A skeleton structure for representing directed paths in
37 37
    /// a digraph.
38 38
    ///
39 39
    /// A skeleton structure for representing directed paths in a
40 40
    /// digraph.
41 41
    /// \tparam _Digraph The digraph type in which the path is.
42 42
    ///
43 43
    /// In a sense, the path can be treated as a list of arcs. The
44 44
    /// lemon path type stores just this list. As a consequence it
45 45
    /// cannot enumerate the nodes in the path and the zero length
46 46
    /// paths cannot store the source.
47 47
    ///
48 48
    template <typename _Digraph>
49 49
    class Path {
50 50
    public:
51 51

	
52 52
      /// Type of the underlying digraph.
53 53
      typedef _Digraph Digraph;
54 54
      /// Arc type of the underlying digraph.
55 55
      typedef typename Digraph::Arc Arc;
56 56

	
57 57
      class ArcIt;
58 58

	
59 59
      /// \brief Default constructor
60 60
      Path() {}
61 61

	
62 62
      /// \brief Template constructor
63 63
      template <typename CPath>
64 64
      Path(const CPath& cpath) {}
65 65

	
66 66
      /// \brief Template assigment
67 67
      template <typename CPath>
68 68
      Path& operator=(const CPath& cpath) {
69 69
        ignore_unused_variable_warning(cpath);
70 70
        return *this;
71 71
      }
72 72

	
73 73
      /// Length of the path ie. the number of arcs in the path.
74 74
      int length() const { return 0;}
75 75

	
76 76
      /// Returns whether the path is empty.
77 77
      bool empty() const { return true;}
78 78

	
79 79
      /// Resets the path to an empty path.
80 80
      void clear() {}
81 81

	
82 82
      /// \brief LEMON style iterator for path arcs
83 83
      ///
84 84
      /// This class is used to iterate on the arcs of the paths.
85 85
      class ArcIt {
86 86
      public:
87 87
        /// Default constructor
88 88
        ArcIt() {}
89 89
        /// Invalid constructor
90 90
        ArcIt(Invalid) {}
91 91
        /// Constructor for first arc
92 92
        ArcIt(const Path &) {}
93 93

	
94 94
        /// Conversion to Arc
95 95
        operator Arc() const { return INVALID; }
96 96

	
97 97
        /// Next arc
98 98
        ArcIt& operator++() {return *this;}
99 99

	
100 100
        /// Comparison operator
101 101
        bool operator==(const ArcIt&) const {return true;}
102 102
        /// Comparison operator
103 103
        bool operator!=(const ArcIt&) const {return true;}
104 104
        /// Comparison operator
105 105
        bool operator<(const ArcIt&) const {return false;}
106 106

	
107 107
      };
108 108

	
109 109
      template <typename _Path>
110 110
      struct Constraints {
111 111
        void constraints() {
112 112
          Path<Digraph> pc;
113 113
          _Path p, pp(pc);
114 114
          int l = p.length();
115 115
          int e = p.empty();
116 116
          p.clear();
117 117

	
118 118
          p = pc;
119 119

	
120 120
          typename _Path::ArcIt id, ii(INVALID), i(p);
121 121

	
122 122
          ++i;
123 123
          typename Digraph::Arc ed = i;
124 124

	
125 125
          e = (i == ii);
126 126
          e = (i != ii);
127 127
          e = (i < ii);
128 128

	
129 129
          ignore_unused_variable_warning(l);
130 130
          ignore_unused_variable_warning(pp);
131 131
          ignore_unused_variable_warning(e);
132 132
          ignore_unused_variable_warning(id);
133 133
          ignore_unused_variable_warning(ii);
134 134
          ignore_unused_variable_warning(ed);
135 135
        }
136 136
      };
137 137

	
138 138
    };
139 139

	
140 140
    namespace _path_bits {
141 141

	
142 142
      template <typename _Digraph, typename _Path, typename RevPathTag = void>
143 143
      struct PathDumperConstraints {
144 144
        void constraints() {
145 145
          int l = p.length();
146 146
          int e = p.empty();
147 147

	
148 148
          typename _Path::ArcIt id, i(p);
149 149

	
150 150
          ++i;
151 151
          typename _Digraph::Arc ed = i;
152 152

	
153 153
          e = (i == INVALID);
154 154
          e = (i != INVALID);
155 155

	
156 156
          ignore_unused_variable_warning(l);
157 157
          ignore_unused_variable_warning(e);
158 158
          ignore_unused_variable_warning(id);
159 159
          ignore_unused_variable_warning(ed);
160 160
        }
161 161
        _Path& p;
162 162
      };
163 163

	
164 164
      template <typename _Digraph, typename _Path>
165 165
      struct PathDumperConstraints<
166 166
        _Digraph, _Path,
167 167
        typename enable_if<typename _Path::RevPathTag, void>::type
168 168
      > {
169 169
        void constraints() {
170 170
          int l = p.length();
171 171
          int e = p.empty();
172 172

	
173 173
          typename _Path::RevArcIt id, i(p);
174 174

	
175 175
          ++i;
176 176
          typename _Digraph::Arc ed = i;
177 177

	
178 178
          e = (i == INVALID);
179 179
          e = (i != INVALID);
180 180

	
181 181
          ignore_unused_variable_warning(l);
182 182
          ignore_unused_variable_warning(e);
183 183
          ignore_unused_variable_warning(id);
184 184
          ignore_unused_variable_warning(ed);
185 185
        }
186 186
        _Path& p;
187 187
      };
188 188

	
189 189
    }
190 190

	
191 191

	
192 192
    /// \brief A skeleton structure for path dumpers.
193 193
    ///
194 194
    /// A skeleton structure for path dumpers. The path dumpers are
195 195
    /// the generalization of the paths. The path dumpers can
196 196
    /// enumerate the arcs of the path wheter in forward or in
197 197
    /// backward order.  In most time these classes are not used
198 198
    /// directly rather it used to assign a dumped class to a real
199 199
    /// path type.
200 200
    ///
201 201
    /// The main purpose of this concept is that the shortest path
202 202
    /// algorithms can enumerate easily the arcs in reverse order.
203 203
    /// If we would like to give back a real path from these
204 204
    /// algorithms then we should create a temporarly path object. In
205 205
    /// LEMON such algorithms gives back a path dumper what can
206 206
    /// assigned to a real path and the dumpers can be implemented as
207 207
    /// an adaptor class to the predecessor map.
208 208

	
209 209
    /// \tparam _Digraph  The digraph type in which the path is.
210 210
    ///
211 211
    /// The paths can be constructed from any path type by a
212 212
    /// template constructor or a template assignment operator.
213 213
    ///
214 214
    template <typename _Digraph>
215 215
    class PathDumper {
216 216
    public:
217 217

	
218 218
      /// Type of the underlying digraph.
219 219
      typedef _Digraph Digraph;
220 220
      /// Arc type of the underlying digraph.
221 221
      typedef typename Digraph::Arc Arc;
222 222

	
223 223
      /// Length of the path ie. the number of arcs in the path.
224 224
      int length() const { return 0;}
225 225

	
226 226
      /// Returns whether the path is empty.
227 227
      bool empty() const { return true;}
228 228

	
229 229
      /// \brief Forward or reverse dumping
230 230
      ///
231 231
      /// If the RevPathTag is defined and true then reverse dumping
232 232
      /// is provided in the path dumper. In this case instead of the
233 233
      /// ArcIt the RevArcIt iterator should be implemented in the
234 234
      /// dumper.
235 235
      typedef False RevPathTag;
236 236

	
237 237
      /// \brief LEMON style iterator for path arcs
238 238
      ///
239 239
      /// This class is used to iterate on the arcs of the paths.
240 240
      class ArcIt {
241 241
      public:
242 242
        /// Default constructor
243 243
        ArcIt() {}
244 244
        /// Invalid constructor
245 245
        ArcIt(Invalid) {}
246 246
        /// Constructor for first arc
247 247
        ArcIt(const PathDumper&) {}
248 248

	
249 249
        /// Conversion to Arc
250 250
        operator Arc() const { return INVALID; }
251 251

	
252 252
        /// Next arc
253 253
        ArcIt& operator++() {return *this;}
254 254

	
255 255
        /// Comparison operator
256 256
        bool operator==(const ArcIt&) const {return true;}
257 257
        /// Comparison operator
258 258
        bool operator!=(const ArcIt&) const {return true;}
259 259
        /// Comparison operator
260 260
        bool operator<(const ArcIt&) const {return false;}
261 261

	
262 262
      };
263 263

	
264 264
      /// \brief LEMON style iterator for path arcs
265 265
      ///
266 266
      /// This class is used to iterate on the arcs of the paths in
267 267
      /// reverse direction.
268 268
      class RevArcIt {
269 269
      public:
270 270
        /// Default constructor
271 271
        RevArcIt() {}
272 272
        /// Invalid constructor
273 273
        RevArcIt(Invalid) {}
274 274
        /// Constructor for first arc
275 275
        RevArcIt(const PathDumper &) {}
276 276

	
277 277
        /// Conversion to Arc
278 278
        operator Arc() const { return INVALID; }
279 279

	
280 280
        /// Next arc
281 281
        RevArcIt& operator++() {return *this;}
282 282

	
283 283
        /// Comparison operator
284 284
        bool operator==(const RevArcIt&) const {return true;}
285 285
        /// Comparison operator
286 286
        bool operator!=(const RevArcIt&) const {return true;}
287 287
        /// Comparison operator
288 288
        bool operator<(const RevArcIt&) const {return false;}
289 289

	
290 290
      };
291 291

	
292 292
      template <typename _Path>
293 293
      struct Constraints {
294 294
        void constraints() {
295 295
          function_requires<_path_bits::
296 296
            PathDumperConstraints<Digraph, _Path> >();
297 297
        }
298 298
      };
299 299

	
300 300
    };
301 301

	
302 302

	
303 303
    ///@}
304 304
  }
305 305

	
306 306
} // namespace lemon
307 307

	
308
#endif // LEMON_CONCEPT_PATH_H
308
#endif
Ignore white space 6 line context
1 1
/* -*- mode: C++; indent-tabs-mode: nil; -*-
2 2
 *
3 3
 * This file is a part of LEMON, a generic C++ optimization library.
4 4
 *
5 5
 * Copyright (C) 2003-2008
6 6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8 8
 *
9 9
 * Permission to use, modify and distribute this software is granted
10 10
 * provided that this copyright notice appears in all copies. For
11 11
 * precise terms see the accompanying LICENSE file.
12 12
 *
13 13
 * This software is provided "AS IS" with no warranty of any kind,
14 14
 * express or implied, and with no claim as to its suitability for any
15 15
 * purpose.
16 16
 *
17 17
 */
18 18

	
19
#ifndef LEMON_LP_SKELETON
20
#define LEMON_LP_SKELETON
19
#ifndef LEMON_LP_SKELETON_H
20
#define LEMON_LP_SKELETON_H
21 21

	
22 22
#include <lemon/lp_base.h>
23 23

	
24 24
///\file
25 25
///\brief A skeleton file to implement LP solver interfaces
26 26
namespace lemon {
27 27

	
28 28
  ///A skeleton class to implement LP solver interfaces
29 29
  class SkeletonSolverBase : public virtual LpBase {
30 30
    int col_num,row_num;
31 31

	
32 32
  protected:
33 33

	
34 34
    SkeletonSolverBase()
35 35
      : col_num(-1), row_num(-1) {}
36 36

	
37 37
    /// \e
38 38
    virtual int _addCol();
39 39
    /// \e
40 40
    virtual int _addRow();
41 41
    /// \e
42 42
    virtual void _eraseCol(int i);
43 43
    /// \e
44 44
    virtual void _eraseRow(int i);
45 45

	
46 46
    /// \e
47 47
    virtual void _getColName(int col, std::string& name) const;
48 48
    /// \e
49 49
    virtual void _setColName(int col, const std::string& name);
50 50
    /// \e
51 51
    virtual int _colByName(const std::string& name) const;
52 52

	
53 53
    /// \e
54 54
    virtual void _getRowName(int row, std::string& name) const;
55 55
    /// \e
56 56
    virtual void _setRowName(int row, const std::string& name);
57 57
    /// \e
58 58
    virtual int _rowByName(const std::string& name) const;
59 59

	
60 60
    /// \e
61 61
    virtual void _setRowCoeffs(int i, ExprIterator b, ExprIterator e);
62 62
    /// \e
63 63
    virtual void _getRowCoeffs(int i, InsertIterator b) const;
64 64
    /// \e
65 65
    virtual void _setColCoeffs(int i, ExprIterator b, ExprIterator e);
66 66
    /// \e
67 67
    virtual void _getColCoeffs(int i, InsertIterator b) const;
68 68

	
69 69
    /// Set one element of the coefficient matrix
70 70
    virtual void _setCoeff(int row, int col, Value value);
71 71

	
72 72
    /// Get one element of the coefficient matrix
73 73
    virtual Value _getCoeff(int row, int col) const;
74 74

	
75 75
    /// The lower bound of a variable (column) have to be given by an
76 76
    /// extended number of type Value, i.e. a finite number of type
77 77
    /// Value or -\ref INF.
78 78
    virtual void _setColLowerBound(int i, Value value);
79 79
    /// \e
80 80

	
81 81
    /// The lower bound of a variable (column) is an
82 82
    /// extended number of type Value, i.e. a finite number of type
83 83
    /// Value or -\ref INF.
84 84
    virtual Value _getColLowerBound(int i) const;
85 85

	
86 86
    /// The upper bound of a variable (column) have to be given by an
87 87
    /// extended number of type Value, i.e. a finite number of type
88 88
    /// Value or \ref INF.
89 89
    virtual void _setColUpperBound(int i, Value value);
90 90
    /// \e
91 91

	
92 92
    /// The upper bound of a variable (column) is an
93 93
    /// extended number of type Value, i.e. a finite number of type
94 94
    /// Value or \ref INF.
95 95
    virtual Value _getColUpperBound(int i) const;
96 96

	
97 97
    /// The lower bound of a constraint (row) have to be given by an
98 98
    /// extended number of type Value, i.e. a finite number of type
99 99
    /// Value or -\ref INF.
100 100
    virtual void _setRowLowerBound(int i, Value value);
101 101
    /// \e
102 102

	
103 103
    /// The lower bound of a constraint (row) is an
104 104
    /// extended number of type Value, i.e. a finite number of type
105 105
    /// Value or -\ref INF.
106 106
    virtual Value _getRowLowerBound(int i) const;
107 107

	
108 108
    /// The upper bound of a constraint (row) have to be given by an
109 109
    /// extended number of type Value, i.e. a finite number of type
110 110
    /// Value or \ref INF.
111 111
    virtual void _setRowUpperBound(int i, Value value);
112 112
    /// \e
113 113

	
114 114
    /// The upper bound of a constraint (row) is an
115 115
    /// extended number of type Value, i.e. a finite number of type
116 116
    /// Value or \ref INF.
117 117
    virtual Value _getRowUpperBound(int i) const;
118 118

	
119 119
    /// \e
120 120
    virtual void _setObjCoeffs(ExprIterator b, ExprIterator e);
121 121
    /// \e
122 122
    virtual void _getObjCoeffs(InsertIterator b) const;
123 123

	
124 124
    /// \e
125 125
    virtual void _setObjCoeff(int i, Value obj_coef);
126 126
    /// \e
127 127
    virtual Value _getObjCoeff(int i) const;
128 128

	
129 129
    ///\e
130 130
    virtual void _setSense(Sense);
131 131
    ///\e
132 132
    virtual Sense _getSense() const;
133 133

	
134 134
    ///\e
135 135
    virtual void _clear();
136 136

	
137 137
  };
138 138

	
139 139
  /// \brief Interface for a skeleton LP solver
140 140
  ///
141 141
  /// This class implements an interface for a skeleton LP solver.
142 142
  ///\ingroup lp_group
143 143
  class LpSkeleton : public SkeletonSolverBase, public LpSolver {
144 144
  public:
145 145
    LpSkeleton() : SkeletonSolverBase(), LpSolver() {}
146 146

	
147 147
  protected:
148 148

	
149 149
    ///\e
150 150
    virtual SolveExitStatus _solve();
151 151

	
152 152
    ///\e
153 153
    virtual Value _getPrimal(int i) const;
154 154
    ///\e
155 155
    virtual Value _getDual(int i) const;
156 156

	
157 157
    ///\e
158 158
    virtual Value _getPrimalValue() const;
159 159

	
160 160
    ///\e
161 161
    virtual Value _getPrimalRay(int i) const;
162 162
    ///\e
163 163
    virtual Value _getDualRay(int i) const;
164 164

	
165 165
    ///\e
166 166
    virtual ProblemType _getPrimalType() const;
167 167
    ///\e
168 168
    virtual ProblemType _getDualType() const;
169 169

	
170 170
    ///\e
171 171
    virtual VarStatus _getColStatus(int i) const;
172 172
    ///\e
173 173
    virtual VarStatus _getRowStatus(int i) const;
174 174

	
175 175
    ///\e
176 176
    virtual LpSkeleton* _newSolver() const;
177 177
    ///\e
178 178
    virtual LpSkeleton* _cloneSolver() const;
179 179
    ///\e
180 180
    virtual const char* _solverName() const;
181 181

	
182 182
  };
183 183

	
184 184
  /// \brief Interface for a skeleton MIP solver
185 185
  ///
186 186
  /// This class implements an interface for a skeleton MIP solver.
187 187
  ///\ingroup lp_group
188 188
  class MipSkeleton : public SkeletonSolverBase, public MipSolver {
189 189
  public:
190 190
    MipSkeleton() : SkeletonSolverBase(), MipSolver() {}
191 191

	
192 192
  protected:
193 193
    ///\e
194 194

	
195 195
    ///\bug Wrong interface
196 196
    ///
197 197
    virtual SolveExitStatus _solve();
198 198

	
199 199
    ///\e
200 200

	
201 201
    ///\bug Wrong interface
202 202
    ///
203 203
    virtual Value _getSol(int i) const;
204 204

	
205 205
    ///\e
206 206

	
207 207
    ///\bug Wrong interface
208 208
    ///
209 209
    virtual Value _getSolValue() const;
210 210

	
211 211
    ///\e
212 212

	
213 213
    ///\bug Wrong interface
214 214
    ///
215 215
    virtual ProblemType _getType() const;
216 216

	
217 217
    ///\e
218 218
    virtual MipSkeleton* _newSolver() const;
219 219

	
220 220
    ///\e
221 221
    virtual MipSkeleton* _cloneSolver() const;
222 222
    ///\e
223 223
    virtual const char* _solverName() const;
224 224

	
225 225
  };
226 226

	
227 227
} //namespace lemon
228 228

	
229
#endif // LEMON_LP_SKELETON
229
#endif
0 comments (0 inline)