Unionfind changes induced some bugs here. Also some augmentations made.
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 // Indicators for the tags
244 template <typename Graph, typename Enable = void>
245 struct NodeNumTagIndicator {
246 static const bool value = false;
249 template <typename Graph>
250 struct NodeNumTagIndicator<
252 typename enable_if<typename Graph::NodeNumTag, void>::type
254 static const bool value = true;
257 template <typename Graph, typename Enable = void>
258 struct EdgeNumTagIndicator {
259 static const bool value = false;
262 template <typename Graph>
263 struct EdgeNumTagIndicator<
265 typename enable_if<typename Graph::EdgeNumTag, void>::type
267 static const bool value = true;
270 template <typename Graph, typename Enable = void>
271 struct FindEdgeTagIndicator {
272 static const bool value = false;
275 template <typename Graph>
276 struct FindEdgeTagIndicator<
278 typename enable_if<typename Graph::FindEdgeTag, void>::type
280 static const bool value = true;
283 template <typename Graph, typename Enable = void>
284 struct UndirectedTagIndicator {
285 static const bool value = false;
288 template <typename Graph>
289 struct UndirectedTagIndicator<
291 typename enable_if<typename Graph::UndirectedTag, void>::type
293 static const bool value = true;