... |
... |
@@ -60,13 +60,13 @@
|
60 |
60 |
/// \tparam GR The undirected graph data structure the algorithm will run on
|
61 |
61 |
/// \tparam CAP type of the EdgeMap describing the Edge capacities.
|
62 |
62 |
/// it is typename GR::template EdgeMap<int> by default.
|
63 |
63 |
template <typename GR,
|
64 |
64 |
typename CAP = typename GR::template EdgeMap<int>
|
65 |
65 |
>
|
66 |
|
class GomoryHuTree {
|
|
66 |
class GomoryHu {
|
67 |
67 |
public:
|
68 |
68 |
|
69 |
69 |
/// The graph type
|
70 |
70 |
typedef GR Graph;
|
71 |
71 |
/// The type if the edge capacity map
|
72 |
72 |
typedef CAP Capacity;
|
... |
... |
@@ -113,24 +113,24 @@
|
113 |
113 |
|
114 |
114 |
/// \brief Constructor
|
115 |
115 |
///
|
116 |
116 |
/// Constructor
|
117 |
117 |
/// \param graph The graph the algorithm will run on.
|
118 |
118 |
/// \param capacity The capacity map.
|
119 |
|
GomoryHuTree(const Graph& graph, const Capacity& capacity)
|
|
119 |
GomoryHu(const Graph& graph, const Capacity& capacity)
|
120 |
120 |
: _graph(graph), _capacity(capacity),
|
121 |
121 |
_pred(0), _weight(0), _order(0)
|
122 |
122 |
{
|
123 |
123 |
checkConcept<concepts::ReadMap<Edge, Value>, Capacity>();
|
124 |
124 |
}
|
125 |
125 |
|
126 |
126 |
|
127 |
127 |
/// \brief Destructor
|
128 |
128 |
///
|
129 |
129 |
/// Destructor
|
130 |
|
~GomoryHuTree() {
|
|
130 |
~GomoryHu() {
|
131 |
131 |
destroyStructures();
|
132 |
132 |
}
|
133 |
133 |
|
134 |
134 |
// \brief Initialize the internal data structures.
|
135 |
135 |
//
|
136 |
136 |
// This function initializes the internal data structures.
|
... |
... |
@@ -337,35 +337,35 @@
|
337 |
337 |
|
338 |
338 |
friend class MinCutNodeIt;
|
339 |
339 |
|
340 |
340 |
/// Iterate on the nodes of a minimum cut
|
341 |
341 |
|
342 |
342 |
/// This iterator class lists the nodes of a minimum cut found by
|
343 |
|
/// GomoryHuTree. Before using it, you must allocate a GomoryHuTree class,
|
344 |
|
/// and call its \ref GomoryHuTree::run() "run()" method.
|
|
343 |
/// GomoryHu. Before using it, you must allocate a GomoryHu class,
|
|
344 |
/// and call its \ref GomoryHu::run() "run()" method.
|
345 |
345 |
///
|
346 |
346 |
/// This example counts the nodes in the minimum cut separating \c s from
|
347 |
347 |
/// \c t.
|
348 |
348 |
/// \code
|
349 |
|
/// GomoruHuTree<Graph> gom(g, capacities);
|
|
349 |
/// GomoruHu<Graph> gom(g, capacities);
|
350 |
350 |
/// gom.run();
|
351 |
351 |
/// int sum=0;
|
352 |
|
/// for(GomoruHuTree<Graph>::MinCutNodeIt n(gom,s,t);n!=INVALID;++n) ++sum;
|
|
352 |
/// for(GomoruHu<Graph>::MinCutNodeIt n(gom,s,t);n!=INVALID;++n) ++sum;
|
353 |
353 |
/// \endcode
|
354 |
354 |
class MinCutNodeIt
|
355 |
355 |
{
|
356 |
356 |
bool _side;
|
357 |
357 |
typename Graph::NodeIt _node_it;
|
358 |
358 |
typename Graph::template NodeMap<bool> _cut;
|
359 |
359 |
public:
|
360 |
360 |
/// Constructor
|
361 |
361 |
|
362 |
362 |
/// Constructor
|
363 |
363 |
///
|
364 |
|
MinCutNodeIt(GomoryHuTree const &gomory,
|
365 |
|
///< The GomoryHuTree class. You must call its
|
|
364 |
MinCutNodeIt(GomoryHu const &gomory,
|
|
365 |
///< The GomoryHu class. You must call its
|
366 |
366 |
/// run() method
|
367 |
367 |
/// before initializing this iterator
|
368 |
368 |
const Node& s, ///< Base node
|
369 |
369 |
const Node& t,
|
370 |
370 |
///< The node you want to separate from Node s.
|
371 |
371 |
bool side=true
|
... |
... |
@@ -434,26 +434,26 @@
|
434 |
434 |
|
435 |
435 |
friend class MinCutEdgeIt;
|
436 |
436 |
|
437 |
437 |
/// Iterate on the edges of a minimum cut
|
438 |
438 |
|
439 |
439 |
/// This iterator class lists the edges of a minimum cut found by
|
440 |
|
/// GomoryHuTree. Before using it, you must allocate a GomoryHuTree class,
|
441 |
|
/// and call its \ref GomoryHuTree::run() "run()" method.
|
|
440 |
/// GomoryHu. Before using it, you must allocate a GomoryHu class,
|
|
441 |
/// and call its \ref GomoryHu::run() "run()" method.
|
442 |
442 |
///
|
443 |
443 |
/// This example computes the value of the minimum cut separating \c s from
|
444 |
444 |
/// \c t.
|
445 |
445 |
/// \code
|
446 |
|
/// GomoruHuTree<Graph> gom(g, capacities);
|
|
446 |
/// GomoruHu<Graph> gom(g, capacities);
|
447 |
447 |
/// gom.run();
|
448 |
448 |
/// int value=0;
|
449 |
|
/// for(GomoruHuTree<Graph>::MinCutEdgeIt e(gom,s,t);e!=INVALID;++e)
|
|
449 |
/// for(GomoruHu<Graph>::MinCutEdgeIt e(gom,s,t);e!=INVALID;++e)
|
450 |
450 |
/// value+=capacities[e];
|
451 |
451 |
/// \endcode
|
452 |
452 |
/// the result will be the same as it is returned by
|
453 |
|
/// \ref GomoryHuTree::minCostValue() "gom.minCostValue(s,t)"
|
|
453 |
/// \ref GomoryHu::minCostValue() "gom.minCostValue(s,t)"
|
454 |
454 |
class MinCutEdgeIt
|
455 |
455 |
{
|
456 |
456 |
bool _side;
|
457 |
457 |
const Graph &_graph;
|
458 |
458 |
typename Graph::NodeIt _node_it;
|
459 |
459 |
typename Graph::OutArcIt _arc_it;
|
... |
... |
@@ -467,14 +467,14 @@
|
467 |
467 |
if(_node_it!=INVALID)
|
468 |
468 |
_arc_it=typename Graph::OutArcIt(_graph,_node_it);
|
469 |
469 |
}
|
470 |
470 |
}
|
471 |
471 |
|
472 |
472 |
public:
|
473 |
|
MinCutEdgeIt(GomoryHuTree const &gomory,
|
474 |
|
///< The GomoryHuTree class. You must call its
|
|
473 |
MinCutEdgeIt(GomoryHu const &gomory,
|
|
474 |
///< The GomoryHu class. You must call its
|
475 |
475 |
/// run() method
|
476 |
476 |
/// before initializing this iterator
|
477 |
477 |
const Node& s, ///< Base node
|
478 |
478 |
const Node& t,
|
479 |
479 |
///< The node you want to separate from Node s.
|
480 |
480 |
bool side=true
|