0
8
0
... | ... |
@@ -93,20 +93,20 @@ |
93 | 93 |
(=variables used locally in methods) should look like the following. |
94 | 94 |
|
95 | 95 |
\code |
96 | 96 |
all_lower_case_with_underscores |
97 | 97 |
\endcode |
98 | 98 |
|
99 | 99 |
\subsection pri-loc-var Private member variables |
100 | 100 |
|
101 |
Private member variables should start with underscore |
|
101 |
Private member variables should start with underscore. |
|
102 | 102 |
|
103 | 103 |
\code |
104 |
|
|
104 |
_start_with_underscore |
|
105 | 105 |
\endcode |
106 | 106 |
|
107 | 107 |
\subsection cs-excep Exceptions |
108 | 108 |
|
109 | 109 |
When writing exceptions please comply the following naming conventions. |
110 | 110 |
|
111 | 111 |
\code |
112 | 112 |
ClassNameEndsWithException |
... | ... |
@@ -401,20 +401,20 @@ |
401 | 401 |
- \ref CostScaling Cost Scaling algorithm based on push/augment and |
402 | 402 |
relabel operations \ref goldberg90approximation, \ref goldberg97efficient, |
403 | 403 |
\ref bunnagel98efficient. |
404 | 404 |
- \ref CapacityScaling Capacity Scaling algorithm based on the successive |
405 | 405 |
shortest path method \ref edmondskarp72theoretical. |
406 | 406 |
- \ref CycleCanceling Cycle-Canceling algorithms, two of which are |
407 | 407 |
strongly polynomial \ref klein67primal, \ref goldberg89cyclecanceling. |
408 | 408 |
|
409 |
In general NetworkSimplex is the most efficient implementation, |
|
410 |
but in special cases other algorithms could be faster. |
|
409 |
In general, \ref NetworkSimplex and \ref CostScaling are the most efficient |
|
410 |
implementations, but the other two algorithms could be faster in special cases. |
|
411 | 411 |
For example, if the total supply and/or capacities are rather small, |
412 |
CapacityScaling is usually the fastest algorithm (without effective scaling). |
|
412 |
\ref CapacityScaling is usually the fastest algorithm (without effective scaling). |
|
413 | 413 |
*/ |
414 | 414 |
|
415 | 415 |
/** |
416 | 416 |
@defgroup min_cut Minimum Cut Algorithms |
417 | 417 |
@ingroup algs |
418 | 418 |
|
419 | 419 |
\brief Algorithms for finding minimum cut in graphs. |
420 | 420 |
|
... | ... |
@@ -466,17 +466,17 @@ |
466 | 466 |
LEMON contains three algorithms for solving the minimum mean cycle problem: |
467 | 467 |
- \ref KarpMmc Karp's original algorithm \ref amo93networkflows, |
468 | 468 |
\ref dasdan98minmeancycle. |
469 | 469 |
- \ref HartmannOrlinMmc Hartmann-Orlin's algorithm, which is an improved |
470 | 470 |
version of Karp's algorithm \ref dasdan98minmeancycle. |
471 | 471 |
- \ref HowardMmc Howard's policy iteration algorithm |
472 | 472 |
\ref dasdan98minmeancycle. |
473 | 473 |
|
474 |
In practice, the \ref HowardMmc "Howard" algorithm |
|
474 |
In practice, the \ref HowardMmc "Howard" algorithm turned out to be by far the |
|
475 | 475 |
most efficient one, though the best known theoretical bound on its running |
476 | 476 |
time is exponential. |
477 | 477 |
Both \ref KarpMmc "Karp" and \ref HartmannOrlinMmc "Hartmann-Orlin" algorithms |
478 | 478 |
run in time O(ne) and use space O(n<sup>2</sup>+e), but the latter one is |
479 | 479 |
typically faster due to the applied early termination scheme. |
480 | 480 |
*/ |
481 | 481 |
|
482 | 482 |
/** |
... | ... |
@@ -534,17 +534,17 @@ |
534 | 534 |
This group contains the algorithms for discovering the graph properties |
535 | 535 |
like connectivity, bipartiteness, euler property, simplicity etc. |
536 | 536 |
|
537 | 537 |
\image html connected_components.png |
538 | 538 |
\image latex connected_components.eps "Connected components" width=\textwidth |
539 | 539 |
*/ |
540 | 540 |
|
541 | 541 |
/** |
542 |
@defgroup planar |
|
542 |
@defgroup planar Planar Embedding and Drawing |
|
543 | 543 |
@ingroup algs |
544 | 544 |
\brief Algorithms for planarity checking, embedding and drawing |
545 | 545 |
|
546 | 546 |
This group contains the algorithms for planarity checking, |
547 | 547 |
embedding and drawing. |
548 | 548 |
|
549 | 549 |
\image html planar.png |
550 | 550 |
\image latex planar.eps "Plane graph" width=\textwidth |
... | ... |
@@ -83,18 +83,18 @@ |
83 | 83 |
/// \tparam TR The traits class that defines various types used by the |
84 | 84 |
/// algorithm. By default, it is \ref CapacityScalingDefaultTraits |
85 | 85 |
/// "CapacityScalingDefaultTraits<GR, V, C>". |
86 | 86 |
/// In most cases, this parameter should not be set directly, |
87 | 87 |
/// consider to use the named template parameters instead. |
88 | 88 |
/// |
89 | 89 |
/// \warning Both number types must be signed and all input data must |
90 | 90 |
/// be integer. |
91 |
/// \warning This algorithm does not support negative costs for such |
|
92 |
/// arcs that have infinite upper bound. |
|
91 |
/// \warning This algorithm does not support negative costs for |
|
92 |
/// arcs having infinite upper bound. |
|
93 | 93 |
#ifdef DOXYGEN |
94 | 94 |
template <typename GR, typename V, typename C, typename TR> |
95 | 95 |
#else |
96 | 96 |
template < typename GR, typename V = int, typename C = V, |
97 | 97 |
typename TR = CapacityScalingDefaultTraits<GR, V, C> > |
98 | 98 |
#endif |
99 | 99 |
class CapacityScaling |
100 | 100 |
{ |
... | ... |
@@ -417,17 +417,17 @@ |
417 | 417 |
/// \brief Set single source and target nodes and a supply value. |
418 | 418 |
/// |
419 | 419 |
/// This function sets a single source node and a single target node |
420 | 420 |
/// and the required flow value. |
421 | 421 |
/// If neither this function nor \ref supplyMap() is used before |
422 | 422 |
/// calling \ref run(), the supply of each node will be set to zero. |
423 | 423 |
/// |
424 | 424 |
/// Using this function has the same effect as using \ref supplyMap() |
425 |
/// with |
|
425 |
/// with a map in which \c k is assigned to \c s, \c -k is |
|
426 | 426 |
/// assigned to \c t and all other nodes have zero supply value. |
427 | 427 |
/// |
428 | 428 |
/// \param s The source node. |
429 | 429 |
/// \param t The target node. |
430 | 430 |
/// \param k The required amount of flow from node \c s to node \c t |
431 | 431 |
/// (i.e. the supply of \c s and the demand of \c t). |
432 | 432 |
/// |
433 | 433 |
/// \return <tt>(*this)</tt> |
... | ... |
@@ -442,17 +442,17 @@ |
442 | 442 |
static void copy(const From& from, Graph &to, |
443 | 443 |
NodeRefMap& nodeRefMap, EdgeRefMap& edgeRefMap) { |
444 | 444 |
to.build(from, nodeRefMap, edgeRefMap); |
445 | 445 |
} |
446 | 446 |
}; |
447 | 447 |
|
448 | 448 |
} |
449 | 449 |
|
450 |
/// Check whether a graph is undirected. |
|
450 |
/// \brief Check whether a graph is undirected. |
|
451 | 451 |
/// |
452 | 452 |
/// This function returns \c true if the given graph is undirected. |
453 | 453 |
#ifdef DOXYGEN |
454 | 454 |
template <typename GR> |
455 | 455 |
bool undirected(const GR& g) { return false; } |
456 | 456 |
#else |
457 | 457 |
template <typename GR> |
458 | 458 |
typename enable_if<UndirectedTagIndicator<GR>, bool>::type |
... | ... |
@@ -92,16 +92,19 @@ |
92 | 92 |
/// \ref CostScaling implements a cost scaling algorithm that performs |
93 | 93 |
/// push/augment and relabel operations for finding a \ref min_cost_flow |
94 | 94 |
/// "minimum cost flow" \ref amo93networkflows, \ref goldberg90approximation, |
95 | 95 |
/// \ref goldberg97efficient, \ref bunnagel98efficient. |
96 | 96 |
/// It is a highly efficient primal-dual solution method, which |
97 | 97 |
/// can be viewed as the generalization of the \ref Preflow |
98 | 98 |
/// "preflow push-relabel" algorithm for the maximum flow problem. |
99 | 99 |
/// |
100 |
/// In general, \ref NetworkSimplex and \ref CostScaling are the fastest |
|
101 |
/// implementations available in LEMON for this problem. |
|
102 |
/// |
|
100 | 103 |
/// Most of the parameters of the problem (except for the digraph) |
101 | 104 |
/// can be given using separate functions, and the algorithm can be |
102 | 105 |
/// executed using the \ref run() function. If some parameters are not |
103 | 106 |
/// specified, then default values will be used. |
104 | 107 |
/// |
105 | 108 |
/// \tparam GR The digraph type the algorithm runs on. |
106 | 109 |
/// \tparam V The number type used for flow amounts, capacity bounds |
107 | 110 |
/// and supply values in the algorithm. By default, it is \c int. |
... | ... |
@@ -110,18 +113,18 @@ |
110 | 113 |
/// \tparam TR The traits class that defines various types used by the |
111 | 114 |
/// algorithm. By default, it is \ref CostScalingDefaultTraits |
112 | 115 |
/// "CostScalingDefaultTraits<GR, V, C>". |
113 | 116 |
/// In most cases, this parameter should not be set directly, |
114 | 117 |
/// consider to use the named template parameters instead. |
115 | 118 |
/// |
116 | 119 |
/// \warning Both number types must be signed and all input data must |
117 | 120 |
/// be integer. |
118 |
/// \warning This algorithm does not support negative costs for such |
|
119 |
/// arcs that have infinite upper bound. |
|
121 |
/// \warning This algorithm does not support negative costs for |
|
122 |
/// arcs having infinite upper bound. |
|
120 | 123 |
/// |
121 | 124 |
/// \note %CostScaling provides three different internal methods, |
122 | 125 |
/// from which the most efficient one is used by default. |
123 | 126 |
/// For more information, see \ref Method. |
124 | 127 |
#ifdef DOXYGEN |
125 | 128 |
template <typename GR, typename V, typename C, typename TR> |
126 | 129 |
#else |
127 | 130 |
template < typename GR, typename V = int, typename C = V, |
... | ... |
@@ -173,17 +176,17 @@ |
173 | 176 |
/// |
174 | 177 |
/// Enum type containing constants for selecting the internal method |
175 | 178 |
/// for the \ref run() function. |
176 | 179 |
/// |
177 | 180 |
/// \ref CostScaling provides three internal methods that differ mainly |
178 | 181 |
/// in their base operations, which are used in conjunction with the |
179 | 182 |
/// relabel operation. |
180 | 183 |
/// By default, the so called \ref PARTIAL_AUGMENT |
181 |
/// "Partial Augment-Relabel" method is used, which |
|
184 |
/// "Partial Augment-Relabel" method is used, which turned out to be |
|
182 | 185 |
/// the most efficient and the most robust on various test inputs. |
183 | 186 |
/// However, the other methods can be selected using the \ref run() |
184 | 187 |
/// function with the proper parameter. |
185 | 188 |
enum Method { |
186 | 189 |
/// Local push operations are used, i.e. flow is moved only on one |
187 | 190 |
/// admissible arc at once. |
188 | 191 |
PUSH, |
189 | 192 |
/// Augment operations are used, i.e. flow is moved on admissible |
... | ... |
@@ -442,17 +445,17 @@ |
442 | 445 |
/// \brief Set single source and target nodes and a supply value. |
443 | 446 |
/// |
444 | 447 |
/// This function sets a single source node and a single target node |
445 | 448 |
/// and the required flow value. |
446 | 449 |
/// If neither this function nor \ref supplyMap() is used before |
447 | 450 |
/// calling \ref run(), the supply of each node will be set to zero. |
448 | 451 |
/// |
449 | 452 |
/// Using this function has the same effect as using \ref supplyMap() |
450 |
/// with |
|
453 |
/// with a map in which \c k is assigned to \c s, \c -k is |
|
451 | 454 |
/// assigned to \c t and all other nodes have zero supply value. |
452 | 455 |
/// |
453 | 456 |
/// \param s The source node. |
454 | 457 |
/// \param t The target node. |
455 | 458 |
/// \param k The required amount of flow from node \c s to node \c t |
456 | 459 |
/// (i.e. the supply of \c s and the demand of \c t). |
457 | 460 |
/// |
458 | 461 |
/// \return <tt>(*this)</tt> |
... | ... |
@@ -62,18 +62,18 @@ |
62 | 62 |
/// \tparam GR The digraph type the algorithm runs on. |
63 | 63 |
/// \tparam V The number type used for flow amounts, capacity bounds |
64 | 64 |
/// and supply values in the algorithm. By default, it is \c int. |
65 | 65 |
/// \tparam C The number type used for costs and potentials in the |
66 | 66 |
/// algorithm. By default, it is the same as \c V. |
67 | 67 |
/// |
68 | 68 |
/// \warning Both number types must be signed and all input data must |
69 | 69 |
/// be integer. |
70 |
/// \warning This algorithm does not support negative costs for such |
|
71 |
/// arcs that have infinite upper bound. |
|
70 |
/// \warning This algorithm does not support negative costs for |
|
71 |
/// arcs having infinite upper bound. |
|
72 | 72 |
/// |
73 | 73 |
/// \note For more information about the three available methods, |
74 | 74 |
/// see \ref Method. |
75 | 75 |
#ifdef DOXYGEN |
76 | 76 |
template <typename GR, typename V, typename C> |
77 | 77 |
#else |
78 | 78 |
template <typename GR, typename V = int, typename C = V> |
79 | 79 |
#endif |
... | ... |
@@ -111,18 +111,17 @@ |
111 | 111 |
|
112 | 112 |
/// \brief Constants for selecting the used method. |
113 | 113 |
/// |
114 | 114 |
/// Enum type containing constants for selecting the used method |
115 | 115 |
/// for the \ref run() function. |
116 | 116 |
/// |
117 | 117 |
/// \ref CycleCanceling provides three different cycle-canceling |
118 | 118 |
/// methods. By default, \ref CANCEL_AND_TIGHTEN "Cancel and Tighten" |
119 |
/// is used, which proved to be the most efficient and the most robust |
|
120 |
/// on various test inputs. |
|
119 |
/// is used, which is by far the most efficient and the most robust. |
|
121 | 120 |
/// However, the other methods can be selected using the \ref run() |
122 | 121 |
/// function with the proper parameter. |
123 | 122 |
enum Method { |
124 | 123 |
/// A simple cycle-canceling method, which uses the |
125 | 124 |
/// \ref BellmanFord "Bellman-Ford" algorithm with limited iteration |
126 | 125 |
/// number for detecting negative cycles in the residual network. |
127 | 126 |
SIMPLE_CYCLE_CANCELING, |
128 | 127 |
/// The "Minimum Mean Cycle-Canceling" algorithm, which is a |
... | ... |
@@ -344,17 +343,17 @@ |
344 | 343 |
/// \brief Set single source and target nodes and a supply value. |
345 | 344 |
/// |
346 | 345 |
/// This function sets a single source node and a single target node |
347 | 346 |
/// and the required flow value. |
348 | 347 |
/// If neither this function nor \ref supplyMap() is used before |
349 | 348 |
/// calling \ref run(), the supply of each node will be set to zero. |
350 | 349 |
/// |
351 | 350 |
/// Using this function has the same effect as using \ref supplyMap() |
352 |
/// with |
|
351 |
/// with a map in which \c k is assigned to \c s, \c -k is |
|
353 | 352 |
/// assigned to \c t and all other nodes have zero supply value. |
354 | 353 |
/// |
355 | 354 |
/// \param s The source node. |
356 | 355 |
/// \param t The target node. |
357 | 356 |
/// \param k The required amount of flow from node \c s to node \c t |
358 | 357 |
/// (i.e. the supply of \c s and the demand of \c t). |
359 | 358 |
/// |
360 | 359 |
/// \return <tt>(*this)</tt> |
... | ... |
@@ -31,17 +31,17 @@ |
31 | 31 |
/// |
32 | 32 |
///This file provides Euler tour iterators and a function to check |
33 | 33 |
///if a (di)graph is \e Eulerian. |
34 | 34 |
|
35 | 35 |
namespace lemon { |
36 | 36 |
|
37 | 37 |
///Euler tour iterator for digraphs. |
38 | 38 |
|
39 |
/// \ingroup |
|
39 |
/// \ingroup graph_properties |
|
40 | 40 |
///This iterator provides an Euler tour (Eulerian circuit) of a \e directed |
41 | 41 |
///graph (if there exists) and it converts to the \c Arc type of the digraph. |
42 | 42 |
/// |
43 | 43 |
///For example, if the given digraph has an Euler tour (i.e it has only one |
44 | 44 |
///non-trivial component and the in-degree is equal to the out-degree |
45 | 45 |
///for all nodes), then the following code will put the arcs of \c g |
46 | 46 |
///to the vector \c et according to an Euler tour of \c g. |
47 | 47 |
///\code |
... | ... |
@@ -42,20 +42,20 @@ |
42 | 42 |
/// \ref NetworkSimplex implements the primal Network Simplex algorithm |
43 | 43 |
/// for finding a \ref min_cost_flow "minimum cost flow" |
44 | 44 |
/// \ref amo93networkflows, \ref dantzig63linearprog, |
45 | 45 |
/// \ref kellyoneill91netsimplex. |
46 | 46 |
/// This algorithm is a highly efficient specialized version of the |
47 | 47 |
/// linear programming simplex method directly for the minimum cost |
48 | 48 |
/// flow problem. |
49 | 49 |
/// |
50 |
/// In general, %NetworkSimplex is the fastest implementation available |
|
51 |
/// in LEMON for this problem. |
|
52 |
/// Moreover, it supports both directions of the supply/demand inequality |
|
53 |
/// constraints. For more information, see \ref SupplyType. |
|
50 |
/// In general, \ref NetworkSimplex and \ref CostScaling are the fastest |
|
51 |
/// implementations available in LEMON for this problem. |
|
52 |
/// Furthermore, this class supports both directions of the supply/demand |
|
53 |
/// inequality constraints. For more information, see \ref SupplyType. |
|
54 | 54 |
/// |
55 | 55 |
/// Most of the parameters of the problem (except for the digraph) |
56 | 56 |
/// can be given using separate functions, and the algorithm can be |
57 | 57 |
/// executed using the \ref run() function. If some parameters are not |
58 | 58 |
/// specified, then default values will be used. |
59 | 59 |
/// |
60 | 60 |
/// \tparam GR The digraph type the algorithm runs on. |
61 | 61 |
/// \tparam V The number type used for flow amounts, capacity bounds |
... | ... |
@@ -120,17 +120,17 @@ |
120 | 120 |
/// |
121 | 121 |
/// Enum type containing constants for selecting the pivot rule for |
122 | 122 |
/// the \ref run() function. |
123 | 123 |
/// |
124 | 124 |
/// \ref NetworkSimplex provides five different pivot rule |
125 | 125 |
/// implementations that significantly affect the running time |
126 | 126 |
/// of the algorithm. |
127 | 127 |
/// By default, \ref BLOCK_SEARCH "Block Search" is used, which |
128 |
/// |
|
128 |
/// turend out to be the most efficient and the most robust on various |
|
129 | 129 |
/// test inputs. |
130 | 130 |
/// However, another pivot rule can be selected using the \ref run() |
131 | 131 |
/// function with the proper parameter. |
132 | 132 |
enum PivotRule { |
133 | 133 |
|
134 | 134 |
/// The \e First \e Eligible pivot rule. |
135 | 135 |
/// The next eligible arc is selected in a wraparound fashion |
136 | 136 |
/// in every iteration. |
... | ... |
@@ -162,17 +162,17 @@ |
162 | 162 |
private: |
163 | 163 |
|
164 | 164 |
TEMPLATE_DIGRAPH_TYPEDEFS(GR); |
165 | 165 |
|
166 | 166 |
typedef std::vector<int> IntVector; |
167 | 167 |
typedef std::vector<Value> ValueVector; |
168 | 168 |
typedef std::vector<Cost> CostVector; |
169 | 169 |
typedef std::vector<signed char> CharVector; |
170 |
// Note: vector<signed char> is used instead of vector<ArcState> and |
|
170 |
// Note: vector<signed char> is used instead of vector<ArcState> and |
|
171 | 171 |
// vector<ArcDirection> for efficiency reasons |
172 | 172 |
|
173 | 173 |
// State constants for arcs |
174 | 174 |
enum ArcState { |
175 | 175 |
STATE_UPPER = -1, |
176 | 176 |
STATE_TREE = 0, |
177 | 177 |
STATE_LOWER = 1 |
178 | 178 |
}; |
... | ... |
@@ -729,33 +729,35 @@ |
729 | 729 |
/// If neither this function nor \ref stSupply() is used before |
730 | 730 |
/// calling \ref run(), the supply of each node will be set to zero. |
731 | 731 |
/// |
732 | 732 |
/// \param map A node map storing the supply values. |
733 | 733 |
/// Its \c Value type must be convertible to the \c Value type |
734 | 734 |
/// of the algorithm. |
735 | 735 |
/// |
736 | 736 |
/// \return <tt>(*this)</tt> |
737 |
/// |
|
738 |
/// \sa supplyType() |
|
737 | 739 |
template<typename SupplyMap> |
738 | 740 |
NetworkSimplex& supplyMap(const SupplyMap& map) { |
739 | 741 |
for (NodeIt n(_graph); n != INVALID; ++n) { |
740 | 742 |
_supply[_node_id[n]] = map[n]; |
741 | 743 |
} |
742 | 744 |
return *this; |
743 | 745 |
} |
744 | 746 |
|
745 | 747 |
/// \brief Set single source and target nodes and a supply value. |
746 | 748 |
/// |
747 | 749 |
/// This function sets a single source node and a single target node |
748 | 750 |
/// and the required flow value. |
749 | 751 |
/// If neither this function nor \ref supplyMap() is used before |
750 | 752 |
/// calling \ref run(), the supply of each node will be set to zero. |
751 | 753 |
/// |
752 | 754 |
/// Using this function has the same effect as using \ref supplyMap() |
753 |
/// with |
|
755 |
/// with a map in which \c k is assigned to \c s, \c -k is |
|
754 | 756 |
/// assigned to \c t and all other nodes have zero supply value. |
755 | 757 |
/// |
756 | 758 |
/// \param s The source node. |
757 | 759 |
/// \param t The target node. |
758 | 760 |
/// \param k The required amount of flow from node \c s to node \c t |
759 | 761 |
/// (i.e. the supply of \c s and the demand of \c t). |
760 | 762 |
/// |
761 | 763 |
/// \return <tt>(*this)</tt> |
0 comments (0 inline)