mip_test file went to mip_demo.
3 * This file is a part of LEMON, a generic C++ optimization library
5 * Copyright (C) 2003-2006
6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 * (Egervary Research Group on Combinatorial Optimization, EGRES).
9 * Permission to use, modify and distribute this software is granted
10 * provided that this copyright notice appears in all copies. For
11 * precise terms see the accompanying LICENSE file.
13 * This software is provided "AS IS" with no warranty of any kind,
14 * express or implied, and with no claim as to its suitability for any
19 #ifndef LEMON_BITS_TRAITS_H
20 #define LEMON_BITS_TRAITS_H
22 #include <lemon/bits/utility.h>
25 ///\brief Traits for graphs and maps
29 template <typename _Graph, typename _Item>
30 class ItemSetTraits {};
33 template <typename Graph, typename Enable = void>
34 struct NodeNotifierIndicator {
35 typedef InvalidType Type;
37 template <typename Graph>
38 struct NodeNotifierIndicator<
40 typename enable_if<typename Graph::NodeNotifier::Notifier, void>::type
42 typedef typename Graph::NodeNotifier Type;
45 template <typename _Graph>
46 class ItemSetTraits<_Graph, typename _Graph::Node> {
51 typedef typename Graph::Node Item;
52 typedef typename Graph::NodeIt ItemIt;
54 typedef typename NodeNotifierIndicator<Graph>::Type ItemNotifier;
56 template <typename _Value>
57 class Map : public Graph::template NodeMap<_Value> {
59 typedef typename Graph::template NodeMap<_Value> Parent;
60 typedef typename Parent::Value Value;
62 Map(const Graph& _graph) : Parent(_graph) {}
63 Map(const Graph& _graph, const Value& _value)
64 : Parent(_graph, _value) {}
70 template <typename Graph, typename Enable = void>
71 struct EdgeNotifierIndicator {
72 typedef InvalidType Type;
74 template <typename Graph>
75 struct EdgeNotifierIndicator<
77 typename enable_if<typename Graph::EdgeNotifier::Notifier, void>::type
79 typedef typename Graph::EdgeNotifier Type;
82 template <typename _Graph>
83 class ItemSetTraits<_Graph, typename _Graph::Edge> {
88 typedef typename Graph::Edge Item;
89 typedef typename Graph::EdgeIt ItemIt;
91 typedef typename EdgeNotifierIndicator<Graph>::Type ItemNotifier;
93 template <typename _Value>
94 class Map : public Graph::template EdgeMap<_Value> {
96 typedef typename Graph::template EdgeMap<_Value> Parent;
97 typedef typename Parent::Value Value;
99 Map(const Graph& _graph) : Parent(_graph) {}
100 Map(const Graph& _graph, const Value& _value)
101 : Parent(_graph, _value) {}
106 template <typename Graph, typename Enable = void>
107 struct UEdgeNotifierIndicator {
108 typedef InvalidType Type;
110 template <typename Graph>
111 struct UEdgeNotifierIndicator<
113 typename enable_if<typename Graph::UEdgeNotifier::Notifier, void>::type
115 typedef typename Graph::UEdgeNotifier Type;
118 template <typename _Graph>
119 class ItemSetTraits<_Graph, typename _Graph::UEdge> {
122 typedef _Graph Graph;
124 typedef typename Graph::UEdge Item;
125 typedef typename Graph::UEdgeIt ItemIt;
127 typedef typename UEdgeNotifierIndicator<Graph>::Type ItemNotifier;
129 template <typename _Value>
130 class Map : public Graph::template UEdgeMap<_Value> {
132 typedef typename Graph::template UEdgeMap<_Value> Parent;
133 typedef typename Parent::Value Value;
135 Map(const Graph& _graph) : Parent(_graph) {}
136 Map(const Graph& _graph, const Value& _value)
137 : Parent(_graph, _value) {}
142 template <typename Graph, typename Enable = void>
143 struct ANodeNotifierIndicator {
144 typedef InvalidType Type;
146 template <typename Graph>
147 struct ANodeNotifierIndicator<
149 typename enable_if<typename Graph::ANodeNotifier::Notifier, void>::type
151 typedef typename Graph::ANodeNotifier Type;
154 template <typename _Graph>
155 class ItemSetTraits<_Graph, typename _Graph::ANode> {
158 typedef _Graph Graph;
160 typedef typename Graph::ANode Item;
161 typedef typename Graph::ANodeIt ItemIt;
163 typedef typename ANodeNotifierIndicator<Graph>::Type ItemNotifier;
165 template <typename _Value>
166 class Map : public Graph::template ANodeMap<_Value> {
168 typedef typename Graph::template ANodeMap<_Value> Parent;
169 typedef typename Parent::Value Value;
171 Map(const Graph& _graph) : Parent(_graph) {}
172 Map(const Graph& _graph, const Value& _value)
173 : Parent(_graph, _value) {}
178 template <typename Graph, typename Enable = void>
179 struct BNodeNotifierIndicator {
180 typedef InvalidType Type;
182 template <typename Graph>
183 struct BNodeNotifierIndicator<
185 typename enable_if<typename Graph::BNodeNotifier::Notifier, void>::type
187 typedef typename Graph::BNodeNotifier Type;
190 template <typename _Graph>
191 class ItemSetTraits<_Graph, typename _Graph::BNode> {
194 typedef _Graph Graph;
196 typedef typename Graph::BNode Item;
197 typedef typename Graph::BNodeIt ItemIt;
199 typedef typename BNodeNotifierIndicator<Graph>::Type ItemNotifier;
201 template <typename _Value>
202 class Map : public Graph::template BNodeMap<_Value> {
204 typedef typename Graph::template BNodeMap<_Value> Parent;
205 typedef typename Parent::Value Value;
207 Map(const Graph& _graph) : Parent(_graph) {}
208 Map(const Graph& _graph, const Value& _value)
209 : Parent(_graph, _value) {}
215 template <typename Map, typename Enable = void>
217 typedef False ReferenceMapTag;
219 typedef typename Map::Key Key;
220 typedef typename Map::Value Value;
222 typedef const Value ConstReturnValue;
223 typedef const Value ReturnValue;
226 template <typename Map>
228 Map, typename enable_if<typename Map::ReferenceMapTag, void>::type >
230 typedef True ReferenceMapTag;
232 typedef typename Map::Key Key;
233 typedef typename Map::Value Value;
235 typedef typename Map::ConstReference ConstReturnValue;
236 typedef typename Map::Reference ReturnValue;
238 typedef typename Map::ConstReference ConstReference;
239 typedef typename Map::Reference Reference;
242 template <typename MatrixMap, typename Enable = void>
243 struct MatrixMapTraits {
244 typedef False ReferenceMapTag;
246 typedef typename MatrixMap::FirstKey FirstKey;
247 typedef typename MatrixMap::SecondKey SecondKey;
248 typedef typename MatrixMap::Value Value;
250 typedef const Value ConstReturnValue;
251 typedef const Value ReturnValue;
254 template <typename MatrixMap>
255 struct MatrixMapTraits<
256 MatrixMap, typename enable_if<typename MatrixMap::ReferenceMapTag,
259 typedef True ReferenceMapTag;
261 typedef typename MatrixMap::FirstKey FirstKey;
262 typedef typename MatrixMap::SecondKey SecondKey;
263 typedef typename MatrixMap::Value Value;
265 typedef typename MatrixMap::ConstReference ConstReturnValue;
266 typedef typename MatrixMap::Reference ReturnValue;
268 typedef typename MatrixMap::ConstReference ConstReference;
269 typedef typename MatrixMap::Reference Reference;
272 // Indicators for the tags
274 template <typename Graph, typename Enable = void>
275 struct NodeNumTagIndicator {
276 static const bool value = false;
279 template <typename Graph>
280 struct NodeNumTagIndicator<
282 typename enable_if<typename Graph::NodeNumTag, void>::type
284 static const bool value = true;
287 template <typename Graph, typename Enable = void>
288 struct EdgeNumTagIndicator {
289 static const bool value = false;
292 template <typename Graph>
293 struct EdgeNumTagIndicator<
295 typename enable_if<typename Graph::EdgeNumTag, void>::type
297 static const bool value = true;
300 template <typename Graph, typename Enable = void>
301 struct FindEdgeTagIndicator {
302 static const bool value = false;
305 template <typename Graph>
306 struct FindEdgeTagIndicator<
308 typename enable_if<typename Graph::FindEdgeTag, void>::type
310 static const bool value = true;
313 template <typename Graph, typename Enable = void>
314 struct UndirectedTagIndicator {
315 static const bool value = false;
318 template <typename Graph>
319 struct UndirectedTagIndicator<
321 typename enable_if<typename Graph::UndirectedTag, void>::type
323 static const bool value = true;