0
15
0
2
7
2
7
1
11
... | ... |
@@ -45,35 +45,33 @@ |
45 | 45 |
///\brief The type of the map that stores the predecessor |
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 | 52 |
///Instantiates a \ref PredMap. |
53 | 53 |
|
54 | 54 |
///This function instantiates a \ref PredMap. |
55 | 55 |
///\param g is the digraph, to which we would like to define the |
56 | 56 |
///\ref PredMap. |
57 |
///\todo The digraph alone may be insufficient to initialize |
|
58 | 57 |
static PredMap *createPredMap(const Digraph &g) |
59 | 58 |
{ |
60 | 59 |
return new PredMap(g); |
61 | 60 |
} |
62 | 61 |
|
63 | 62 |
///The type of the map that indicates which nodes are processed. |
64 | 63 |
|
65 | 64 |
///The type of the map that indicates which nodes are processed. |
66 | 65 |
///It must meet the \ref concepts::WriteMap "WriteMap" concept. |
67 |
///By default it is a NullMap. |
|
68 | 66 |
typedef NullMap<typename Digraph::Node,bool> ProcessedMap; |
69 | 67 |
///Instantiates a \ref ProcessedMap. |
70 | 68 |
|
71 | 69 |
///This function instantiates a \ref ProcessedMap. |
72 | 70 |
///\param g is the digraph, to which |
73 | 71 |
///we would like to define the \ref ProcessedMap |
74 | 72 |
#ifdef DOXYGEN |
75 | 73 |
static ProcessedMap *createProcessedMap(const Digraph &g) |
76 | 74 |
#else |
77 | 75 |
static ProcessedMap *createProcessedMap(const Digraph &) |
78 | 76 |
#endif |
79 | 77 |
{ |
... | ... |
@@ -187,26 +185,25 @@ |
187 | 185 |
ReachedMap *_reached; |
188 | 186 |
//Indicates if _reached is locally allocated (true) or not. |
189 | 187 |
bool local_reached; |
190 | 188 |
//Pointer to the map of processed status of the nodes. |
191 | 189 |
ProcessedMap *_processed; |
192 | 190 |
//Indicates if _processed is locally allocated (true) or not. |
193 | 191 |
bool local_processed; |
194 | 192 |
|
195 | 193 |
std::vector<typename Digraph::Node> _queue; |
196 | 194 |
int _queue_head,_queue_tail,_queue_next_dist; |
197 | 195 |
int _curr_dist; |
198 | 196 |
|
199 |
///Creates the maps if necessary. |
|
200 |
///\todo Better memory allocation (instead of new). |
|
197 |
//Creates the maps if necessary. |
|
201 | 198 |
void create_maps() |
202 | 199 |
{ |
203 | 200 |
if(!_pred) { |
204 | 201 |
local_pred = true; |
205 | 202 |
_pred = Traits::createPredMap(*G); |
206 | 203 |
} |
207 | 204 |
if(!_dist) { |
208 | 205 |
local_dist = true; |
209 | 206 |
_dist = Traits::createDistMap(*G); |
210 | 207 |
} |
211 | 208 |
if(!_reached) { |
212 | 209 |
local_reached = true; |
... | ... |
@@ -839,25 +836,24 @@ |
839 | 836 |
///\brief The type of the map that stores the predecessor |
840 | 837 |
///arcs of the shortest paths. |
841 | 838 |
/// |
842 | 839 |
///The type of the map that stores the predecessor |
843 | 840 |
///arcs of the shortest paths. |
844 | 841 |
///It must meet the \ref concepts::WriteMap "WriteMap" concept. |
845 | 842 |
typedef typename Digraph::template NodeMap<typename Digraph::Arc> PredMap; |
846 | 843 |
///Instantiates a \ref PredMap. |
847 | 844 |
|
848 | 845 |
///This function instantiates a \ref PredMap. |
849 | 846 |
///\param g is the digraph, to which we would like to define the |
850 | 847 |
///\ref PredMap. |
851 |
///\todo The digraph alone may be insufficient to initialize |
|
852 | 848 |
static PredMap *createPredMap(const Digraph &g) |
853 | 849 |
{ |
854 | 850 |
return new PredMap(g); |
855 | 851 |
} |
856 | 852 |
|
857 | 853 |
///The type of the map that indicates which nodes are processed. |
858 | 854 |
|
859 | 855 |
///The type of the map that indicates which nodes are processed. |
860 | 856 |
///It must meet the \ref concepts::WriteMap "WriteMap" concept. |
861 | 857 |
///By default it is a NullMap. |
862 | 858 |
typedef NullMap<typename Digraph::Node,bool> ProcessedMap; |
863 | 859 |
///Instantiates a \ref ProcessedMap. |
... | ... |
@@ -1361,26 +1357,25 @@ |
1361 | 1357 |
//Pointer to the underlying digraph. |
1362 | 1358 |
const Digraph *_digraph; |
1363 | 1359 |
//Pointer to the visitor object. |
1364 | 1360 |
Visitor *_visitor; |
1365 | 1361 |
//Pointer to the map of reached status of the nodes. |
1366 | 1362 |
ReachedMap *_reached; |
1367 | 1363 |
//Indicates if _reached is locally allocated (true) or not. |
1368 | 1364 |
bool local_reached; |
1369 | 1365 |
|
1370 | 1366 |
std::vector<typename Digraph::Node> _list; |
1371 | 1367 |
int _list_front, _list_back; |
1372 | 1368 |
|
1373 |
///Creates the maps if necessary. |
|
1374 |
///\todo Better memory allocation (instead of new). |
|
1369 |
//Creates the maps if necessary. |
|
1375 | 1370 |
void create_maps() { |
1376 | 1371 |
if(!_reached) { |
1377 | 1372 |
local_reached = true; |
1378 | 1373 |
_reached = Traits::createReachedMap(*_digraph); |
1379 | 1374 |
} |
1380 | 1375 |
} |
1381 | 1376 |
|
1382 | 1377 |
protected: |
1383 | 1378 |
|
1384 | 1379 |
BfsVisit() {} |
1385 | 1380 |
|
1386 | 1381 |
public: |
... | ... |
@@ -96,27 +96,24 @@ |
96 | 96 |
|
97 | 97 |
/// \brief Directed arc from an edge. |
98 | 98 |
/// |
99 | 99 |
/// Returns a directed arc corresponding to the specified edge. |
100 | 100 |
/// If the given bool is true, the first node of the given edge and |
101 | 101 |
/// the source node of the returned arc are the same. |
102 | 102 |
static Arc direct(const Edge &e, bool d) { |
103 | 103 |
return Arc(e, d); |
104 | 104 |
} |
105 | 105 |
|
106 | 106 |
/// Returns whether the given directed arc has the same orientation |
107 | 107 |
/// as the corresponding edge. |
108 |
/// |
|
109 |
/// \todo reference to the corresponding point of the undirected digraph |
|
110 |
/// concept. "What does the direction of an edge mean?" |
|
111 | 108 |
static bool direction(const Arc &a) { return a.forward; } |
112 | 109 |
|
113 | 110 |
using Parent::first; |
114 | 111 |
using Parent::next; |
115 | 112 |
|
116 | 113 |
void first(Arc &e) const { |
117 | 114 |
Parent::first(e); |
118 | 115 |
e.forward=true; |
119 | 116 |
} |
120 | 117 |
|
121 | 118 |
void next(Arc &e) const { |
122 | 119 |
if( e.forward ) { |
... | ... |
@@ -33,28 +33,27 @@ |
33 | 33 |
///\file |
34 | 34 |
///\brief Vector based graph maps. |
35 | 35 |
namespace lemon { |
36 | 36 |
|
37 | 37 |
/// \ingroup graphbits |
38 | 38 |
/// |
39 | 39 |
/// \brief Graph map based on the std::vector storage. |
40 | 40 |
/// |
41 | 41 |
/// The VectorMap template class is graph map structure what |
42 | 42 |
/// automatically updates the map when a key is added to or erased from |
43 | 43 |
/// the map. This map type uses the std::vector to store the values. |
44 | 44 |
/// |
45 |
/// \tparam |
|
45 |
/// \tparam _Graph The graph this map is attached to. |
|
46 | 46 |
/// \tparam _Item The item type of the graph items. |
47 | 47 |
/// \tparam _Value The value type of the map. |
48 |
/// \todo Fix the doc: there is _Graph parameter instead of _Notifier. |
|
49 | 48 |
template <typename _Graph, typename _Item, typename _Value> |
50 | 49 |
class VectorMap |
51 | 50 |
: public ItemSetTraits<_Graph, _Item>::ItemNotifier::ObserverBase { |
52 | 51 |
private: |
53 | 52 |
|
54 | 53 |
/// The container type of the map. |
55 | 54 |
typedef std::vector<_Value> Container; |
56 | 55 |
|
57 | 56 |
public: |
58 | 57 |
|
59 | 58 |
/// The graph type of the map. |
60 | 59 |
typedef _Graph Graph; |
... | ... |
@@ -27,26 +27,24 @@ |
27 | 27 |
// |
28 | 28 |
// Revision History: |
29 | 29 |
// 05 May 2001: Workarounds for HP aCC from Thomas Matelich. (Jeremy Siek) |
30 | 30 |
// 02 April 2001: Removed limits header altogether. (Jeremy Siek) |
31 | 31 |
// 01 April 2001: Modified to use new <boost/limits.hpp> header. (JMaddock) |
32 | 32 |
// |
33 | 33 |
|
34 | 34 |
// See http://www.boost.org/libs/concept_check for documentation. |
35 | 35 |
|
36 | 36 |
///\file |
37 | 37 |
///\brief Basic utilities for concept checking. |
38 | 38 |
/// |
39 |
///\todo Are we still using BOOST concept checking utility? |
|
40 |
///Is the BOOST copyright notice necessary? |
|
41 | 39 |
|
42 | 40 |
#ifndef LEMON_CONCEPT_CHECK_H |
43 | 41 |
#define LEMON_CONCEPT_CHECK_H |
44 | 42 |
|
45 | 43 |
namespace lemon { |
46 | 44 |
|
47 | 45 |
/* |
48 | 46 |
"inline" is used for ignore_unused_variable_warning() |
49 | 47 |
and function_requires() to make sure there is no |
50 | 48 |
overtarget with g++. |
51 | 49 |
*/ |
52 | 50 |
... | ... |
@@ -11,25 +11,24 @@ |
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 |
///\todo Iterators have obsolete style |
|
24 | 23 |
|
25 | 24 |
#ifndef LEMON_CONCEPT_PATH_H |
26 | 25 |
#define LEMON_CONCEPT_PATH_H |
27 | 26 |
|
28 | 27 |
#include <lemon/core.h> |
29 | 28 |
#include <lemon/concept_check.h> |
30 | 29 |
|
31 | 30 |
namespace lemon { |
32 | 31 |
namespace concepts { |
33 | 32 |
|
34 | 33 |
/// \addtogroup concept |
35 | 34 |
/// @{ |
... | ... |
@@ -46,35 +46,33 @@ |
46 | 46 |
///\brief The type of the map that stores the predecessor |
47 | 47 |
///arcs of the %DFS paths. |
48 | 48 |
/// |
49 | 49 |
///The type of the map that stores the predecessor |
50 | 50 |
///arcs of the %DFS paths. |
51 | 51 |
///It must meet the \ref concepts::WriteMap "WriteMap" concept. |
52 | 52 |
typedef typename Digraph::template NodeMap<typename Digraph::Arc> PredMap; |
53 | 53 |
///Instantiates a \ref PredMap. |
54 | 54 |
|
55 | 55 |
///This function instantiates a \ref PredMap. |
56 | 56 |
///\param g is the digraph, to which we would like to define the |
57 | 57 |
///\ref PredMap. |
58 |
///\todo The digraph alone may be insufficient to initialize |
|
59 | 58 |
static PredMap *createPredMap(const Digraph &g) |
60 | 59 |
{ |
61 | 60 |
return new PredMap(g); |
62 | 61 |
} |
63 | 62 |
|
64 | 63 |
///The type of the map that indicates which nodes are processed. |
65 | 64 |
|
66 | 65 |
///The type of the map that indicates which nodes are processed. |
67 | 66 |
///It must meet the \ref concepts::WriteMap "WriteMap" concept. |
68 |
///By default it is a NullMap. |
|
69 | 67 |
typedef NullMap<typename Digraph::Node,bool> ProcessedMap; |
70 | 68 |
///Instantiates a \ref ProcessedMap. |
71 | 69 |
|
72 | 70 |
///This function instantiates a \ref ProcessedMap. |
73 | 71 |
///\param g is the digraph, to which |
74 | 72 |
///we would like to define the \ref ProcessedMap |
75 | 73 |
#ifdef DOXYGEN |
76 | 74 |
static ProcessedMap *createProcessedMap(const Digraph &g) |
77 | 75 |
#else |
78 | 76 |
static ProcessedMap *createProcessedMap(const Digraph &) |
79 | 77 |
#endif |
80 | 78 |
{ |
... | ... |
@@ -187,26 +185,25 @@ |
187 | 185 |
//Pointer to the map of reached status of the nodes. |
188 | 186 |
ReachedMap *_reached; |
189 | 187 |
//Indicates if _reached is locally allocated (true) or not. |
190 | 188 |
bool local_reached; |
191 | 189 |
//Pointer to the map of processed status of the nodes. |
192 | 190 |
ProcessedMap *_processed; |
193 | 191 |
//Indicates if _processed is locally allocated (true) or not. |
194 | 192 |
bool local_processed; |
195 | 193 |
|
196 | 194 |
std::vector<typename Digraph::OutArcIt> _stack; |
197 | 195 |
int _stack_head; |
198 | 196 |
|
199 |
///Creates the maps if necessary. |
|
200 |
///\todo Better memory allocation (instead of new). |
|
197 |
//Creates the maps if necessary. |
|
201 | 198 |
void create_maps() |
202 | 199 |
{ |
203 | 200 |
if(!_pred) { |
204 | 201 |
local_pred = true; |
205 | 202 |
_pred = Traits::createPredMap(*G); |
206 | 203 |
} |
207 | 204 |
if(!_dist) { |
208 | 205 |
local_dist = true; |
209 | 206 |
_dist = Traits::createDistMap(*G); |
210 | 207 |
} |
211 | 208 |
if(!_reached) { |
212 | 209 |
local_reached = true; |
... | ... |
@@ -773,25 +770,24 @@ |
773 | 770 |
///\brief The type of the map that stores the predecessor |
774 | 771 |
///arcs of the %DFS paths. |
775 | 772 |
/// |
776 | 773 |
///The type of the map that stores the predecessor |
777 | 774 |
///arcs of the %DFS paths. |
778 | 775 |
///It must meet the \ref concepts::WriteMap "WriteMap" concept. |
779 | 776 |
typedef typename Digraph::template NodeMap<typename Digraph::Arc> PredMap; |
780 | 777 |
///Instantiates a \ref PredMap. |
781 | 778 |
|
782 | 779 |
///This function instantiates a \ref PredMap. |
783 | 780 |
///\param g is the digraph, to which we would like to define the |
784 | 781 |
///\ref PredMap. |
785 |
///\todo The digraph alone may be insufficient to initialize |
|
786 | 782 |
static PredMap *createPredMap(const Digraph &g) |
787 | 783 |
{ |
788 | 784 |
return new PredMap(g); |
789 | 785 |
} |
790 | 786 |
|
791 | 787 |
///The type of the map that indicates which nodes are processed. |
792 | 788 |
|
793 | 789 |
///The type of the map that indicates which nodes are processed. |
794 | 790 |
///It must meet the \ref concepts::WriteMap "WriteMap" concept. |
795 | 791 |
///By default it is a NullMap. |
796 | 792 |
typedef NullMap<typename Digraph::Node,bool> ProcessedMap; |
797 | 793 |
///Instantiates a \ref ProcessedMap. |
... | ... |
@@ -1308,26 +1304,25 @@ |
1308 | 1304 |
//Pointer to the underlying digraph. |
1309 | 1305 |
const Digraph *_digraph; |
1310 | 1306 |
//Pointer to the visitor object. |
1311 | 1307 |
Visitor *_visitor; |
1312 | 1308 |
//Pointer to the map of reached status of the nodes. |
1313 | 1309 |
ReachedMap *_reached; |
1314 | 1310 |
//Indicates if _reached is locally allocated (true) or not. |
1315 | 1311 |
bool local_reached; |
1316 | 1312 |
|
1317 | 1313 |
std::vector<typename Digraph::Arc> _stack; |
1318 | 1314 |
int _stack_head; |
1319 | 1315 |
|
1320 |
///Creates the maps if necessary. |
|
1321 |
///\todo Better memory allocation (instead of new). |
|
1316 |
//Creates the maps if necessary. |
|
1322 | 1317 |
void create_maps() { |
1323 | 1318 |
if(!_reached) { |
1324 | 1319 |
local_reached = true; |
1325 | 1320 |
_reached = Traits::createReachedMap(*_digraph); |
1326 | 1321 |
} |
1327 | 1322 |
} |
1328 | 1323 |
|
1329 | 1324 |
protected: |
1330 | 1325 |
|
1331 | 1326 |
DfsVisit() {} |
1332 | 1327 |
|
1333 | 1328 |
public: |
... | ... |
@@ -135,37 +135,34 @@ |
135 | 135 |
///\brief The type of the map that stores the predecessor |
136 | 136 |
///arcs of the shortest paths. |
137 | 137 |
/// |
138 | 138 |
///The type of the map that stores the predecessor |
139 | 139 |
///arcs of the shortest paths. |
140 | 140 |
///It must meet the \ref concepts::WriteMap "WriteMap" concept. |
141 | 141 |
typedef typename Digraph::template NodeMap<typename Digraph::Arc> PredMap; |
142 | 142 |
///Instantiates a \ref PredMap. |
143 | 143 |
|
144 | 144 |
///This function instantiates a \ref PredMap. |
145 | 145 |
///\param g is the digraph, to which we would like to define the |
146 | 146 |
///\ref PredMap. |
147 |
///\todo The digraph alone may be insufficient for the initialization |
|
148 | 147 |
static PredMap *createPredMap(const Digraph &g) |
149 | 148 |
{ |
150 | 149 |
return new PredMap(g); |
151 | 150 |
} |
152 | 151 |
|
153 | 152 |
///The type of the map that indicates which nodes are processed. |
154 | 153 |
|
155 | 154 |
///The type of the map that indicates which nodes are processed. |
156 | 155 |
///It must meet the \ref concepts::WriteMap "WriteMap" concept. |
157 | 156 |
///By default it is a NullMap. |
158 |
///\todo If it is set to a real map, |
|
159 |
///Dijkstra::processed() should read this. |
|
160 | 157 |
typedef NullMap<typename Digraph::Node,bool> ProcessedMap; |
161 | 158 |
///Instantiates a \ref ProcessedMap. |
162 | 159 |
|
163 | 160 |
///This function instantiates a \ref ProcessedMap. |
164 | 161 |
///\param g is the digraph, to which |
165 | 162 |
///we would like to define the \ref ProcessedMap |
166 | 163 |
#ifdef DOXYGEN |
167 | 164 |
static ProcessedMap *createProcessedMap(const Digraph &g) |
168 | 165 |
#else |
169 | 166 |
static ProcessedMap *createProcessedMap(const Digraph &) |
170 | 167 |
#endif |
171 | 168 |
{ |
... | ... |
@@ -288,26 +285,25 @@ |
288 | 285 |
ProcessedMap *_processed; |
289 | 286 |
//Indicates if _processed is locally allocated (true) or not. |
290 | 287 |
bool local_processed; |
291 | 288 |
//Pointer to the heap cross references. |
292 | 289 |
HeapCrossRef *_heap_cross_ref; |
293 | 290 |
//Indicates if _heap_cross_ref is locally allocated (true) or not. |
294 | 291 |
bool local_heap_cross_ref; |
295 | 292 |
//Pointer to the heap. |
296 | 293 |
Heap *_heap; |
297 | 294 |
//Indicates if _heap is locally allocated (true) or not. |
298 | 295 |
bool local_heap; |
299 | 296 |
|
300 |
///Creates the maps if necessary. |
|
301 |
///\todo Better memory allocation (instead of new). |
|
297 |
//Creates the maps if necessary. |
|
302 | 298 |
void create_maps() |
303 | 299 |
{ |
304 | 300 |
if(!_pred) { |
305 | 301 |
local_pred = true; |
306 | 302 |
_pred = Traits::createPredMap(*G); |
307 | 303 |
} |
308 | 304 |
if(!_dist) { |
309 | 305 |
local_dist = true; |
310 | 306 |
_dist = Traits::createDistMap(*G); |
311 | 307 |
} |
312 | 308 |
if(!_processed) { |
313 | 309 |
local_processed = true; |
... | ... |
@@ -949,25 +945,24 @@ |
949 | 945 |
typedef DijkstraDefaultOperationTraits<Value> OperationTraits; |
950 | 946 |
|
951 | 947 |
/// The cross reference type used by the heap. |
952 | 948 |
|
953 | 949 |
/// The cross reference type used by the heap. |
954 | 950 |
/// Usually it is \c Digraph::NodeMap<int>. |
955 | 951 |
typedef typename Digraph::template NodeMap<int> HeapCrossRef; |
956 | 952 |
///Instantiates a \ref HeapCrossRef. |
957 | 953 |
|
958 | 954 |
///This function instantiates a \ref HeapCrossRef. |
959 | 955 |
/// \param g is the digraph, to which we would like to define the |
960 | 956 |
/// HeapCrossRef. |
961 |
/// \todo The digraph alone may be insufficient for the initialization |
|
962 | 957 |
static HeapCrossRef *createHeapCrossRef(const Digraph &g) |
963 | 958 |
{ |
964 | 959 |
return new HeapCrossRef(g); |
965 | 960 |
} |
966 | 961 |
|
967 | 962 |
///The heap type used by the Dijkstra algorithm. |
968 | 963 |
|
969 | 964 |
///The heap type used by the Dijkstra algorithm. |
970 | 965 |
/// |
971 | 966 |
///\sa BinHeap |
972 | 967 |
///\sa Dijkstra |
973 | 968 |
typedef BinHeap<Value, typename Digraph::template NodeMap<int>, |
... | ... |
@@ -985,38 +980,34 @@ |
985 | 980 |
///\brief The type of the map that stores the predecessor |
986 | 981 |
///arcs of the shortest paths. |
987 | 982 |
/// |
988 | 983 |
///The type of the map that stores the predecessor |
989 | 984 |
///arcs of the shortest paths. |
990 | 985 |
///It must meet the \ref concepts::WriteMap "WriteMap" concept. |
991 | 986 |
typedef typename Digraph::template NodeMap<typename Digraph::Arc> PredMap; |
992 | 987 |
///Instantiates a \ref PredMap. |
993 | 988 |
|
994 | 989 |
///This function instantiates a \ref PredMap. |
995 | 990 |
///\param g is the digraph, to which we would like to define the |
996 | 991 |
///\ref PredMap. |
997 |
///\todo The digraph alone may be insufficient to initialize |
|
998 | 992 |
static PredMap *createPredMap(const Digraph &g) |
999 | 993 |
{ |
1000 | 994 |
return new PredMap(g); |
1001 | 995 |
} |
1002 | 996 |
|
1003 | 997 |
///The type of the map that indicates which nodes are processed. |
1004 | 998 |
|
1005 | 999 |
///The type of the map that indicates which nodes are processed. |
1006 | 1000 |
///It must meet the \ref concepts::WriteMap "WriteMap" concept. |
1007 | 1001 |
///By default it is a NullMap. |
1008 |
///\todo If it is set to a real map, |
|
1009 |
///Dijkstra::processed() should read this. |
|
1010 |
///\todo named parameter to set this type, function to read and write. |
|
1011 | 1002 |
typedef NullMap<typename Digraph::Node,bool> ProcessedMap; |
1012 | 1003 |
///Instantiates a \ref ProcessedMap. |
1013 | 1004 |
|
1014 | 1005 |
///This function instantiates a \ref ProcessedMap. |
1015 | 1006 |
///\param g is the digraph, to which |
1016 | 1007 |
///we would like to define the \ref ProcessedMap. |
1017 | 1008 |
#ifdef DOXYGEN |
1018 | 1009 |
static ProcessedMap *createProcessedMap(const Digraph &g) |
1019 | 1010 |
#else |
1020 | 1011 |
static ProcessedMap *createProcessedMap(const Digraph &) |
1021 | 1012 |
#endif |
1022 | 1013 |
{ |
... | ... |
@@ -1044,25 +1035,24 @@ |
1044 | 1035 |
///It must meet the \ref concepts::Path "Path" concept. |
1045 | 1036 |
typedef lemon::Path<Digraph> Path; |
1046 | 1037 |
}; |
1047 | 1038 |
|
1048 | 1039 |
/// Default traits class used by \ref DijkstraWizard |
1049 | 1040 |
|
1050 | 1041 |
/// To make it easier to use Dijkstra algorithm |
1051 | 1042 |
/// we have created a wizard class. |
1052 | 1043 |
/// This \ref DijkstraWizard class needs default traits, |
1053 | 1044 |
/// as well as the \ref Dijkstra class. |
1054 | 1045 |
/// The \ref DijkstraWizardBase is a class to be the default traits of the |
1055 | 1046 |
/// \ref DijkstraWizard class. |
1056 |
/// \todo More named parameters are required... |
|
1057 | 1047 |
template<class GR,class LM> |
1058 | 1048 |
class DijkstraWizardBase : public DijkstraWizardDefaultTraits<GR,LM> |
1059 | 1049 |
{ |
1060 | 1050 |
typedef DijkstraWizardDefaultTraits<GR,LM> Base; |
1061 | 1051 |
protected: |
1062 | 1052 |
//The type of the nodes in the digraph. |
1063 | 1053 |
typedef typename Base::Digraph::Node Node; |
1064 | 1054 |
|
1065 | 1055 |
//Pointer to the digraph the algorithm runs on. |
1066 | 1056 |
void *_g; |
1067 | 1057 |
//Pointer to the length map. |
1068 | 1058 |
void *_length; |
... | ... |
@@ -93,26 +93,24 @@ |
93 | 93 |
std::auto_ptr<_Type> ptr; |
94 | 94 |
}; |
95 | 95 |
|
96 | 96 |
/// Exception-safe convenient error message builder class. |
97 | 97 |
|
98 | 98 |
/// Helper class which provides a convenient ostream-like (operator << |
99 | 99 |
/// based) interface to create a string message. Mostly useful in |
100 | 100 |
/// exception classes (therefore the name). |
101 | 101 |
class ErrorMessage { |
102 | 102 |
protected: |
103 | 103 |
///\e |
104 | 104 |
|
105 |
///\todo The good solution is boost::shared_ptr... |
|
106 |
/// |
|
107 | 105 |
mutable std::auto_ptr<std::ostringstream> buf; |
108 | 106 |
|
109 | 107 |
///\e |
110 | 108 |
bool init() throw() { |
111 | 109 |
try { |
112 | 110 |
buf.reset(new std::ostringstream); |
113 | 111 |
} |
114 | 112 |
catch(...) { |
115 | 113 |
buf.reset(); |
116 | 114 |
} |
117 | 115 |
return buf.get(); |
118 | 116 |
} |
... | ... |
@@ -657,25 +657,24 @@ |
657 | 657 |
} |
658 | 658 |
|
659 | 659 |
public: |
660 | 660 |
~GraphToEps() { } |
661 | 661 |
|
662 | 662 |
///Draws the graph. |
663 | 663 |
|
664 | 664 |
///Like other functions using |
665 | 665 |
///\ref named-templ-func-param "named template parameters", |
666 | 666 |
///this function calls the algorithm itself, i.e. in this case |
667 | 667 |
///it draws the graph. |
668 | 668 |
void run() { |
669 |
//\todo better 'epsilon' would be nice here. |
|
670 | 669 |
const double EPSILON=1e-9; |
671 | 670 |
if(dontPrint) return; |
672 | 671 |
|
673 | 672 |
_graph_to_eps_bits::_NegY<typename T::CoordsMapType> |
674 | 673 |
mycoords(_coords,_negY); |
675 | 674 |
|
676 | 675 |
os << "%!PS-Adobe-2.0 EPSF-2.0\n"; |
677 | 676 |
if(_title.size()>0) os << "%%Title: " << _title << '\n'; |
678 | 677 |
if(_copyright.size()>0) os << "%%Copyright: " << _copyright << '\n'; |
679 | 678 |
os << "%%Creator: LEMON, graphToEps()\n"; |
680 | 679 |
|
681 | 680 |
{ |
... | ... |
@@ -698,35 +697,33 @@ |
698 | 697 |
GetDateFormat(LOCALE_USER_DEFAULT, 0, &time, |
699 | 698 |
"yyyy", buf3, 5)) { |
700 | 699 |
os << "%%CreationDate: " << buf1 << ' ' |
701 | 700 |
<< buf2 << ' ' << buf3 << std::endl; |
702 | 701 |
} |
703 | 702 |
#endif |
704 | 703 |
} |
705 | 704 |
|
706 | 705 |
if (_autoArcWidthScale) { |
707 | 706 |
double max_w=0; |
708 | 707 |
for(ArcIt e(g);e!=INVALID;++e) |
709 | 708 |
max_w=std::max(double(_arcWidths[e]),max_w); |
710 |
//\todo better 'epsilon' would be nice here. |
|
711 | 709 |
if(max_w>EPSILON) { |
712 | 710 |
_arcWidthScale/=max_w; |
713 | 711 |
} |
714 | 712 |
} |
715 | 713 |
|
716 | 714 |
if (_autoNodeScale) { |
717 | 715 |
double max_s=0; |
718 | 716 |
for(NodeIt n(g);n!=INVALID;++n) |
719 | 717 |
max_s=std::max(double(_nodeSizes[n]),max_s); |
720 |
//\todo better 'epsilon' would be nice here. |
|
721 | 718 |
if(max_s>EPSILON) { |
722 | 719 |
_nodeScale/=max_s; |
723 | 720 |
} |
724 | 721 |
} |
725 | 722 |
|
726 | 723 |
double diag_len = 1; |
727 | 724 |
if(!(_absoluteNodeSizes&&_absoluteArcWidths)) { |
728 | 725 |
dim2::Box<double> bb; |
729 | 726 |
for(NodeIt n(g);n!=INVALID;++n) bb.add(mycoords[n]); |
730 | 727 |
if (bb.empty()) { |
731 | 728 |
bb = dim2::Box<double>(dim2::Point<double>(0,0)); |
732 | 729 |
} |
... | ... |
@@ -864,25 +861,24 @@ |
864 | 861 |
os << "\ngsave\n"; |
865 | 862 |
if(_scaleToA4) |
866 | 863 |
if(bb.height()>bb.width()) { |
867 | 864 |
double sc= std::min((A4HEIGHT-2*A4BORDER)/bb.height(), |
868 | 865 |
(A4WIDTH-2*A4BORDER)/bb.width()); |
869 | 866 |
os << ((A4WIDTH -2*A4BORDER)-sc*bb.width())/2 + A4BORDER << ' ' |
870 | 867 |
<< ((A4HEIGHT-2*A4BORDER)-sc*bb.height())/2 + A4BORDER |
871 | 868 |
<< " translate\n" |
872 | 869 |
<< sc << " dup scale\n" |
873 | 870 |
<< -bb.left() << ' ' << -bb.bottom() << " translate\n"; |
874 | 871 |
} |
875 | 872 |
else { |
876 |
//\todo Verify centering |
|
877 | 873 |
double sc= std::min((A4HEIGHT-2*A4BORDER)/bb.width(), |
878 | 874 |
(A4WIDTH-2*A4BORDER)/bb.height()); |
879 | 875 |
os << ((A4WIDTH -2*A4BORDER)-sc*bb.height())/2 + A4BORDER << ' ' |
880 | 876 |
<< ((A4HEIGHT-2*A4BORDER)-sc*bb.width())/2 + A4BORDER |
881 | 877 |
<< " translate\n" |
882 | 878 |
<< sc << " dup scale\n90 rotate\n" |
883 | 879 |
<< -bb.left() << ' ' << -bb.top() << " translate\n"; |
884 | 880 |
} |
885 | 881 |
else if(_scale!=1.0) os << _scale << " dup scale\n"; |
886 | 882 |
|
887 | 883 |
if(_showArcs) { |
888 | 884 |
os << "%Arcs:\ngsave\n"; |
... | ... |
@@ -897,25 +893,24 @@ |
897 | 893 |
typename std::vector<Arc>::iterator j; |
898 | 894 |
for(typename std::vector<Arc>::iterator i=el.begin();i!=el.end();i=j) { |
899 | 895 |
for(j=i+1;j!=el.end()&&isParallel(*i,*j);++j) ; |
900 | 896 |
|
901 | 897 |
double sw=0; |
902 | 898 |
for(typename std::vector<Arc>::iterator e=i;e!=j;++e) |
903 | 899 |
sw+=_arcWidths[*e]*_arcWidthScale+_parArcDist; |
904 | 900 |
sw-=_parArcDist; |
905 | 901 |
sw/=-2.0; |
906 | 902 |
dim2::Point<double> |
907 | 903 |
dvec(mycoords[g.target(*i)]-mycoords[g.source(*i)]); |
908 | 904 |
double l=std::sqrt(dvec.normSquare()); |
909 |
//\todo better 'epsilon' would be nice here. |
|
910 | 905 |
dim2::Point<double> d(dvec/std::max(l,EPSILON)); |
911 | 906 |
dim2::Point<double> m; |
912 | 907 |
// m=dim2::Point<double>(mycoords[g.target(*i)]+ |
913 | 908 |
// mycoords[g.source(*i)])/2.0; |
914 | 909 |
|
915 | 910 |
// m=dim2::Point<double>(mycoords[g.source(*i)])+ |
916 | 911 |
// dvec*(double(_nodeSizes[g.source(*i)])/ |
917 | 912 |
// (_nodeSizes[g.source(*i)]+_nodeSizes[g.target(*i)])); |
918 | 913 |
|
919 | 914 |
m=dim2::Point<double>(mycoords[g.source(*i)])+ |
920 | 915 |
d*(l+_nodeSizes[g.source(*i)]-_nodeSizes[g.target(*i)])/2.0; |
921 | 916 |
... | ... |
@@ -492,28 +492,26 @@ |
492 | 492 |
///Split a node. |
493 | 493 |
|
494 | 494 |
///This function splits a node. First a new node is added to the digraph, |
495 | 495 |
///then the source of each outgoing arc of \c n is moved to this new node. |
496 | 496 |
///If \c connect is \c true (this is the default value), then a new arc |
497 | 497 |
///from \c n to the newly created node is also added. |
498 | 498 |
///\return The newly created node. |
499 | 499 |
/// |
500 | 500 |
///\note The <tt>ArcIt</tt>s referencing a moved arc remain |
501 | 501 |
///valid. However <tt>InArcIt</tt>s and <tt>OutArcIt</tt>s may |
502 | 502 |
///be invalidated. |
503 | 503 |
/// |
504 |
///\warning This functionality cannot be used |
|
504 |
///\warning This functionality cannot be used in conjunction with the |
|
505 | 505 |
///Snapshot feature. |
506 |
/// |
|
507 |
///\todo It could be implemented in a bit faster way. |
|
508 | 506 |
Node split(Node n, bool connect = true) { |
509 | 507 |
Node b = addNode(); |
510 | 508 |
for(OutArcIt e(*this,n);e!=INVALID;) { |
511 | 509 |
OutArcIt f=e; |
512 | 510 |
++f; |
513 | 511 |
changeSource(e,b); |
514 | 512 |
e=f; |
515 | 513 |
} |
516 | 514 |
if (connect) addArc(n,b); |
517 | 515 |
return b; |
518 | 516 |
} |
519 | 517 |
... | ... |
@@ -475,26 +475,24 @@ |
475 | 475 |
/// ComposeMap<M1, M2> cm(m1,m2); |
476 | 476 |
/// \endcode |
477 | 477 |
/// <tt>cm[x]</tt> will be equal to <tt>m1[m2[x]]</tt>. |
478 | 478 |
/// |
479 | 479 |
/// The \c Key type of the map is inherited from \c M2 and the |
480 | 480 |
/// \c Value type is from \c M1. |
481 | 481 |
/// \c M2::Value must be convertible to \c M1::Key. |
482 | 482 |
/// |
483 | 483 |
/// The simplest way of using this map is through the composeMap() |
484 | 484 |
/// function. |
485 | 485 |
/// |
486 | 486 |
/// \sa CombineMap |
487 |
/// |
|
488 |
/// \todo Check the requirements. |
|
489 | 487 |
template <typename M1, typename M2> |
490 | 488 |
class ComposeMap : public MapBase<typename M2::Key, typename M1::Value> { |
491 | 489 |
const M1 &_m1; |
492 | 490 |
const M2 &_m2; |
493 | 491 |
public: |
494 | 492 |
typedef MapBase<typename M2::Key, typename M1::Value> Parent; |
495 | 493 |
typedef typename Parent::Key Key; |
496 | 494 |
typedef typename Parent::Value Value; |
497 | 495 |
|
498 | 496 |
/// Constructor |
499 | 497 |
ComposeMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {} |
500 | 498 |
|
... | ... |
@@ -531,26 +529,24 @@ |
531 | 529 |
/// <tt>cm[x]</tt> will be equal to <tt>f(m1[x],m2[x])</tt>. |
532 | 530 |
/// |
533 | 531 |
/// The \c Key type of the map is inherited from \c M1 (\c M1::Key |
534 | 532 |
/// must be convertible to \c M2::Key) and the \c Value type is \c V. |
535 | 533 |
/// \c M2::Value and \c M1::Value must be convertible to the |
536 | 534 |
/// corresponding input parameter of \c F and the return type of \c F |
537 | 535 |
/// must be convertible to \c V. |
538 | 536 |
/// |
539 | 537 |
/// The simplest way of using this map is through the combineMap() |
540 | 538 |
/// function. |
541 | 539 |
/// |
542 | 540 |
/// \sa ComposeMap |
543 |
/// |
|
544 |
/// \todo Check the requirements. |
|
545 | 541 |
template<typename M1, typename M2, typename F, |
546 | 542 |
typename V = typename F::result_type> |
547 | 543 |
class CombineMap : public MapBase<typename M1::Key, V> { |
548 | 544 |
const M1 &_m1; |
549 | 545 |
const M2 &_m2; |
550 | 546 |
F _f; |
551 | 547 |
public: |
552 | 548 |
typedef MapBase<typename M1::Key, V> Parent; |
553 | 549 |
typedef typename Parent::Key Key; |
554 | 550 |
typedef typename Parent::Value Value; |
555 | 551 |
|
556 | 552 |
/// Constructor |
... | ... |
@@ -812,25 +812,24 @@ |
812 | 812 |
/// \brief Returns a random bool |
813 | 813 |
/// |
814 | 814 |
/// It returns a random bool with given probability of true result. |
815 | 815 |
bool boolean(double p) { |
816 | 816 |
return operator()() < p; |
817 | 817 |
} |
818 | 818 |
|
819 | 819 |
/// Standard Gauss distribution |
820 | 820 |
|
821 | 821 |
/// Standard Gauss distribution. |
822 | 822 |
/// \note The Cartesian form of the Box-Muller |
823 | 823 |
/// transformation is used to generate a random normal distribution. |
824 |
/// \todo Consider using the "ziggurat" method instead. |
|
825 | 824 |
double gauss() |
826 | 825 |
{ |
827 | 826 |
double V1,V2,S; |
828 | 827 |
do { |
829 | 828 |
V1=2*real<double>()-1; |
830 | 829 |
V2=2*real<double>()-1; |
831 | 830 |
S=V1*V1+V2*V2; |
832 | 831 |
} while(S>=1); |
833 | 832 |
return std::sqrt(-2*std::log(S)/S)*V1; |
834 | 833 |
} |
835 | 834 |
/// Gauss distribution with given mean and standard deviation |
836 | 835 |
... | ... |
@@ -291,25 +291,24 @@ |
291 | 291 |
///This function splits a node. First a new node is added to the digraph, |
292 | 292 |
///then the source of each outgoing arc of \c n is moved to this new node. |
293 | 293 |
///If \c connect is \c true (this is the default value), then a new arc |
294 | 294 |
///from \c n to the newly created node is also added. |
295 | 295 |
///\return The newly created node. |
296 | 296 |
/// |
297 | 297 |
///\note The <tt>Arc</tt>s |
298 | 298 |
///referencing a moved arc remain |
299 | 299 |
///valid. However <tt>InArc</tt>'s and <tt>OutArc</tt>'s |
300 | 300 |
///may be invalidated. |
301 | 301 |
///\warning This functionality cannot be used together with the Snapshot |
302 | 302 |
///feature. |
303 |
///\todo It could be implemented in a bit faster way. |
|
304 | 303 |
Node split(Node n, bool connect = true) |
305 | 304 |
{ |
306 | 305 |
Node b = addNode(); |
307 | 306 |
nodes[b._id].first_out=nodes[n._id].first_out; |
308 | 307 |
nodes[n._id].first_out=-1; |
309 | 308 |
for(int i=nodes[b._id].first_out;i!=-1;i++) arcs[i].source=b._id; |
310 | 309 |
if(connect) addArc(n,b); |
311 | 310 |
return b; |
312 | 311 |
} |
313 | 312 |
|
314 | 313 |
public: |
315 | 314 |
... | ... |
@@ -283,25 +283,24 @@ |
283 | 283 |
///running times. |
284 | 284 |
/// |
285 | 285 |
///\warning Depending on the operation system and its actual configuration |
286 | 286 |
///the time counters have a certain (10ms on a typical Linux system) |
287 | 287 |
///granularity. |
288 | 288 |
///Therefore this tool is not appropriate to measure very short times. |
289 | 289 |
///Also, if you start and stop the timer very frequently, it could lead to |
290 | 290 |
///distorted results. |
291 | 291 |
/// |
292 | 292 |
///\note If you want to measure the running time of the execution of a certain |
293 | 293 |
///function, consider the usage of \ref TimeReport instead. |
294 | 294 |
/// |
295 |
///\todo This shouldn't be Unix (Linux) specific. |
|
296 | 295 |
///\sa TimeReport |
297 | 296 |
class Timer |
298 | 297 |
{ |
299 | 298 |
int _running; //Timer is running iff _running>0; (_running>=0 always holds) |
300 | 299 |
TimeStamp start_time; //This is the relativ start-time if the timer |
301 | 300 |
//is _running, the collected _running time otherwise. |
302 | 301 |
|
303 | 302 |
void _reset() {if(_running) start_time.stamp(); else start_time.reset();} |
304 | 303 |
|
305 | 304 |
public: |
306 | 305 |
///Constructor. |
307 | 306 |
|
... | ... |
@@ -478,25 +477,24 @@ |
478 | 477 |
///Same as \ref Timer but prints a report on destruction. |
479 | 478 |
///This example shows its usage. |
480 | 479 |
///\code |
481 | 480 |
/// void myAlg(ListGraph &g,int n) |
482 | 481 |
/// { |
483 | 482 |
/// TimeReport tr("Running time of myAlg: "); |
484 | 483 |
/// ... //Here comes the algorithm |
485 | 484 |
/// } |
486 | 485 |
///\endcode |
487 | 486 |
/// |
488 | 487 |
///\sa Timer |
489 | 488 |
///\sa NoTimeReport |
490 |
///\todo There is no test case for this |
|
491 | 489 |
class TimeReport : public Timer |
492 | 490 |
{ |
493 | 491 |
std::string _title; |
494 | 492 |
std::ostream &_os; |
495 | 493 |
public: |
496 | 494 |
///\e |
497 | 495 |
|
498 | 496 |
///\param title This text will be printed before the ellapsed time. |
499 | 497 |
///\param os The stream to print the report to. |
500 | 498 |
///\param run Sets whether the timer should start immediately. |
501 | 499 |
|
502 | 500 |
TimeReport(std::string title,std::ostream &os=std::cerr,bool run=true) |
... | ... |
@@ -15,26 +15,24 @@ |
15 | 15 |
* purpose. |
16 | 16 |
* |
17 | 17 |
*/ |
18 | 18 |
|
19 | 19 |
#ifndef LEMON_TOLERANCE_H |
20 | 20 |
#define LEMON_TOLERANCE_H |
21 | 21 |
|
22 | 22 |
///\ingroup misc |
23 | 23 |
///\file |
24 | 24 |
///\brief A basic tool to handle the anomalies of calculation with |
25 | 25 |
///floating point numbers. |
26 | 26 |
/// |
27 |
///\todo It should be in a module like "Basic tools" |
|
28 |
|
|
29 | 27 |
|
30 | 28 |
namespace lemon { |
31 | 29 |
|
32 | 30 |
/// \addtogroup misc |
33 | 31 |
/// @{ |
34 | 32 |
|
35 | 33 |
///\brief A class to provide a basic way to |
36 | 34 |
///handle the comparison of numbers that are obtained |
37 | 35 |
///as a result of a probably inexact computation. |
38 | 36 |
/// |
39 | 37 |
///\ref Tolerance is a class to provide a basic way to |
40 | 38 |
///handle the comparison of numbers that are obtained |
0 comments (0 inline)