gravatar
alpar (Alpar Juttner)
alpar@cs.elte.hu
Merge various fixes
0 5 0
merge r1.1 1.1
0 files changed with 55 insertions and 25 deletions:
↑ Collapse diff ↑
Show white space 24 line context
... ...
@@ -9,28 +9,29 @@
9 9

	
10 10
PROJECT(${PROJECT_NAME})
11 11

	
12 12
SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
13 13

	
14 14
INCLUDE(FindDoxygen)
15 15
INCLUDE(FindGhostscript)
16 16
FIND_PACKAGE(GLPK 4.33)
17 17
FIND_PACKAGE(CPLEX)
18 18
FIND_PACKAGE(COIN)
19 19

	
20 20
IF(MSVC)
21
  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4250 /wd4355 /wd4800 /wd4996")
21
  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4250 /wd4355 /wd4503 /wd4800 /wd4996")
22 22
# Suppressed warnings:
23 23
# C4250: 'class1' : inherits 'class2::member' via dominance
24 24
# C4355: 'this' : used in base member initializer list
25
# C4503: 'function' : decorated name length exceeded, name was truncated
25 26
# C4800: 'type' : forcing value to bool 'true' or 'false' (performance warning)
26 27
# C4996: 'function': was declared deprecated
27 28
ENDIF(MSVC)
28 29

	
29 30
INCLUDE(CheckTypeSize)
30 31
CHECK_TYPE_SIZE("long long" LEMON_LONG_LONG)
31 32

	
32 33
ENABLE_TESTING()
33 34

	
34 35
ADD_SUBDIRECTORY(lemon)
35 36
IF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
36 37
  ADD_SUBDIRECTORY(demo)
Show white space 24 line context
1 1
EXTRA_DIST += \
2 2
	lemon/lemon.pc.in \
3
	lemon/CMakeLists.txt
3
	lemon/CMakeLists.txt \
4
	lemon/config.h.cmake
4 5

	
5 6
pkgconfig_DATA += lemon/lemon.pc
6 7

	
7 8
lib_LTLIBRARIES += lemon/libemon.la
8 9

	
9 10
lemon_libemon_la_SOURCES = \
10 11
	lemon/arg_parser.cc \
11 12
	lemon/base.cc \
12 13
	lemon/color.cc \
13 14
	lemon/lp_base.cc \
14 15
	lemon/lp_skeleton.cc \
15 16
	lemon/random.cc \
Show white space 24 line context
... ...
@@ -62,24 +62,29 @@
62 62
      /// \brief Constructor for conversion from \c INVALID.
63 63
      ///
64 64
      /// Constructor for conversion from \c INVALID.
65 65
      /// It initializes the item to be invalid.
66 66
      /// \sa Invalid for more details.
67 67
      GraphItem(Invalid) {}
68 68

	
69 69
      /// \brief Assignment operator.
70 70
      ///
71 71
      /// Assignment operator for the item.
72 72
      GraphItem& operator=(const GraphItem&) { return *this; }
73 73

	
74
      /// \brief Assignment operator for INVALID.
75
      ///
76
      /// This operator makes the item invalid.
77
      GraphItem& operator=(Invalid) { return *this; }
78

	
74 79
      /// \brief Equality operator.
75 80
      ///
76 81
      /// Equality operator.
77 82
      bool operator==(const GraphItem&) const { return false; }
78 83

	
79 84
      /// \brief Inequality operator.
80 85
      ///
81 86
      /// Inequality operator.
82 87
      bool operator!=(const GraphItem&) const { return false; }
83 88

	
84 89
      /// \brief Ordering operator.
85 90
      ///
... ...
@@ -87,24 +92,25 @@
87 92
      /// It makes possible to use graph item types as key types in 
88 93
      /// associative containers (e.g. \c std::map).
89 94
      ///
90 95
      /// \note This operator only have to define some strict ordering of
91 96
      /// the items; this order has nothing to do with the iteration
92 97
      /// ordering of the items.
93 98
      bool operator<(const GraphItem&) const { return false; }
94 99

	
95 100
      template<typename _GraphItem>
96 101
      struct Constraints {
97 102
        void constraints() {
98 103
          _GraphItem i1;
104
          i1=INVALID;
99 105
          _GraphItem i2 = i1;
100 106
          _GraphItem i3 = INVALID;
101 107

	
102 108
          i1 = i2 = i3;
103 109

	
104 110
          bool b;
105 111
          b = (ia == ib) && (ia != ib);
106 112
          b = (ia == INVALID) && (ib != INVALID);
107 113
          b = (ia < ib);
108 114
        }
109 115

	
110 116
        const _GraphItem &ia;
... ...
@@ -212,31 +218,24 @@
212 218
        ///
213 219
        /// Constructor for conversion from \c INVALID.
214 220
        /// It initializes the item to be invalid.
215 221
        /// \sa Invalid for more details.
216 222
        Edge(Invalid) {}
217 223

	
218 224
        /// \brief Constructor for conversion from an arc.
219 225
        ///
220 226
        /// Constructor for conversion from an arc.
221 227
        /// Besides the core graph item functionality each arc should
222 228
        /// be convertible to the represented edge.
223 229
        Edge(const Arc&) {}
224

	
225
        /// \brief Assign an arc to an edge.
226
        ///
227
        /// This function assigns an arc to an edge.
228
        /// Besides the core graph item functionality each arc should
229
        /// be convertible to the represented edge.
230
        Edge& operator=(const Arc&) { return *this; }
231 230
      };
