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;
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.
... ...
@@ -391,97 +391,97 @@
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 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 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.
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 {
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
      ///
... ...
@@ -150,97 +150,97 @@
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

	
... ...
@@ -120,97 +120,97 @@
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 192 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

	
... ...
@@ -212,97 +212,97 @@
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.
... ...
@@ -133,97 +133,97 @@
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)