src/demo/tight_edge_filter_map.h
changeset 1153 4b0468de3a31
parent 929 882790531532
child 1164 80bb73097736
equal deleted inserted replaced
1:497120c9f1aa 2:730eb1a2a802
    29   /// which are tight w.r.t. some node_potential map and 
    29   /// which are tight w.r.t. some node_potential map and 
    30   /// edge_distance map.
    30   /// edge_distance map.
    31   ///
    31   ///
    32   /// A node-map node_potential is said to be a potential w.r.t. 
    32   /// A node-map node_potential is said to be a potential w.r.t. 
    33   /// an edge-map edge_distance 
    33   /// an edge-map edge_distance 
    34   /// if and only if for each edge e, node_potential[g.head(e)] 
    34   /// if and only if for each edge e, node_potential[g.target(e)] 
    35   /// <= edge_distance[e]+node_potential[g.tail(e)] 
    35   /// <= edge_distance[e]+node_potential[g.source(e)] 
    36   /// (or the reverse inequality holds for each edge).
    36   /// (or the reverse inequality holds for each edge).
    37   /// An edge is said to be tight if this inequality holds with equality, 
    37   /// An edge is said to be tight if this inequality holds with equality, 
    38   /// and the map returns true exactly for those edges.
    38   /// and the map returns true exactly for those edges.
    39   /// To avoid rounding errors, it is recommended to use this class with exact 
    39   /// To avoid rounding errors, it is recommended to use this class with exact 
    40   /// types, e.g. with int.
    40   /// types, e.g. with int.
    49     TightEdgeFilterMap(Graph& _g, NodePotentialMap& _node_potential, 
    49     TightEdgeFilterMap(Graph& _g, NodePotentialMap& _node_potential, 
    50 		       EdgeDistanceMap& _edge_distance) : 
    50 		       EdgeDistanceMap& _edge_distance) : 
    51       g(&_g), node_potential(&_node_potential), 
    51       g(&_g), node_potential(&_node_potential), 
    52       edge_distance(&_edge_distance) { }
    52       edge_distance(&_edge_distance) { }
    53     bool operator[](const typename Graph::Edge& e) const {
    53     bool operator[](const typename Graph::Edge& e) const {
    54       return ((*node_potential)[g->head(e)] == 
    54       return ((*node_potential)[g->target(e)] == 
    55 	      (*edge_distance)[e]+(*node_potential)[g->tail(e)]);
    55 	      (*edge_distance)[e]+(*node_potential)[g->source(e)]);
    56     }
    56     }
    57   };
    57   };
    58 
    58 
    59 } //namespace lemon
    59 } //namespace lemon
    60 
    60