232 231

	
233 232
      /// \brief Return one end node of an edge.
234 233
      ///
235 234
      /// This function returns one end node of an edge.
236 235
      Node u(const Edge&) const { return INVALID; }
237 236

	
238 237
      /// \brief Return the other end node of an edge.
239 238
      ///
240 239
      /// This function returns the other end node of an edge.
241 240
      Node v(const Edge&) const { return INVALID; }
242 241

	
... ...
@@ -344,28 +343,30 @@
344 343
      /// arc id.
345 344
      ///
346 345
      /// This function returns an integer greater or equal to the
347 346
      /// maximum arc id.
348 347
      int maxArcId() const { return -1; }
349 348

	
350 349
      template <typename _Digraph>
351 350
      struct Constraints {
352 351

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

	
364 365
          nid = digraph.maxNodeId();
365 366
          ignore_unused_variable_warning(nid);
366 367
          eid = digraph.maxArcId();
367 368
          ignore_unused_variable_warning(eid);
368 369
        }
369 370

	
370 371
        const _Digraph& digraph;
371 372
      };
Show white space 24 line context
... ...
@@ -75,24 +75,30 @@
75 75
      Arc(int _id) : id(_id) {}
76 76
      int id;
77 77
    public:
78 78
      Arc() {}
79 79
      Arc(Invalid) : id(-1) {}
80 80
      bool operator==(const Arc& arc) const { return id == arc.id; }
81 81
      bool operator!=(const Arc& arc) const { return id != arc.id; }
82 82
      bool operator<(const Arc& arc) const { return id < arc.id; }
83 83
    };
84 84

	
85 85
    ListArcSetBase() : first_arc(-1), first_free_arc(-1) {}
86 86

	
87
    Node addNode() {
88
      LEMON_ASSERT(false,
89
        "This graph structure does not support node insertion");
90
      return INVALID; // avoid warning
91
    }
92

	
87 93
    Arc addArc(const Node& u, const Node& v) {
88 94
      int n;
89 95
      if (first_free_arc == -1) {
90 96
        n = arcs.size();
91 97
        arcs.push_back(ArcT());
92 98
      } else {
93 99
        n = first_free_arc;
94 100
        first_free_arc = arcs[first_free_arc].next_in;
95 101
      }
96 102
      arcs[n].next_in = (*_nodes)[v].first_in;
97 103
      if ((*_nodes)[v].first_in != -1) {
98 104
        arcs[(*_nodes)[v].first_in].prev_in = n;
... ...
@@ -407,24 +413,30 @@
407 413
    public:
408 414
      operator Edge() const { return edgeFromId(id / 2); }
409 415

	
410 416
      Arc() {}
411 417
      Arc(Invalid) : id(-1) {}
412 418
      bool operator==(const Arc& arc) const { return id == arc.id; }
413 419
      bool operator!=(const Arc& arc) const { return id != arc.id; }
414 420
      bool operator<(const Arc& arc) const { return id < arc.id; }
415 421
    };
416 422

	
417 423
    ListEdgeSetBase() : first_arc(-1), first_free_arc(-1) {}
418 424

	
425
    Node addNode() {
426
      LEMON_ASSERT(false,
427
        "This graph structure does not support node insertion");
428
      return INVALID; // avoid warning
429
    }
430

	
419 431
    Edge addEdge(const Node& u, const Node& v) {
420 432
      int n;
421 433

	
422 434
      if (first_free_arc == -1) {
423 435
        n = arcs.size();
424 436
        arcs.push_back(ArcT());
425 437
        arcs.push_back(ArcT());
426 438
      } else {
427 439
        n = first_free_arc;
428 440
        first_free_arc = arcs[n].next_out;
429 441
      }
430 442

	
... ...
@@ -807,24 +819,30 @@
807 819
      Arc(int _id) : id(_id) {}
808 820
      int id;
809 821
    public:
810 822
      Arc() {}
811 823
      Arc(Invalid) : id(-1) {}
812 824
      bool operator==(const Arc& arc) const { return id == arc.id; }
813 825
      bool operator!=(const Arc& arc) const { return id != arc.id; }
814 826
      bool operator<(const Arc& arc) const { return id < arc.id; }
815 827
    };
816 828

	
817 829
    SmartArcSetBase() {}
818 830

	
831
    Node addNode() {
832
      LEMON_ASSERT(false,
833
        "This graph structure does not support node insertion");
834
      return INVALID; // avoid warning
835
    }
836

	
819 837
    Arc addArc(const Node& u, const Node& v) {
820 838
      int n = arcs.size();
821 839
      arcs.push_back(ArcT());
822 840
      arcs[n].next_in = (*_nodes)[v].first_in;
823 841
      (*_nodes)[v].first_in = n;
824 842
      arcs[n].next_out = (*_nodes)[u].first_out;
825 843
      (*_nodes)[u].first_out = n;
826 844
      arcs[n].source = u;
827 845
      arcs[n].target = v;
828 846
      return Arc(n);
829 847
    }
830 848

	
... ...
@@ -1103,24 +1121,30 @@
1103 1121
    public:
1104 1122
      operator Edge() const { return edgeFromId(id / 2); }
1105 1123

	
1106 1124
      Arc() {}
1107 1125
      Arc(Invalid) : id(-1) {}
1108 1126
      bool operator==(const Arc& arc) const { return id == arc.id; }
1109 1127
      bool operator!=(const Arc& arc) const { return id != arc.id; }
1110 1128
      bool operator<(const Arc& arc) const { return id < arc.id; }
1111 1129
    };
