alpar@906
|
1 |
/* -*- C++ -*-
|
alpar@921
|
2 |
* src/lemon/tight_edge_filter_map.h - Part of LEMON, a generic C++ optimization library
|
alpar@906
|
3 |
*
|
alpar@906
|
4 |
* Copyright (C) 2004 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
|
alpar@906
|
5 |
* (Egervary Combinatorial Optimization Research Group, EGRES).
|
alpar@906
|
6 |
*
|
alpar@906
|
7 |
* Permission to use, modify and distribute this software is granted
|
alpar@906
|
8 |
* provided that this copyright notice appears in all copies. For
|
alpar@906
|
9 |
* precise terms see the accompanying LICENSE file.
|
alpar@906
|
10 |
*
|
alpar@906
|
11 |
* This software is provided "AS IS" with no warranty of any kind,
|
alpar@906
|
12 |
* express or implied, and with no claim as to its suitability for any
|
alpar@906
|
13 |
* purpose.
|
alpar@906
|
14 |
*
|
alpar@906
|
15 |
*/
|
alpar@906
|
16 |
|
alpar@921
|
17 |
#ifndef LEMON_TIGHT_EDGE_FILTER_MAP_H
|
alpar@921
|
18 |
#define LEMON_TIGHT_EDGE_FILTER_MAP_H
|
marci@888
|
19 |
|
alpar@921
|
20 |
#include <lemon/maps.h>
|
marci@910
|
21 |
|
marci@888
|
22 |
// /// \file
|
marci@888
|
23 |
// /// \brief Maximum flow algorithms.
|
marci@888
|
24 |
// /// \ingroup galgs
|
marci@888
|
25 |
|
alpar@921
|
26 |
namespace lemon {
|
marci@888
|
27 |
|
marci@888
|
28 |
/// \brief A map for filtering the edge-set to those edges
|
marci@888
|
29 |
/// which are tight w.r.t. some node_potential map and
|
marci@888
|
30 |
/// edge_distance map.
|
marci@888
|
31 |
///
|
marci@888
|
32 |
/// A node-map node_potential is said to be a potential w.r.t.
|
marci@888
|
33 |
/// an edge-map edge_distance
|
alpar@986
|
34 |
/// if and only if for each edge e, node_potential[g.target(e)]
|
alpar@986
|
35 |
/// <= edge_distance[e]+node_potential[g.source(e)]
|
marci@888
|
36 |
/// (or the reverse inequality holds for each edge).
|
marci@888
|
37 |
/// An edge is said to be tight if this inequality holds with equality,
|
marci@888
|
38 |
/// and the map returns true exactly for those edges.
|
marci@888
|
39 |
/// To avoid rounding errors, it is recommended to use this class with exact
|
marci@888
|
40 |
/// types, e.g. with int.
|
marci@888
|
41 |
template<typename Graph,
|
marci@888
|
42 |
typename NodePotentialMap, typename EdgeDistanceMap>
|
marci@910
|
43 |
class TightEdgeFilterMap : public MapBase<typename Graph::Edge, bool> {
|
marci@888
|
44 |
protected:
|
marci@888
|
45 |
const Graph* g;
|
marci@888
|
46 |
NodePotentialMap* node_potential;
|
marci@888
|
47 |
EdgeDistanceMap* edge_distance;
|
marci@888
|
48 |
public:
|
marci@888
|
49 |
TightEdgeFilterMap(Graph& _g, NodePotentialMap& _node_potential,
|
marci@888
|
50 |
EdgeDistanceMap& _edge_distance) :
|
marci@888
|
51 |
g(&_g), node_potential(&_node_potential),
|
marci@888
|
52 |
edge_distance(&_edge_distance) { }
|
marci@888
|
53 |
bool operator[](const typename Graph::Edge& e) const {
|
alpar@986
|
54 |
return ((*node_potential)[g->target(e)] ==
|
alpar@986
|
55 |
(*edge_distance)[e]+(*node_potential)[g->source(e)]);
|
marci@888
|
56 |
}
|
marci@888
|
57 |
};
|
marci@888
|
58 |
|
alpar@921
|
59 |
} //namespace lemon
|
marci@888
|
60 |
|
alpar@921
|
61 |
#endif //LEMON_TIGHT_EDGE_FILTER_MAP_H
|
marci@888
|
62 |
|
marci@888
|
63 |
|