src/demo/tight_edge_filter_map.h
author marci
Thu, 16 Sep 2004 14:01:36 +0000
changeset 868 805963ea8654
parent 863 src/work/marci/tight_edge_filter_map.h@d27bbe17b0b8
permissions -rw-r--r--
This is needed for the demo.
marci@762
     1
// -*- C++ -*-
marci@863
     2
#ifndef HUGO_TIGHT_EDGE_FILTER_MAP_H
marci@863
     3
#define HUGO_TIGHT_EDGE_FILTER_MAP_H
marci@762
     4
marci@863
     5
// /// \file
marci@863
     6
// /// \brief Maximum flow algorithms.
marci@863
     7
// /// \ingroup galgs
marci@762
     8
marci@762
     9
namespace hugo {
marci@762
    10
marci@862
    11
  /// \brief A map for filtering the edge-set to those edges 
marci@862
    12
  /// which are tight w.r.t. some node_potential map and 
marci@862
    13
  /// edge_distance map.
marci@862
    14
  ///
marci@862
    15
  /// A node-map node_potential is said to be a potential w.r.t. 
marci@862
    16
  /// an edge-map edge_distance 
marci@862
    17
  /// if and only if for each edge e, node_potential[g.head(e)] 
marci@862
    18
  /// <= edge_distance[e]+node_potential[g.tail(e)] 
marci@862
    19
  /// (or the reverse inequality holds for each edge).
marci@862
    20
  /// An edge is said to be tight if this inequality holds with equality, 
marci@862
    21
  /// and the map returns true exactly for those edges.
marci@862
    22
  /// To avoid rounding errors, it is recommended to use this class with exact 
marci@862
    23
  /// types, e.g. with int.
marci@862
    24
  template<typename Graph, 
marci@862
    25
	   typename NodePotentialMap, typename EdgeDistanceMap>
marci@862
    26
  class TightEdgeFilterMap {
marci@862
    27
  protected:
marci@862
    28
    const Graph* g;
marci@862
    29
    NodePotentialMap* node_potential;
marci@862
    30
    EdgeDistanceMap* edge_distance;
marci@862
    31
  public:
marci@862
    32
    TightEdgeFilterMap(Graph& _g, NodePotentialMap& _node_potential, 
marci@862
    33
		       EdgeDistanceMap& _edge_distance) : 
marci@862
    34
      g(&_g), node_potential(&_node_potential), 
marci@862
    35
      edge_distance(&_edge_distance) { }
marci@862
    36
    bool operator[](const typename Graph::Edge& e) const {
marci@862
    37
      return ((*node_potential)[g->head(e)] == 
marci@862
    38
	      (*edge_distance)[e]+(*node_potential)[g->tail(e)]);
marci@862
    39
    }
marci@862
    40
  };
marci@862
    41
marci@762
    42
} //namespace hugo
marci@762
    43
marci@863
    44
#endif //HUGO_TIGHT_EDGE_FILTER_MAP_H
marci@762
    45
marci@762
    46