0
8
0
46
46
28
30
45
45
32
31
13
13
... | ... |
@@ -46,32 +46,32 @@ |
46 | 46 |
///arcs of the shortest paths. |
47 | 47 |
/// |
48 | 48 |
///The type of the map that stores the predecessor |
49 | 49 |
///arcs of the shortest paths. |
50 | 50 |
///It must meet the \ref concepts::WriteMap "WriteMap" concept. |
51 | 51 |
typedef typename Digraph::template NodeMap<typename Digraph::Arc> PredMap; |
52 |
///Instantiates a PredMap. |
|
52 |
///Instantiates a \c PredMap. |
|
53 | 53 |
|
54 |
///This function instantiates a PredMap. |
|
54 |
///This function instantiates a \ref PredMap. |
|
55 | 55 |
///\param g is the digraph, to which we would like to define the |
56 |
///PredMap. |
|
56 |
///\ref PredMap. |
|
57 | 57 |
static PredMap *createPredMap(const Digraph &g) |
58 | 58 |
{ |
59 | 59 |
return new PredMap(g); |
60 | 60 |
} |
61 | 61 |
|
62 | 62 |
///The type of the map that indicates which nodes are processed. |
63 | 63 |
|
64 | 64 |
///The type of the map that indicates which nodes are processed. |
65 | 65 |
///It must meet the \ref concepts::WriteMap "WriteMap" concept. |
66 | 66 |
typedef NullMap<typename Digraph::Node,bool> ProcessedMap; |
67 |
///Instantiates a ProcessedMap. |
|
67 |
///Instantiates a \c ProcessedMap. |
|
68 | 68 |
|
69 |
///This function instantiates a ProcessedMap. |
|
69 |
///This function instantiates a \ref ProcessedMap. |
|
70 | 70 |
///\param g is the digraph, to which |
71 |
///we would like to define the ProcessedMap |
|
71 |
///we would like to define the \ref ProcessedMap |
|
72 | 72 |
#ifdef DOXYGEN |
73 | 73 |
static ProcessedMap *createProcessedMap(const Digraph &g) |
74 | 74 |
#else |
75 | 75 |
static ProcessedMap *createProcessedMap(const Digraph &) |
76 | 76 |
#endif |
77 | 77 |
{ |
... | ... |
@@ -80,32 +80,32 @@ |
80 | 80 |
|
81 | 81 |
///The type of the map that indicates which nodes are reached. |
82 | 82 |
|
83 | 83 |
///The type of the map that indicates which nodes are reached. |
84 | 84 |
///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept. |
85 | 85 |
typedef typename Digraph::template NodeMap<bool> ReachedMap; |
86 |
///Instantiates a ReachedMap. |
|
86 |
///Instantiates a \c ReachedMap. |
|
87 | 87 |
|
88 |
///This function instantiates a ReachedMap. |
|
88 |
///This function instantiates a \ref ReachedMap. |
|
89 | 89 |
///\param g is the digraph, to which |
90 |
///we would like to define the ReachedMap. |
|
90 |
///we would like to define the \ref ReachedMap. |
|
91 | 91 |
static ReachedMap *createReachedMap(const Digraph &g) |
92 | 92 |
{ |
93 | 93 |
return new ReachedMap(g); |
94 | 94 |
} |
95 | 95 |
|
96 | 96 |
///The type of the map that stores the distances of the nodes. |
97 | 97 |
|
98 | 98 |
///The type of the map that stores the distances of the nodes. |
99 | 99 |
///It must meet the \ref concepts::WriteMap "WriteMap" concept. |
100 | 100 |
typedef typename Digraph::template NodeMap<int> DistMap; |
101 |
///Instantiates a DistMap. |
|
101 |
///Instantiates a \c DistMap. |
|
102 | 102 |
|
103 |
///This function instantiates a DistMap. |
|
103 |
///This function instantiates a \ref DistMap. |
|
104 | 104 |
///\param g is the digraph, to which we would like to define the |
105 |
///DistMap. |
|
105 |
///\ref DistMap. |
|
106 | 106 |
static DistMap *createDistMap(const Digraph &g) |
107 | 107 |
{ |
108 | 108 |
return new DistMap(g); |
109 | 109 |
} |
110 | 110 |
}; |
111 | 111 |
|
... | ... |
@@ -218,16 +218,16 @@ |
218 | 218 |
{ |
219 | 219 |
LEMON_ASSERT(false, "PredMap is not initialized"); |
220 | 220 |
return 0; // ignore warnings |
221 | 221 |
} |
222 | 222 |
}; |
223 | 223 |
///\brief \ref named-templ-param "Named parameter" for setting |
224 |
///PredMap type. |
|
224 |
///\c PredMap type. |
|
225 | 225 |
/// |
226 | 226 |
///\ref named-templ-param "Named parameter" for setting |
227 |
///PredMap type. |
|
227 |
///\c PredMap type. |
|
228 | 228 |
///It must meet the \ref concepts::WriteMap "WriteMap" concept. |
229 | 229 |
template <class T> |
230 | 230 |
struct SetPredMap : public Bfs< Digraph, SetPredMapTraits<T> > { |
231 | 231 |
typedef Bfs< Digraph, SetPredMapTraits<T> > Create; |
232 | 232 |
}; |
233 | 233 |
|
... | ... |
@@ -238,16 +238,16 @@ |
238 | 238 |
{ |
239 | 239 |
LEMON_ASSERT(false, "DistMap is not initialized"); |
240 | 240 |
return 0; // ignore warnings |
241 | 241 |
} |
242 | 242 |
}; |
243 | 243 |
///\brief \ref named-templ-param "Named parameter" for setting |
244 |
///DistMap type. |
|
244 |
///\c DistMap type. |
|
245 | 245 |
/// |
246 | 246 |
///\ref named-templ-param "Named parameter" for setting |
247 |
///DistMap type. |
|
247 |
///\c DistMap type. |
|
248 | 248 |
///It must meet the \ref concepts::WriteMap "WriteMap" concept. |
249 | 249 |
template <class T> |
250 | 250 |
struct SetDistMap : public Bfs< Digraph, SetDistMapTraits<T> > { |
251 | 251 |
typedef Bfs< Digraph, SetDistMapTraits<T> > Create; |
252 | 252 |
}; |
253 | 253 |
|
... | ... |
@@ -258,16 +258,16 @@ |
258 | 258 |
{ |
259 | 259 |
LEMON_ASSERT(false, "ReachedMap is not initialized"); |
260 | 260 |
return 0; // ignore warnings |
261 | 261 |
} |
262 | 262 |
}; |
263 | 263 |
///\brief \ref named-templ-param "Named parameter" for setting |
264 |
///ReachedMap type. |
|
264 |
///\c ReachedMap type. |
|
265 | 265 |
/// |
266 | 266 |
///\ref named-templ-param "Named parameter" for setting |
267 |
///ReachedMap type. |
|
267 |
///\c ReachedMap type. |
|
268 | 268 |
///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept. |
269 | 269 |
template <class T> |
270 | 270 |
struct SetReachedMap : public Bfs< Digraph, SetReachedMapTraits<T> > { |
271 | 271 |
typedef Bfs< Digraph, SetReachedMapTraits<T> > Create; |
272 | 272 |
}; |
273 | 273 |
|
... | ... |
@@ -278,16 +278,16 @@ |
278 | 278 |
{ |
279 | 279 |
LEMON_ASSERT(false, "ProcessedMap is not initialized"); |
280 | 280 |
return 0; // ignore warnings |
281 | 281 |
} |
282 | 282 |
}; |
283 | 283 |
///\brief \ref named-templ-param "Named parameter" for setting |
284 |
///ProcessedMap type. |
|
284 |
///\c ProcessedMap type. |
|
285 | 285 |
/// |
286 | 286 |
///\ref named-templ-param "Named parameter" for setting |
287 |
///ProcessedMap type. |
|
287 |
///\c ProcessedMap type. |
|
288 | 288 |
///It must meet the \ref concepts::WriteMap "WriteMap" concept. |
289 | 289 |
template <class T> |
290 | 290 |
struct SetProcessedMap : public Bfs< Digraph, SetProcessedMapTraits<T> > { |
291 | 291 |
typedef Bfs< Digraph, SetProcessedMapTraits<T> > Create; |
292 | 292 |
}; |
293 | 293 |
|
... | ... |
@@ -297,16 +297,16 @@ |
297 | 297 |
{ |
298 | 298 |
return new ProcessedMap(g); |
299 | 299 |
return 0; // ignore warnings |
300 | 300 |
} |
301 | 301 |
}; |
302 | 302 |
///\brief \ref named-templ-param "Named parameter" for setting |
303 |
///ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>. |
|
303 |
///\c ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>. |
|
304 | 304 |
/// |
305 | 305 |
///\ref named-templ-param "Named parameter" for setting |
306 |
///ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>. |
|
306 |
///\c ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>. |
|
307 | 307 |
///If you don't set it explicitly, it will be automatically allocated. |
308 | 308 |
struct SetStandardProcessedMap : |
309 | 309 |
public Bfs< Digraph, SetStandardProcessedMapTraits > { |
310 | 310 |
typedef Bfs< Digraph, SetStandardProcessedMapTraits > Create; |
311 | 311 |
}; |
312 | 312 |
|
... | ... |
@@ -1191,15 +1191,15 @@ |
1191 | 1191 |
|
1192 | 1192 |
#ifdef DOXYGEN |
1193 | 1193 |
/// \brief Visitor class for BFS. |
1194 | 1194 |
/// |
1195 | 1195 |
/// This class defines the interface of the BfsVisit events, and |
1196 | 1196 |
/// it could be the base of a real visitor class. |
1197 |
template <typename |
|
1197 |
template <typename GR> |
|
1198 | 1198 |
struct BfsVisitor { |
1199 |
typedef |
|
1199 |
typedef GR Digraph; |
|
1200 | 1200 |
typedef typename Digraph::Arc Arc; |
1201 | 1201 |
typedef typename Digraph::Node Node; |
1202 | 1202 |
/// \brief Called for the source node(s) of the BFS. |
1203 | 1203 |
/// |
1204 | 1204 |
/// This function is called for the source node(s) of the BFS. |
1205 | 1205 |
void start(const Node& node) {} |
... | ... |
@@ -1221,15 +1221,15 @@ |
1221 | 1221 |
/// |
1222 | 1222 |
/// This function is called when an arc is examined but its target node is |
1223 | 1223 |
/// already discovered. |
1224 | 1224 |
void examine(const Arc& arc) {} |
1225 | 1225 |
}; |
1226 | 1226 |
#else |
1227 |
template <typename |
|
1227 |
template <typename GR> |
|
1228 | 1228 |
struct BfsVisitor { |
1229 |
typedef |
|
1229 |
typedef GR Digraph; |
|
1230 | 1230 |
typedef typename Digraph::Arc Arc; |
1231 | 1231 |
typedef typename Digraph::Node Node; |
1232 | 1232 |
void start(const Node&) {} |
1233 | 1233 |
void reach(const Node&) {} |
1234 | 1234 |
void process(const Node&) {} |
1235 | 1235 |
void discover(const Arc&) {} |
... | ... |
@@ -1251,18 +1251,18 @@ |
1251 | 1251 |
}; |
1252 | 1252 |
#endif |
1253 | 1253 |
|
1254 | 1254 |
/// \brief Default traits class of BfsVisit class. |
1255 | 1255 |
/// |
1256 | 1256 |
/// Default traits class of BfsVisit class. |
1257 |
/// \tparam _Digraph The type of the digraph the algorithm runs on. |
|
1258 |
template<class _Digraph> |
|
1257 |
/// \tparam GR The type of the digraph the algorithm runs on. |
|
1258 |
template<class GR> |
|
1259 | 1259 |
struct BfsVisitDefaultTraits { |
1260 | 1260 |
|
1261 | 1261 |
/// \brief The type of the digraph the algorithm runs on. |
1262 |
typedef |
|
1262 |
typedef GR Digraph; |
|
1263 | 1263 |
|
1264 | 1264 |
/// \brief The type of the map that indicates which nodes are reached. |
1265 | 1265 |
/// |
1266 | 1266 |
/// The type of the map that indicates which nodes are reached. |
1267 | 1267 |
/// It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept. |
1268 | 1268 |
typedef typename Digraph::template NodeMap<bool> ReachedMap; |
... | ... |
@@ -1277,57 +1277,57 @@ |
1277 | 1277 |
} |
1278 | 1278 |
|
1279 | 1279 |
}; |
1280 | 1280 |
|
1281 | 1281 |
/// \ingroup search |
1282 | 1282 |
/// |
1283 |
/// \brief |
|
1283 |
/// \brief BFS algorithm class with visitor interface. |
|
1284 | 1284 |
/// |
1285 |
/// This class provides an efficient implementation of the |
|
1285 |
/// This class provides an efficient implementation of the BFS algorithm |
|
1286 | 1286 |
/// with visitor interface. |
1287 | 1287 |
/// |
1288 |
/// The |
|
1288 |
/// The BfsVisit class provides an alternative interface to the Bfs |
|
1289 | 1289 |
/// class. It works with callback mechanism, the BfsVisit object calls |
1290 | 1290 |
/// the member functions of the \c Visitor class on every BFS event. |
1291 | 1291 |
/// |
1292 | 1292 |
/// This interface of the BFS algorithm should be used in special cases |
1293 | 1293 |
/// when extra actions have to be performed in connection with certain |
1294 | 1294 |
/// events of the BFS algorithm. Otherwise consider to use Bfs or bfs() |
1295 | 1295 |
/// instead. |
1296 | 1296 |
/// |
1297 |
/// \tparam _Digraph The type of the digraph the algorithm runs on. |
|
1298 |
/// The default value is |
|
1299 |
/// \ref ListDigraph. The value of _Digraph is not used directly by |
|
1300 |
/// \ref BfsVisit, it is only passed to \ref BfsVisitDefaultTraits. |
|
1301 |
/// \tparam _Visitor The Visitor type that is used by the algorithm. |
|
1302 |
/// \ref BfsVisitor "BfsVisitor<_Digraph>" is an empty visitor, which |
|
1297 |
/// \tparam GR The type of the digraph the algorithm runs on. |
|
1298 |
/// The default type is \ref ListDigraph. |
|
1299 |
/// The value of GR is not used directly by \ref BfsVisit, |
|
1300 |
/// it is only passed to \ref BfsVisitDefaultTraits. |
|
1301 |
/// \tparam VS The Visitor type that is used by the algorithm. |
|
1302 |
/// \ref BfsVisitor "BfsVisitor<GR>" is an empty visitor, which |
|
1303 | 1303 |
/// does not observe the BFS events. If you want to observe the BFS |
1304 | 1304 |
/// events, you should implement your own visitor class. |
1305 |
/// \tparam |
|
1305 |
/// \tparam TR Traits class to set various data types used by the |
|
1306 | 1306 |
/// algorithm. The default traits class is |
1307 |
/// \ref BfsVisitDefaultTraits "BfsVisitDefaultTraits< |
|
1307 |
/// \ref BfsVisitDefaultTraits "BfsVisitDefaultTraits<GR>". |
|
1308 | 1308 |
/// See \ref BfsVisitDefaultTraits for the documentation of |
1309 | 1309 |
/// a BFS visit traits class. |
1310 | 1310 |
#ifdef DOXYGEN |
1311 |
template <typename |
|
1311 |
template <typename GR, typename VS, typename TR> |
|
1312 | 1312 |
#else |
1313 |
template <typename _Digraph = ListDigraph, |
|
1314 |
typename _Visitor = BfsVisitor<_Digraph>, |
|
1315 |
|
|
1313 |
template <typename GR = ListDigraph, |
|
1314 |
typename VS = BfsVisitor<GR>, |
|
1315 |
typename TR = BfsVisitDefaultTraits<GR> > |
|
1316 | 1316 |
#endif |
1317 | 1317 |
class BfsVisit { |
1318 | 1318 |
public: |
1319 | 1319 |
|
1320 | 1320 |
///The traits class. |
1321 |
typedef |
|
1321 |
typedef TR Traits; |
|
1322 | 1322 |
|
1323 | 1323 |
///The type of the digraph the algorithm runs on. |
1324 | 1324 |
typedef typename Traits::Digraph Digraph; |
1325 | 1325 |
|
1326 | 1326 |
///The visitor type used by the algorithm. |
1327 |
typedef |
|
1327 |
typedef VS Visitor; |
|
1328 | 1328 |
|
1329 | 1329 |
///The type of the map that indicates which nodes are reached. |
1330 | 1330 |
typedef typename Traits::ReachedMap ReachedMap; |
1331 | 1331 |
|
1332 | 1332 |
private: |
1333 | 1333 |
... | ... |
@@ -132,13 +132,13 @@ |
132 | 132 |
return operator=<ArrayMap>(cmap); |
133 | 133 |
} |
134 | 134 |
|
135 | 135 |
|
136 | 136 |
// \brief Template assign operator. |
137 | 137 |
// |
138 |
// The given parameter should |
|
138 |
// The given parameter should conform to the ReadMap |
|
139 | 139 |
// concecpt and could be indiced by the current item set of |
140 | 140 |
// the NodeMap. In this case the value for each item |
141 | 141 |
// is assigned by the value of the given ReadMap. |
142 | 142 |
template <typename CMap> |
143 | 143 |
ArrayMap& operator=(const CMap& cmap) { |
144 | 144 |
checkConcept<concepts::ReadMap<Key, _Value>, CMap>(); |
... | ... |
@@ -121,13 +121,13 @@ |
121 | 121 |
return operator=<VectorMap>(cmap); |
122 | 122 |
} |
123 | 123 |
|
124 | 124 |
|
125 | 125 |
// \brief Template assign operator. |
126 | 126 |
// |
127 |
// The given parameter should |
|
127 |
// The given parameter should conform to the ReadMap |
|
128 | 128 |
// concecpt and could be indiced by the current item set of |
129 | 129 |
// the NodeMap. In this case the value for each item |
130 | 130 |
// is assigned by the value of the given ReadMap. |
131 | 131 |
template <typename CMap> |
132 | 132 |
VectorMap& operator=(const CMap& cmap) { |
133 | 133 |
checkConcept<concepts::ReadMap<Key, _Value>, CMap>(); |
... | ... |
@@ -28,44 +28,44 @@ |
28 | 28 |
/// |
29 | 29 |
namespace lemon { |
30 | 30 |
|
31 | 31 |
/// \brief Default traits class of Circulation class. |
32 | 32 |
/// |
33 | 33 |
/// Default traits class of Circulation class. |
34 |
/// \tparam _Diraph Digraph type. |
|
35 |
/// \tparam _LCapMap Lower bound capacity map type. |
|
36 |
/// \tparam _UCapMap Upper bound capacity map type. |
|
37 |
/// \tparam _DeltaMap Delta map type. |
|
38 |
template <typename _Diraph, typename _LCapMap, |
|
39 |
typename _UCapMap, typename _DeltaMap> |
|
34 |
/// \tparam GR Digraph type. |
|
35 |
/// \tparam LM Lower bound capacity map type. |
|
36 |
/// \tparam UM Upper bound capacity map type. |
|
37 |
/// \tparam DM Delta map type. |
|
38 |
template <typename GR, typename LM, |
|
39 |
typename UM, typename DM> |
|
40 | 40 |
struct CirculationDefaultTraits { |
41 | 41 |
|
42 | 42 |
/// \brief The type of the digraph the algorithm runs on. |
43 |
typedef |
|
43 |
typedef GR Digraph; |
|
44 | 44 |
|
45 | 45 |
/// \brief The type of the map that stores the circulation lower |
46 | 46 |
/// bound. |
47 | 47 |
/// |
48 | 48 |
/// The type of the map that stores the circulation lower bound. |
49 | 49 |
/// It must meet the \ref concepts::ReadMap "ReadMap" concept. |
50 |
typedef |
|
50 |
typedef LM LCapMap; |
|
51 | 51 |
|
52 | 52 |
/// \brief The type of the map that stores the circulation upper |
53 | 53 |
/// bound. |
54 | 54 |
/// |
55 | 55 |
/// The type of the map that stores the circulation upper bound. |
56 | 56 |
/// It must meet the \ref concepts::ReadMap "ReadMap" concept. |
57 |
typedef |
|
57 |
typedef UM UCapMap; |
|
58 | 58 |
|
59 | 59 |
/// \brief The type of the map that stores the lower bound for |
60 | 60 |
/// the supply of the nodes. |
61 | 61 |
/// |
62 | 62 |
/// The type of the map that stores the lower bound for the supply |
63 | 63 |
/// of the nodes. It must meet the \ref concepts::ReadMap "ReadMap" |
64 | 64 |
/// concept. |
65 |
typedef |
|
65 |
typedef DM DeltaMap; |
|
66 | 66 |
|
67 | 67 |
/// \brief The type of the flow values. |
68 | 68 |
typedef typename DeltaMap::Value Value; |
69 | 69 |
|
70 | 70 |
/// \brief The type of the map that stores the flow values. |
71 | 71 |
/// |
... | ... |
@@ -134,41 +134,39 @@ |
134 | 134 |
\f$\sum_{v\in V}delta(v) = 0\f$. Then the supply of each node \f$v\f$ |
135 | 135 |
will be \e equal \e to \f$delta(v)\f$, if a circulation can be found. |
136 | 136 |
Thus a feasible solution for the |
137 | 137 |
\ref min_cost_flow "minimum cost flow" problem can be calculated |
138 | 138 |
in this way. |
139 | 139 |
|
140 |
\tparam _Digraph The type of the digraph the algorithm runs on. |
|
141 |
\tparam _LCapMap The type of the lower bound capacity map. The default |
|
142 |
map type is \ref concepts::Digraph::ArcMap "_Digraph::ArcMap<int>". |
|
143 |
\tparam _UCapMap The type of the upper bound capacity map. The default |
|
144 |
map type is \c _LCapMap. |
|
145 |
\tparam _DeltaMap The type of the map that stores the lower bound |
|
140 |
\tparam GR The type of the digraph the algorithm runs on. |
|
141 |
\tparam LM The type of the lower bound capacity map. The default |
|
142 |
map type is \ref concepts::Digraph::ArcMap "GR::ArcMap<int>". |
|
143 |
\tparam UM The type of the upper bound capacity map. The default |
|
144 |
map type is \c LM. |
|
145 |
\tparam DM The type of the map that stores the lower bound |
|
146 | 146 |
for the supply of the nodes. The default map type is |
147 |
\ |
|
147 |
\ref concepts::Digraph::NodeMap "GR::NodeMap<UM::Value>". |
|
148 | 148 |
*/ |
149 | 149 |
#ifdef DOXYGEN |
150 |
template< typename _Digraph, |
|
151 |
typename _LCapMap, |
|
152 |
typename _UCapMap, |
|
153 |
typename _DeltaMap, |
|
154 |
|
|
150 |
template< typename GR, |
|
151 |
typename LM, |
|
152 |
typename UM, |
|
153 |
typename DM, |
|
154 |
typename TR > |
|
155 | 155 |
#else |
156 |
template< typename _Digraph, |
|
157 |
typename _LCapMap = typename _Digraph::template ArcMap<int>, |
|
158 |
typename _UCapMap = _LCapMap, |
|
159 |
typename _DeltaMap = typename _Digraph:: |
|
160 |
template NodeMap<typename _UCapMap::Value>, |
|
161 |
typename _Traits=CirculationDefaultTraits<_Digraph, _LCapMap, |
|
162 |
|
|
156 |
template< typename GR, |
|
157 |
typename LM = typename GR::template ArcMap<int>, |
|
158 |
typename UM = LM, |
|
159 |
typename DM = typename GR::template NodeMap<typename UM::Value>, |
|
160 |
typename TR = CirculationDefaultTraits<GR, LM, UM, DM> > |
|
163 | 161 |
#endif |
164 | 162 |
class Circulation { |
165 | 163 |
public: |
166 | 164 |
|
167 | 165 |
///The \ref CirculationDefaultTraits "traits class" of the algorithm. |
168 |
typedef |
|
166 |
typedef TR Traits; |
|
169 | 167 |
///The type of the digraph the algorithm runs on. |
170 | 168 |
typedef typename Traits::Digraph Digraph; |
171 | 169 |
///The type of the flow values. |
172 | 170 |
typedef typename Traits::Value Value; |
173 | 171 |
|
174 | 172 |
/// The type of the lower bound capacity map. |
... | ... |
@@ -111,13 +111,13 @@ |
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 |
/// directed graph structure. All digraph concepts have to |
|
117 |
/// directed graph structure. All digraph concepts have to |
|
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 |
|
... | ... |
@@ -176,13 +176,13 @@ |
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 |
/// to |
|
182 |
/// to 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: |
... | ... |
@@ -291,13 +291,13 @@ |
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 |
/// The most of the base digraphs should |
|
297 |
/// The most of the base digraphs should 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; |
... | ... |
@@ -369,13 +369,13 @@ |
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 |
/// most of the base undirected graphs should |
|
375 |
/// most of the base undirected graphs should 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; |
... | ... |
@@ -46,32 +46,32 @@ |
46 | 46 |
///arcs of the %DFS paths. |
47 | 47 |
/// |
48 | 48 |
///The type of the map that stores the predecessor |
49 | 49 |
///arcs of the %DFS paths. |
50 | 50 |
///It must meet the \ref concepts::WriteMap "WriteMap" concept. |
51 | 51 |
typedef typename Digraph::template NodeMap<typename Digraph::Arc> PredMap; |
52 |
///Instantiates a PredMap. |
|
52 |
///Instantiates a \c PredMap. |
|
53 | 53 |
|
54 |
///This function instantiates a PredMap. |
|
54 |
///This function instantiates a \ref PredMap. |
|
55 | 55 |
///\param g is the digraph, to which we would like to define the |
56 |
///PredMap. |
|
56 |
///\ref PredMap. |
|
57 | 57 |
static PredMap *createPredMap(const Digraph &g) |
58 | 58 |
{ |
59 | 59 |
return new PredMap(g); |
60 | 60 |
} |
61 | 61 |
|
62 | 62 |
///The type of the map that indicates which nodes are processed. |
63 | 63 |
|
64 | 64 |
///The type of the map that indicates which nodes are processed. |
65 | 65 |
///It must meet the \ref concepts::WriteMap "WriteMap" concept. |
66 | 66 |
typedef NullMap<typename Digraph::Node,bool> ProcessedMap; |
67 |
///Instantiates a ProcessedMap. |
|
67 |
///Instantiates a \c ProcessedMap. |
|
68 | 68 |
|
69 |
///This function instantiates a ProcessedMap. |
|
69 |
///This function instantiates a \ref ProcessedMap. |
|
70 | 70 |
///\param g is the digraph, to which |
71 |
///we would like to define the ProcessedMap |
|
71 |
///we would like to define the \ref ProcessedMap. |
|
72 | 72 |
#ifdef DOXYGEN |
73 | 73 |
static ProcessedMap *createProcessedMap(const Digraph &g) |
74 | 74 |
#else |
75 | 75 |
static ProcessedMap *createProcessedMap(const Digraph &) |
76 | 76 |
#endif |
77 | 77 |
{ |
... | ... |
@@ -80,32 +80,32 @@ |
80 | 80 |
|
81 | 81 |
///The type of the map that indicates which nodes are reached. |
82 | 82 |
|
83 | 83 |
///The type of the map that indicates which nodes are reached. |
84 | 84 |
///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept. |
85 | 85 |
typedef typename Digraph::template NodeMap<bool> ReachedMap; |
86 |
///Instantiates a ReachedMap. |
|
86 |
///Instantiates a \c ReachedMap. |
|
87 | 87 |
|
88 |
///This function instantiates a ReachedMap. |
|
88 |
///This function instantiates a \ref ReachedMap. |
|
89 | 89 |
///\param g is the digraph, to which |
90 |
///we would like to define the ReachedMap. |
|
90 |
///we would like to define the \ref ReachedMap. |
|
91 | 91 |
static ReachedMap *createReachedMap(const Digraph &g) |
92 | 92 |
{ |
93 | 93 |
return new ReachedMap(g); |
94 | 94 |
} |
95 | 95 |
|
96 | 96 |
///The type of the map that stores the distances of the nodes. |
97 | 97 |
|
98 | 98 |
///The type of the map that stores the distances of the nodes. |
99 | 99 |
///It must meet the \ref concepts::WriteMap "WriteMap" concept. |
100 | 100 |
typedef typename Digraph::template NodeMap<int> DistMap; |
101 |
///Instantiates a DistMap. |
|
101 |
///Instantiates a \c DistMap. |
|
102 | 102 |
|
103 |
///This function instantiates a DistMap. |
|
103 |
///This function instantiates a \ref DistMap. |
|
104 | 104 |
///\param g is the digraph, to which we would like to define the |
105 |
///DistMap. |
|
105 |
///\ref DistMap. |
|
106 | 106 |
static DistMap *createDistMap(const Digraph &g) |
107 | 107 |
{ |
108 | 108 |
return new DistMap(g); |
109 | 109 |
} |
110 | 110 |
}; |
111 | 111 |
|
... | ... |
@@ -217,16 +217,16 @@ |
217 | 217 |
{ |
218 | 218 |
LEMON_ASSERT(false, "PredMap is not initialized"); |
219 | 219 |
return 0; // ignore warnings |
220 | 220 |
} |
221 | 221 |
}; |
222 | 222 |
///\brief \ref named-templ-param "Named parameter" for setting |
223 |
///PredMap type. |
|
223 |
///\c PredMap type. |
|
224 | 224 |
/// |
225 | 225 |
///\ref named-templ-param "Named parameter" for setting |
226 |
///PredMap type. |
|
226 |
///\c PredMap type. |
|
227 | 227 |
///It must meet the \ref concepts::WriteMap "WriteMap" concept. |
228 | 228 |
template <class T> |
229 | 229 |
struct SetPredMap : public Dfs<Digraph, SetPredMapTraits<T> > { |
230 | 230 |
typedef Dfs<Digraph, SetPredMapTraits<T> > Create; |
231 | 231 |
}; |
232 | 232 |
|
... | ... |
@@ -237,16 +237,16 @@ |
237 | 237 |
{ |
238 | 238 |
LEMON_ASSERT(false, "DistMap is not initialized"); |
239 | 239 |
return 0; // ignore warnings |
240 | 240 |
} |
241 | 241 |
}; |
242 | 242 |
///\brief \ref named-templ-param "Named parameter" for setting |
243 |
///DistMap type. |
|
243 |
///\c DistMap type. |
|
244 | 244 |
/// |
245 | 245 |
///\ref named-templ-param "Named parameter" for setting |
246 |
///DistMap type. |
|
246 |
///\c DistMap type. |
|
247 | 247 |
///It must meet the \ref concepts::WriteMap "WriteMap" concept. |
248 | 248 |
template <class T> |
249 | 249 |
struct SetDistMap : public Dfs< Digraph, SetDistMapTraits<T> > { |
250 | 250 |
typedef Dfs<Digraph, SetDistMapTraits<T> > Create; |
251 | 251 |
}; |
252 | 252 |
|
... | ... |
@@ -257,16 +257,16 @@ |
257 | 257 |
{ |
258 | 258 |
LEMON_ASSERT(false, "ReachedMap is not initialized"); |
259 | 259 |
return 0; // ignore warnings |
260 | 260 |
} |
261 | 261 |
}; |
262 | 262 |
///\brief \ref named-templ-param "Named parameter" for setting |
263 |
///ReachedMap type. |
|
263 |
///\c ReachedMap type. |
|
264 | 264 |
/// |
265 | 265 |
///\ref named-templ-param "Named parameter" for setting |
266 |
///ReachedMap type. |
|
266 |
///\c ReachedMap type. |
|
267 | 267 |
///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept. |
268 | 268 |
template <class T> |
269 | 269 |
struct SetReachedMap : public Dfs< Digraph, SetReachedMapTraits<T> > { |
270 | 270 |
typedef Dfs< Digraph, SetReachedMapTraits<T> > Create; |
271 | 271 |
}; |
272 | 272 |
|
... | ... |
@@ -277,16 +277,16 @@ |
277 | 277 |
{ |
278 | 278 |
LEMON_ASSERT(false, "ProcessedMap is not initialized"); |
279 | 279 |
return 0; // ignore warnings |
280 | 280 |
} |
281 | 281 |
}; |
282 | 282 |
///\brief \ref named-templ-param "Named parameter" for setting |
283 |
///ProcessedMap type. |
|
283 |
///\c ProcessedMap type. |
|
284 | 284 |
/// |
285 | 285 |
///\ref named-templ-param "Named parameter" for setting |
286 |
///ProcessedMap type. |
|
286 |
///\c ProcessedMap type. |
|
287 | 287 |
///It must meet the \ref concepts::WriteMap "WriteMap" concept. |
288 | 288 |
template <class T> |
289 | 289 |
struct SetProcessedMap : public Dfs< Digraph, SetProcessedMapTraits<T> > { |
290 | 290 |
typedef Dfs< Digraph, SetProcessedMapTraits<T> > Create; |
291 | 291 |
}; |
292 | 292 |
|
... | ... |
@@ -295,16 +295,16 @@ |
295 | 295 |
static ProcessedMap *createProcessedMap(const Digraph &g) |
296 | 296 |
{ |
297 | 297 |
return new ProcessedMap(g); |
298 | 298 |
} |
299 | 299 |
}; |
300 | 300 |
///\brief \ref named-templ-param "Named parameter" for setting |
301 |
///ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>. |
|
301 |
///\c ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>. |
|
302 | 302 |
/// |
303 | 303 |
///\ref named-templ-param "Named parameter" for setting |
304 |
///ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>. |
|
304 |
///\c ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>. |
|
305 | 305 |
///If you don't set it explicitly, it will be automatically allocated. |
306 | 306 |
struct SetStandardProcessedMap : |
307 | 307 |
public Dfs< Digraph, SetStandardProcessedMapTraits > { |
308 | 308 |
typedef Dfs< Digraph, SetStandardProcessedMapTraits > Create; |
309 | 309 |
}; |
310 | 310 |
|
... | ... |
@@ -1123,15 +1123,15 @@ |
1123 | 1123 |
|
1124 | 1124 |
#ifdef DOXYGEN |
1125 | 1125 |
/// \brief Visitor class for DFS. |
1126 | 1126 |
/// |
1127 | 1127 |
/// This class defines the interface of the DfsVisit events, and |
1128 | 1128 |
/// it could be the base of a real visitor class. |
1129 |
template <typename |
|
1129 |
template <typename GR> |
|
1130 | 1130 |
struct DfsVisitor { |
1131 |
typedef |
|
1131 |
typedef GR Digraph; |
|
1132 | 1132 |
typedef typename Digraph::Arc Arc; |
1133 | 1133 |
typedef typename Digraph::Node Node; |
1134 | 1134 |
/// \brief Called for the source node of the DFS. |
1135 | 1135 |
/// |
1136 | 1136 |
/// This function is called for the source node of the DFS. |
1137 | 1137 |
void start(const Node& node) {} |
... | ... |
@@ -1161,15 +1161,15 @@ |
1161 | 1161 |
/// \brief Called when the DFS steps back on an arc. |
1162 | 1162 |
/// |
1163 | 1163 |
/// This function is called when the DFS steps back on an arc. |
1164 | 1164 |
void backtrack(const Arc& arc) {} |
1165 | 1165 |
}; |
1166 | 1166 |
#else |
1167 |
template <typename |
|
1167 |
template <typename GR> |
|
1168 | 1168 |
struct DfsVisitor { |
1169 |
typedef |
|
1169 |
typedef GR Digraph; |
|
1170 | 1170 |
typedef typename Digraph::Arc Arc; |
1171 | 1171 |
typedef typename Digraph::Node Node; |
1172 | 1172 |
void start(const Node&) {} |
1173 | 1173 |
void stop(const Node&) {} |
1174 | 1174 |
void reach(const Node&) {} |
1175 | 1175 |
void discover(const Arc&) {} |
... | ... |
@@ -1196,17 +1196,17 @@ |
1196 | 1196 |
#endif |
1197 | 1197 |
|
1198 | 1198 |
/// \brief Default traits class of DfsVisit class. |
1199 | 1199 |
/// |
1200 | 1200 |
/// Default traits class of DfsVisit class. |
1201 | 1201 |
/// \tparam _Digraph The type of the digraph the algorithm runs on. |
1202 |
template<class |
|
1202 |
template<class GR> |
|
1203 | 1203 |
struct DfsVisitDefaultTraits { |
1204 | 1204 |
|
1205 | 1205 |
/// \brief The type of the digraph the algorithm runs on. |
1206 |
typedef |
|
1206 |
typedef GR Digraph; |
|
1207 | 1207 |
|
1208 | 1208 |
/// \brief The type of the map that indicates which nodes are reached. |
1209 | 1209 |
/// |
1210 | 1210 |
/// The type of the map that indicates which nodes are reached. |
1211 | 1211 |
/// It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept. |
1212 | 1212 |
typedef typename Digraph::template NodeMap<bool> ReachedMap; |
... | ... |
@@ -1221,57 +1221,57 @@ |
1221 | 1221 |
} |
1222 | 1222 |
|
1223 | 1223 |
}; |
1224 | 1224 |
|
1225 | 1225 |
/// \ingroup search |
1226 | 1226 |
/// |
1227 |
/// \brief |
|
1227 |
/// \brief DFS algorithm class with visitor interface. |
|
1228 | 1228 |
/// |
1229 |
/// This class provides an efficient implementation of the |
|
1229 |
/// This class provides an efficient implementation of the DFS algorithm |
|
1230 | 1230 |
/// with visitor interface. |
1231 | 1231 |
/// |
1232 |
/// The |
|
1232 |
/// The DfsVisit class provides an alternative interface to the Dfs |
|
1233 | 1233 |
/// class. It works with callback mechanism, the DfsVisit object calls |
1234 | 1234 |
/// the member functions of the \c Visitor class on every DFS event. |
1235 | 1235 |
/// |
1236 | 1236 |
/// This interface of the DFS algorithm should be used in special cases |
1237 | 1237 |
/// when extra actions have to be performed in connection with certain |
1238 | 1238 |
/// events of the DFS algorithm. Otherwise consider to use Dfs or dfs() |
1239 | 1239 |
/// instead. |
1240 | 1240 |
/// |
1241 |
/// \tparam _Digraph The type of the digraph the algorithm runs on. |
|
1242 |
/// The default value is |
|
1243 |
/// \ref ListDigraph. The value of _Digraph is not used directly by |
|
1244 |
/// \ref DfsVisit, it is only passed to \ref DfsVisitDefaultTraits. |
|
1245 |
/// \tparam _Visitor The Visitor type that is used by the algorithm. |
|
1246 |
/// \ref DfsVisitor "DfsVisitor<_Digraph>" is an empty visitor, which |
|
1241 |
/// \tparam GR The type of the digraph the algorithm runs on. |
|
1242 |
/// The default type is \ref ListDigraph. |
|
1243 |
/// The value of GR is not used directly by \ref DfsVisit, |
|
1244 |
/// it is only passed to \ref DfsVisitDefaultTraits. |
|
1245 |
/// \tparam VS The Visitor type that is used by the algorithm. |
|
1246 |
/// \ref DfsVisitor "DfsVisitor<GR>" is an empty visitor, which |
|
1247 | 1247 |
/// does not observe the DFS events. If you want to observe the DFS |
1248 | 1248 |
/// events, you should implement your own visitor class. |
1249 |
/// \tparam |
|
1249 |
/// \tparam TR Traits class to set various data types used by the |
|
1250 | 1250 |
/// algorithm. The default traits class is |
1251 |
/// \ref DfsVisitDefaultTraits "DfsVisitDefaultTraits< |
|
1251 |
/// \ref DfsVisitDefaultTraits "DfsVisitDefaultTraits<GR>". |
|
1252 | 1252 |
/// See \ref DfsVisitDefaultTraits for the documentation of |
1253 | 1253 |
/// a DFS visit traits class. |
1254 | 1254 |
#ifdef DOXYGEN |
1255 |
template <typename |
|
1255 |
template <typename GR, typename VS, typename TR> |
|
1256 | 1256 |
#else |
1257 |
template <typename _Digraph = ListDigraph, |
|
1258 |
typename _Visitor = DfsVisitor<_Digraph>, |
|
1259 |
|
|
1257 |
template <typename GR = ListDigraph, |
|
1258 |
typename VS = DfsVisitor<GR>, |
|
1259 |
typename TR = DfsVisitDefaultTraits<GR> > |
|
1260 | 1260 |
#endif |
1261 | 1261 |
class DfsVisit { |
1262 | 1262 |
public: |
1263 | 1263 |
|
1264 | 1264 |
///The traits class. |
1265 |
typedef |
|
1265 |
typedef TR Traits; |
|
1266 | 1266 |
|
1267 | 1267 |
///The type of the digraph the algorithm runs on. |
1268 | 1268 |
typedef typename Traits::Digraph Digraph; |
1269 | 1269 |
|
1270 | 1270 |
///The visitor type used by the algorithm. |
1271 |
typedef |
|
1271 |
typedef VS Visitor; |
|
1272 | 1272 |
|
1273 | 1273 |
///The type of the map that indicates which nodes are reached. |
1274 | 1274 |
typedef typename Traits::ReachedMap ReachedMap; |
1275 | 1275 |
|
1276 | 1276 |
private: |
1277 | 1277 |
... | ... |
@@ -70,41 +70,41 @@ |
70 | 70 |
///The type of the map that stores the arc lengths. |
71 | 71 |
///It must meet the \ref concepts::ReadMap "ReadMap" concept. |
72 | 72 |
typedef LM LengthMap; |
73 | 73 |
///The type of the length of the arcs. |
74 | 74 |
typedef typename LM::Value Value; |
75 | 75 |
|
76 |
/// Operation traits for Dijkstra algorithm. |
|
76 |
/// Operation traits for %Dijkstra algorithm. |
|
77 | 77 |
|
78 | 78 |
/// This class defines the operations that are used in the algorithm. |
79 | 79 |
/// \see DijkstraDefaultOperationTraits |
80 | 80 |
typedef DijkstraDefaultOperationTraits<Value> OperationTraits; |
81 | 81 |
|
82 | 82 |
/// The cross reference type used by the heap. |
83 | 83 |
|
84 | 84 |
/// The cross reference type used by the heap. |
85 | 85 |
/// Usually it is \c Digraph::NodeMap<int>. |
86 | 86 |
typedef typename Digraph::template NodeMap<int> HeapCrossRef; |
87 |
///Instantiates a \ |
|
87 |
///Instantiates a \c HeapCrossRef. |
|
88 | 88 |
|
89 | 89 |
///This function instantiates a \ref HeapCrossRef. |
90 | 90 |
/// \param g is the digraph, to which we would like to define the |
91 | 91 |
/// \ref HeapCrossRef. |
92 | 92 |
static HeapCrossRef *createHeapCrossRef(const Digraph &g) |
93 | 93 |
{ |
94 | 94 |
return new HeapCrossRef(g); |
95 | 95 |
} |
96 | 96 |
|
97 |
///The heap type used by the Dijkstra algorithm. |
|
97 |
///The heap type used by the %Dijkstra algorithm. |
|
98 | 98 |
|
99 | 99 |
///The heap type used by the Dijkstra algorithm. |
100 | 100 |
/// |
101 | 101 |
///\sa BinHeap |
102 | 102 |
///\sa Dijkstra |
103 | 103 |
typedef BinHeap<typename LM::Value, HeapCrossRef, std::less<Value> > Heap; |
104 |
///Instantiates a \ |
|
104 |
///Instantiates a \c Heap. |
|
105 | 105 |
|
106 | 106 |
///This function instantiates a \ref Heap. |
107 | 107 |
static Heap *createHeap(HeapCrossRef& r) |
108 | 108 |
{ |
109 | 109 |
return new Heap(r); |
110 | 110 |
} |
... | ... |
@@ -113,33 +113,33 @@ |
113 | 113 |
///arcs of the shortest paths. |
114 | 114 |
/// |
115 | 115 |
///The type of the map that stores the predecessor |
116 | 116 |
///arcs of the shortest paths. |
117 | 117 |
///It must meet the \ref concepts::WriteMap "WriteMap" concept. |
118 | 118 |
typedef typename Digraph::template NodeMap<typename Digraph::Arc> PredMap; |
119 |
///Instantiates a PredMap. |
|
119 |
///Instantiates a \c PredMap. |
|
120 | 120 |
|
121 |
///This function instantiates a PredMap. |
|
121 |
///This function instantiates a \ref PredMap. |
|
122 | 122 |
///\param g is the digraph, to which we would like to define the |
123 |
///PredMap. |
|
123 |
///\ref PredMap. |
|
124 | 124 |
static PredMap *createPredMap(const Digraph &g) |
125 | 125 |
{ |
126 | 126 |
return new PredMap(g); |
127 | 127 |
} |
128 | 128 |
|
129 | 129 |
///The type of the map that indicates which nodes are processed. |
130 | 130 |
|
131 | 131 |
///The type of the map that indicates which nodes are processed. |
132 | 132 |
///It must meet the \ref concepts::WriteMap "WriteMap" concept. |
133 | 133 |
///By default it is a NullMap. |
134 | 134 |
typedef NullMap<typename Digraph::Node,bool> ProcessedMap; |
135 |
///Instantiates a ProcessedMap. |
|
135 |
///Instantiates a \c ProcessedMap. |
|
136 | 136 |
|
137 |
///This function instantiates a ProcessedMap. |
|
137 |
///This function instantiates a \ref ProcessedMap. |
|
138 | 138 |
///\param g is the digraph, to which |
139 |
///we would like to define the ProcessedMap |
|
139 |
///we would like to define the \ref ProcessedMap. |
|
140 | 140 |
#ifdef DOXYGEN |
141 | 141 |
static ProcessedMap *createProcessedMap(const Digraph &g) |
142 | 142 |
#else |
143 | 143 |
static ProcessedMap *createProcessedMap(const Digraph &) |
144 | 144 |
#endif |
145 | 145 |
{ |
... | ... |
@@ -148,17 +148,17 @@ |
148 | 148 |
|
149 | 149 |
///The type of the map that stores the distances of the nodes. |
150 | 150 |
|
151 | 151 |
///The type of the map that stores the distances of the nodes. |
152 | 152 |
///It must meet the \ref concepts::WriteMap "WriteMap" concept. |
153 | 153 |
typedef typename Digraph::template NodeMap<typename LM::Value> DistMap; |
154 |
///Instantiates a DistMap. |
|
154 |
///Instantiates a \c DistMap. |
|
155 | 155 |
|
156 |
///This function instantiates a DistMap. |
|
156 |
///This function instantiates a \ref DistMap. |
|
157 | 157 |
///\param g is the digraph, to which we would like to define |
158 |
///the DistMap |
|
158 |
///the \ref DistMap. |
|
159 | 159 |
static DistMap *createDistMap(const Digraph &g) |
160 | 160 |
{ |
161 | 161 |
return new DistMap(g); |
162 | 162 |
} |
163 | 163 |
}; |
164 | 164 |
|
... | ... |
@@ -213,13 +213,14 @@ |
213 | 213 |
///The type of the paths. |
214 | 214 |
typedef PredMapPath<Digraph, PredMap> Path; |
215 | 215 |
///The cross reference type used for the current heap. |
216 | 216 |
typedef typename TR::HeapCrossRef HeapCrossRef; |
217 | 217 |
///The heap type used by the algorithm. |
218 | 218 |
typedef typename TR::Heap Heap; |
219 |
///The operation traits class |
|
219 |
///\brief The \ref DijkstraDefaultOperationTraits "operation traits class" |
|
220 |
///of the algorithm. |
|
220 | 221 |
typedef typename TR::OperationTraits OperationTraits; |
221 | 222 |
|
222 | 223 |
///The \ref DijkstraDefaultTraits "traits class" of the algorithm. |
223 | 224 |
typedef TR Traits; |
224 | 225 |
|
225 | 226 |
private: |
... | ... |
@@ -229,13 +230,13 @@ |
229 | 230 |
typedef typename Digraph::Arc Arc; |
230 | 231 |
typedef typename Digraph::OutArcIt OutArcIt; |
231 | 232 |
|
232 | 233 |
//Pointer to the underlying digraph. |
233 | 234 |
const Digraph *G; |
234 | 235 |
//Pointer to the length map. |
235 |
const LengthMap * |
|
236 |
const LengthMap *_length; |
|
236 | 237 |
//Pointer to the map of predecessors arcs. |
237 | 238 |
PredMap *_pred; |
238 | 239 |
//Indicates if _pred is locally allocated (true) or not. |
239 | 240 |
bool local_pred; |
240 | 241 |
//Pointer to the map of distances. |
241 | 242 |
DistMap *_dist; |
... | ... |
@@ -294,16 +295,16 @@ |
294 | 295 |
{ |
295 | 296 |
LEMON_ASSERT(false, "PredMap is not initialized"); |
296 | 297 |
return 0; // ignore warnings |
297 | 298 |
} |
298 | 299 |
}; |
299 | 300 |
///\brief \ref named-templ-param "Named parameter" for setting |
300 |
///PredMap type. |
|
301 |
///\c PredMap type. |
|
301 | 302 |
/// |
302 | 303 |
///\ref named-templ-param "Named parameter" for setting |
303 |
///PredMap type. |
|
304 |
///\c PredMap type. |
|
304 | 305 |
///It must meet the \ref concepts::WriteMap "WriteMap" concept. |
305 | 306 |
template <class T> |
306 | 307 |
struct SetPredMap |
307 | 308 |
: public Dijkstra< Digraph, LengthMap, SetPredMapTraits<T> > { |
308 | 309 |
typedef Dijkstra< Digraph, LengthMap, SetPredMapTraits<T> > Create; |
309 | 310 |
}; |
... | ... |
@@ -315,16 +316,16 @@ |
315 | 316 |
{ |
316 | 317 |
LEMON_ASSERT(false, "DistMap is not initialized"); |
317 | 318 |
return 0; // ignore warnings |
318 | 319 |
} |
319 | 320 |
}; |
320 | 321 |
///\brief \ref named-templ-param "Named parameter" for setting |
321 |
///DistMap type. |
|
322 |
///\c DistMap type. |
|
322 | 323 |
/// |
323 | 324 |
///\ref named-templ-param "Named parameter" for setting |
324 |
///DistMap type. |
|
325 |
///\c DistMap type. |
|
325 | 326 |
///It must meet the \ref concepts::WriteMap "WriteMap" concept. |
326 | 327 |
template <class T> |
327 | 328 |
struct SetDistMap |
328 | 329 |
: public Dijkstra< Digraph, LengthMap, SetDistMapTraits<T> > { |
329 | 330 |
typedef Dijkstra< Digraph, LengthMap, SetDistMapTraits<T> > Create; |
330 | 331 |
}; |
... | ... |
@@ -336,16 +337,16 @@ |
336 | 337 |
{ |
337 | 338 |
LEMON_ASSERT(false, "ProcessedMap is not initialized"); |
338 | 339 |
return 0; // ignore warnings |
339 | 340 |
} |
340 | 341 |
}; |
341 | 342 |
///\brief \ref named-templ-param "Named parameter" for setting |
342 |
///ProcessedMap type. |
|
343 |
///\c ProcessedMap type. |
|
343 | 344 |
/// |
344 | 345 |
///\ref named-templ-param "Named parameter" for setting |
345 |
///ProcessedMap type. |
|
346 |
///\c ProcessedMap type. |
|
346 | 347 |
///It must meet the \ref concepts::WriteMap "WriteMap" concept. |
347 | 348 |
template <class T> |
348 | 349 |
struct SetProcessedMap |
349 | 350 |
: public Dijkstra< Digraph, LengthMap, SetProcessedMapTraits<T> > { |
350 | 351 |
typedef Dijkstra< Digraph, LengthMap, SetProcessedMapTraits<T> > Create; |
351 | 352 |
}; |
... | ... |
@@ -355,16 +356,16 @@ |
355 | 356 |
static ProcessedMap *createProcessedMap(const Digraph &g) |
356 | 357 |
{ |
357 | 358 |
return new ProcessedMap(g); |
358 | 359 |
} |
359 | 360 |
}; |
360 | 361 |
///\brief \ref named-templ-param "Named parameter" for setting |
361 |
///ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>. |
|
362 |
///\c ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>. |
|
362 | 363 |
/// |
363 | 364 |
///\ref named-templ-param "Named parameter" for setting |
364 |
///ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>. |
|
365 |
///\c ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>. |
|
365 | 366 |
///If you don't set it explicitly, it will be automatically allocated. |
366 | 367 |
struct SetStandardProcessedMap |
367 | 368 |
: public Dijkstra< Digraph, LengthMap, SetStandardProcessedMapTraits > { |
368 | 369 |
typedef Dijkstra< Digraph, LengthMap, SetStandardProcessedMapTraits > |
369 | 370 |
Create; |
370 | 371 |
}; |
... | ... |
@@ -436,13 +437,13 @@ |
436 | 437 |
}; |
437 | 438 |
|
438 | 439 |
/// \brief \ref named-templ-param "Named parameter" for setting |
439 | 440 |
///\c OperationTraits type |
440 | 441 |
/// |
441 | 442 |
///\ref named-templ-param "Named parameter" for setting |
442 |
///\ |
|
443 |
///\c OperationTraits type. |
|
443 | 444 |
template <class T> |
444 | 445 |
struct SetOperationTraits |
445 | 446 |
: public Dijkstra<Digraph, LengthMap, SetOperationTraitsTraits<T> > { |
446 | 447 |
typedef Dijkstra<Digraph, LengthMap, SetOperationTraitsTraits<T> > |
447 | 448 |
Create; |
448 | 449 |
}; |
... | ... |
@@ -455,16 +456,16 @@ |
455 | 456 |
|
456 | 457 |
public: |
457 | 458 |
|
458 | 459 |
///Constructor. |
459 | 460 |
|
460 | 461 |
///Constructor. |
461 |
///\param _g The digraph the algorithm runs on. |
|
462 |
///\param _length The length map used by the algorithm. |
|
463 |
Dijkstra(const Digraph& _g, const LengthMap& _length) : |
|
464 |
G(&_g), length(&_length), |
|
462 |
///\param g The digraph the algorithm runs on. |
|
463 |
///\param length The length map used by the algorithm. |
|
464 |
Dijkstra(const Digraph& g, const LengthMap& length) : |
|
465 |
G(&g), _length(&length), |
|
465 | 466 |
_pred(NULL), local_pred(false), |
466 | 467 |
_dist(NULL), local_dist(false), |
467 | 468 |
_processed(NULL), local_processed(false), |
468 | 469 |
_heap_cross_ref(NULL), local_heap_cross_ref(false), |
469 | 470 |
_heap(NULL), local_heap(false) |
470 | 471 |
{ } |
... | ... |
@@ -482,13 +483,13 @@ |
482 | 483 |
///Sets the length map. |
483 | 484 |
|
484 | 485 |
///Sets the length map. |
485 | 486 |
///\return <tt> (*this) </tt> |
486 | 487 |
Dijkstra &lengthMap(const LengthMap &m) |
487 | 488 |
{ |
488 |
|
|
489 |
_length = &m; |
|
489 | 490 |
return *this; |
490 | 491 |
} |
491 | 492 |
|
492 | 493 |
///Sets the map that stores the predecessor arcs. |
493 | 494 |
|
494 | 495 |
///Sets the map that stores the predecessor arcs. |
... | ... |
@@ -635,18 +636,18 @@ |
635 | 636 |
finalizeNodeData(v,oldvalue); |
636 | 637 |
|
637 | 638 |
for(OutArcIt e(*G,v); e!=INVALID; ++e) { |
638 | 639 |
Node w=G->target(e); |
639 | 640 |
switch(_heap->state(w)) { |
640 | 641 |
case Heap::PRE_HEAP: |
641 |
_heap->push(w,OperationTraits::plus(oldvalue, (* |
|
642 |
_heap->push(w,OperationTraits::plus(oldvalue, (*_length)[e])); |
|
642 | 643 |
_pred->set(w,e); |
643 | 644 |
break; |
644 | 645 |
case Heap::IN_HEAP: |
645 | 646 |
{ |
646 |
Value newvalue = OperationTraits::plus(oldvalue, (* |
|
647 |
Value newvalue = OperationTraits::plus(oldvalue, (*_length)[e]); |
|
647 | 648 |
if ( OperationTraits::less(newvalue, (*_heap)[w]) ) { |
648 | 649 |
_heap->decrease(w, newvalue); |
649 | 650 |
_pred->set(w,e); |
650 | 651 |
} |
651 | 652 |
} |
652 | 653 |
break; |
... | ... |
@@ -28,25 +28,25 @@ |
28 | 28 |
|
29 | 29 |
namespace lemon { |
30 | 30 |
|
31 | 31 |
/// \brief Default traits class of Preflow class. |
32 | 32 |
/// |
33 | 33 |
/// Default traits class of Preflow class. |
34 |
/// \tparam _Digraph Digraph type. |
|
35 |
/// \tparam _CapacityMap Capacity map type. |
|
36 |
|
|
34 |
/// \tparam GR Digraph type. |
|
35 |
/// \tparam CM Capacity map type. |
|
36 |
template <typename GR, typename CM> |
|
37 | 37 |
struct PreflowDefaultTraits { |
38 | 38 |
|
39 | 39 |
/// \brief The type of the digraph the algorithm runs on. |
40 |
typedef |
|
40 |
typedef GR Digraph; |
|
41 | 41 |
|
42 | 42 |
/// \brief The type of the map that stores the arc capacities. |
43 | 43 |
/// |
44 | 44 |
/// The type of the map that stores the arc capacities. |
45 | 45 |
/// It must meet the \ref concepts::ReadMap "ReadMap" concept. |
46 |
typedef |
|
46 |
typedef CM CapacityMap; |
|
47 | 47 |
|
48 | 48 |
/// \brief The type of the flow values. |
49 | 49 |
typedef typename CapacityMap::Value Value; |
50 | 50 |
|
51 | 51 |
/// \brief The type of the map that stores the flow values. |
52 | 52 |
/// |
... | ... |
@@ -101,27 +101,27 @@ |
101 | 101 |
/// The worst case time complexity of the algorithm is \f$O(n^2\sqrt{e})\f$. |
102 | 102 |
/// |
103 | 103 |
/// The algorithm consists of two phases. After the first phase |
104 | 104 |
/// the maximum flow value and the minimum cut is obtained. The |
105 | 105 |
/// second phase constructs a feasible maximum flow on each arc. |
106 | 106 |
/// |
107 |
/// \tparam _Digraph The type of the digraph the algorithm runs on. |
|
108 |
/// \tparam _CapacityMap The type of the capacity map. The default map |
|
109 |
/// type |
|
107 |
/// \tparam GR The type of the digraph the algorithm runs on. |
|
108 |
/// \tparam CM The type of the capacity map. The default map |
|
109 |
/// type is \ref concepts::Digraph::ArcMap "GR::ArcMap<int>". |
|
110 | 110 |
#ifdef DOXYGEN |
111 |
template <typename |
|
111 |
template <typename GR, typename CM, typename TR> |
|
112 | 112 |
#else |
113 |
template <typename _Digraph, |
|
114 |
typename _CapacityMap = typename _Digraph::template ArcMap<int>, |
|
115 |
|
|
113 |
template <typename GR, |
|
114 |
typename CM = typename GR::template ArcMap<int>, |
|
115 |
typename TR = PreflowDefaultTraits<GR, CM> > |
|
116 | 116 |
#endif |
117 | 117 |
class Preflow { |
118 | 118 |
public: |
119 | 119 |
|
120 | 120 |
///The \ref PreflowDefaultTraits "traits class" of the algorithm. |
121 |
typedef |
|
121 |
typedef TR Traits; |
|
122 | 122 |
///The type of the digraph the algorithm runs on. |
123 | 123 |
typedef typename Traits::Digraph Digraph; |
124 | 124 |
///The type of the capacity map. |
125 | 125 |
typedef typename Traits::CapacityMap CapacityMap; |
126 | 126 |
///The type of the flow values. |
127 | 127 |
typedef typename Traits::Value Value; |
0 comments (0 inline)