src/hugo/attic/tight_edge_filter_map.h
author alpar
Wed, 29 Sep 2004 14:02:14 +0000
changeset 919 6153d9cf78c6
parent 910 src/hugo/tight_edge_filter_map.h@5a89cacf17f1
permissions -rw-r--r--
- Backport -r1227 and -r1220
- Temporarily remove (move to attic) tight_edge_filter.h
alpar@906
     1
/* -*- C++ -*-
alpar@906
     2
 * src/hugo/tight_edge_filter_map.h - Part of HUGOlib, 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
marci@888
    17
#ifndef HUGO_TIGHT_EDGE_FILTER_MAP_H
marci@888
    18
#define HUGO_TIGHT_EDGE_FILTER_MAP_H
marci@888
    19
marci@910
    20
#include <hugo/maps.h>
marci@910
    21
marci@888
    22
// /// \file
marci@888
    23
// /// \brief Maximum flow algorithms.
marci@888
    24
// /// \ingroup galgs
marci@888
    25
marci@888
    26
namespace hugo {
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 
marci@888
    34
  /// if and only if for each edge e, node_potential[g.head(e)] 
marci@888
    35
  /// <= edge_distance[e]+node_potential[g.tail(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 {
marci@888
    54
      return ((*node_potential)[g->head(e)] == 
marci@888
    55
	      (*edge_distance)[e]+(*node_potential)[g->tail(e)]);
marci@888
    56
    }
marci@888
    57
  };
marci@888
    58
marci@888
    59
} //namespace hugo
marci@888
    60
marci@888
    61
#endif //HUGO_TIGHT_EDGE_FILTER_MAP_H
marci@888
    62
marci@888
    63