1112 1130

	
1113 1131
    SmartEdgeSetBase() {}
1114 1132

	
1133
    Node addNode() {
1134
      LEMON_ASSERT(false,
1135
        "This graph structure does not support node insertion");
1136
      return INVALID; // avoid warning
1137
    }
1138

	
1115 1139
    Edge addEdge(const Node& u, const Node& v) {
1116 1140
      int n = arcs.size();
1117 1141
      arcs.push_back(ArcT());
1118 1142
      arcs.push_back(ArcT());
1119 1143

	
1120 1144
      arcs[n].target = u;
1121 1145
      arcs[n | 1].target = v;
1122 1146

	
1123 1147
      arcs[n].next_out = (*_nodes)[v].first_out;
1124 1148
      (*_nodes)[v].first_out = n;
1125 1149

	
1126 1150
      arcs[n | 1].next_out = (*_nodes)[u].first_out;
Show white space 24 line context
... ...
@@ -85,59 +85,62 @@
85 85

	
86 86
// Check the interface of an MCF algorithm
87 87
template <typename GR, typename Value, typename Cost>
88 88
class McfClassConcept
89 89
{
90 90
public:
91 91

	
92 92
  template <typename MCF>
93 93
  struct Constraints {
94 94
    void constraints() {
95 95
      checkConcept<concepts::Digraph, GR>();
96 96

	
97
      MCF mcf(g);
97
      const Constraints& me = *this;
98

	
99
      MCF mcf(me.g);
98 100
      const MCF& const_mcf = mcf;
99 101

	
100 102
      b = mcf.reset()
101
             .lowerMap(lower)
102
             .upperMap(upper)
103
             .costMap(cost)
104
             .supplyMap(sup)
105
             .stSupply(n, n, k)
103
             .lowerMap(me.lower)
104
             .upperMap(me.upper)
105
             .costMap(me.cost)
106
             .supplyMap(me.sup)
107
             .stSupply(me.n, me.n, me.k)
106 108
             .run();
107 109

	
108 110
      c = const_mcf.totalCost();
109 111
      x = const_mcf.template totalCost<double>();
110
      v = const_mcf.flow(a);
111
      c = const_mcf.potential(n);
112
      v = const_mcf.flow(me.a);
113
      c = const_mcf.potential(me.n);
112 114
      const_mcf.flowMap(fm);
113 115
      const_mcf.potentialMap(pm);
114 116
    }
115 117

	
116 118
    typedef typename GR::Node Node;
117 119
    typedef typename GR::Arc Arc;
118 120
    typedef concepts::ReadMap<Node, Value> NM;
119 121
    typedef concepts::ReadMap<Arc, Value> VAM;
120 122
    typedef concepts::ReadMap<Arc, Cost> CAM;
121 123
    typedef concepts::WriteMap<Arc, Value> FlowMap;
122 124
    typedef concepts::WriteMap<Node, Cost> PotMap;
123 125

	
124
    const GR &g;
125
    const VAM &lower;
126
    const VAM &upper;
127
    const CAM &cost;
128
    const NM &sup;
129
    const Node &n;
130
    const Arc &a;
131
    const Value &k;
126
    GR g;
127
    VAM lower;
128
    VAM upper;
129
    CAM cost;
130
    NM sup;
131
    Node n;
132
    Arc a;
133
    Value k;
134

	
132 135
    FlowMap fm;
133 136
    PotMap pm;
134 137
    bool b;
135 138
    double x;
136 139
    typename MCF::Value v;
137 140
    typename MCF::Cost c;
138 141
  };
139 142

	
140 143
};
141 144

	
142 145

	
143 146
// Check the feasibility of the given flow (primal soluiton)
0 comments (0 inline)