lemon/graph_utils.h
changeset 1720 578d8b2b76c6
parent 1712 4fb435ad31cf
child 1729 06f939455cb1
     1.1 --- a/lemon/graph_utils.h	Fri Oct 14 10:48:34 2005 +0000
     1.2 +++ b/lemon/graph_utils.h	Fri Oct 14 10:49:51 2005 +0000
     1.3 @@ -25,6 +25,7 @@
     1.4  #include <lemon/invalid.h>
     1.5  #include <lemon/utility.h>
     1.6  #include <lemon/maps.h>
     1.7 +#include <lemon/traits.h>
     1.8  #include <lemon/bits/alteration_notifier.h>
     1.9  
    1.10  ///\ingroup gutils
    1.11 @@ -400,7 +401,6 @@
    1.12      }
    1.13    }
    1.14  
    1.15 -
    1.16    /// \brief Class to copy a graph.
    1.17    ///
    1.18    /// Class to copy a graph to an other graph (duplicate a graph). The
    1.19 @@ -515,6 +515,8 @@
    1.20        return edgeRefMap;
    1.21      }
    1.22  
    1.23 +    void run() {}
    1.24 +
    1.25    private:
    1.26      
    1.27      const Source& source;
    1.28 @@ -542,101 +544,225 @@
    1.29      return GraphCopy<Target, Source>(target, source);
    1.30    }
    1.31  
    1.32 -  template <typename _Graph, typename _Item>
    1.33 -  class ItemSetTraits {};
    1.34 -  
    1.35 -  template <typename _Graph>
    1.36 -  class ItemSetTraits<_Graph, typename _Graph::Node> {
    1.37 +  /// \brief Class to copy an undirected graph.
    1.38 +  ///
    1.39 +  /// Class to copy an undirected graph to an other graph (duplicate a graph).
    1.40 +  /// The simplest way of using it is through the \c copyUndirGraph() function.
    1.41 +  template <typename Target, typename Source>
    1.42 +  class UndirGraphCopy {
    1.43 +  public: 
    1.44 +    typedef typename Source::Node Node;
    1.45 +    typedef typename Source::NodeIt NodeIt;
    1.46 +    typedef typename Source::Edge Edge;
    1.47 +    typedef typename Source::EdgeIt EdgeIt;
    1.48 +    typedef typename Source::UndirEdge UndirEdge;
    1.49 +    typedef typename Source::UndirEdgeIt UndirEdgeIt;
    1.50 +
    1.51 +    typedef typename Source::
    1.52 +    template NodeMap<typename Target::Node> NodeRefMap;
    1.53 +    
    1.54 +    typedef typename Source::
    1.55 +    template UndirEdgeMap<typename Target::UndirEdge> UndirEdgeRefMap;
    1.56 +
    1.57 +  private:
    1.58 +
    1.59 +    struct EdgeRefMap {
    1.60 +      EdgeRefMap(UndirGraphCopy& _gc) : gc(_gc) {}
    1.61 +      typedef typename Source::Edge Key;
    1.62 +      typedef typename Target::Edge Value;
    1.63 +
    1.64 +      Value operator[](const Key& key) {
    1.65 +	return gc.target.direct(gc.undirEdgeRef[key], 
    1.66 +				gc.target.direction(key));
    1.67 +      }
    1.68 +      
    1.69 +      UndirGraphCopy& gc;
    1.70 +    };
    1.71 +    
    1.72    public:
    1.73 +
    1.74 +    /// \brief Constructor for the UndirGraphCopy.
    1.75 +    ///
    1.76 +    /// It copies the content of the \c _source graph into the
    1.77 +    /// \c _target graph. It creates also two references, one beetween
    1.78 +    /// the two nodeset and one beetween the two edgesets.
    1.79 +    UndirGraphCopy(Target& _target, const Source& _source) 
    1.80 +      : source(_source), target(_target), 
    1.81 +	nodeRefMap(_source), edgeRefMap(*this), undirEdgeRefMap(_source) {
    1.82 +      for (NodeIt it(source); it != INVALID; ++it) {
    1.83 +	nodeRefMap[it] = target.addNode();
    1.84 +      }
    1.85 +      for (UndirEdgeIt it(source); it != INVALID; ++it) {
    1.86 +	undirEdgeRefMap[it] = target.addEdge(nodeRefMap[source.source(it)], 
    1.87 +					nodeRefMap[source.target(it)]);
    1.88 +      }
    1.89 +    }
    1.90 +
    1.91 +    /// \brief Copies the node references into the given map.
    1.92 +    ///
    1.93 +    /// Copies the node references into the given map.
    1.94 +    template <typename NodeRef>
    1.95 +    const UndirGraphCopy& nodeRef(NodeRef& map) const {
    1.96 +      for (NodeIt it(source); it != INVALID; ++it) {
    1.97 +	map.set(it, nodeRefMap[it]);
    1.98 +      }
    1.99 +      return *this;
   1.100 +    }
   1.101 +
   1.102 +    /// \brief Reverse and copies the node references into the given map.
   1.103 +    ///
   1.104 +    /// Reverse and copies the node references into the given map.
   1.105 +    template <typename NodeRef>
   1.106 +    const UndirGraphCopy& nodeCrossRef(NodeRef& map) const {
   1.107 +      for (NodeIt it(source); it != INVALID; ++it) {
   1.108 +	map.set(nodeRefMap[it], it);
   1.109 +      }
   1.110 +      return *this;
   1.111 +    }
   1.112 +
   1.113 +    /// \brief Copies the edge references into the given map.
   1.114 +    ///
   1.115 +    /// Copies the edge references into the given map.
   1.116 +    template <typename EdgeRef>
   1.117 +    const UndirGraphCopy& edgeRef(EdgeRef& map) const {
   1.118 +      for (EdgeIt it(source); it != INVALID; ++it) {
   1.119 +	map.set(edgeRefMap[it], it);
   1.120 +      }
   1.121 +      return *this;
   1.122 +    }
   1.123 +
   1.124 +    /// \brief Reverse and copies the undirected edge references into the 
   1.125 +    /// given map.
   1.126 +    ///
   1.127 +    /// Reverse and copies the undirected edge references into the given map.
   1.128 +    template <typename EdgeRef>
   1.129 +    const UndirGraphCopy& edgeCrossRef(EdgeRef& map) const {
   1.130 +      for (EdgeIt it(source); it != INVALID; ++it) {
   1.131 +	map.set(it, edgeRefMap[it]);
   1.132 +      }
   1.133 +      return *this;
   1.134 +    }
   1.135 +
   1.136 +    /// \brief Copies the undirected edge references into the given map.
   1.137 +    ///
   1.138 +    /// Copies the undirected edge references into the given map.
   1.139 +    template <typename EdgeRef>
   1.140 +    const UndirGraphCopy& undirEdgeRef(EdgeRef& map) const {
   1.141 +      for (UndirEdgeIt it(source); it != INVALID; ++it) {
   1.142 +	map.set(it, undirEdgeRefMap[it]);
   1.143 +      }
   1.144 +      return *this;
   1.145 +    }
   1.146 +
   1.147 +    /// \brief Reverse and copies the undirected edge references into the 
   1.148 +    /// given map.
   1.149 +    ///
   1.150 +    /// Reverse and copies the undirected edge references into the given map.
   1.151 +    template <typename EdgeRef>
   1.152 +    const UndirGraphCopy& undirEdgeCrossRef(EdgeRef& map) const {
   1.153 +      for (UndirEdgeIt it(source); it != INVALID; ++it) {
   1.154 +	map.set(undirEdgeRefMap[it], it);
   1.155 +      }
   1.156 +      return *this;
   1.157 +    }
   1.158 +
   1.159 +    /// \brief Make copy of the given map.
   1.160 +    ///
   1.161 +    /// Makes copy of the given map for the newly created graph. 
   1.162 +    /// The new map's key type is the target graph's node type,
   1.163 +    /// and the copied map's key type is the source graph's node
   1.164 +    /// type.  
   1.165 +    template <typename TargetMap, typename SourceMap>
   1.166 +    const UndirGraphCopy& nodeMap(TargetMap& tMap, 
   1.167 +				  const SourceMap& sMap) const {
   1.168 +      copyMap(tMap, sMap, NodeIt(source), nodeRefMap);
   1.169 +      return *this;
   1.170 +    }
   1.171 +
   1.172 +    /// \brief Make copy of the given map.
   1.173 +    ///
   1.174 +    /// Makes copy of the given map for the newly created graph. 
   1.175 +    /// The new map's key type is the target graph's edge type,
   1.176 +    /// and the copied map's key type is the source graph's edge
   1.177 +    /// type.  
   1.178 +    template <typename TargetMap, typename SourceMap>
   1.179 +    const UndirGraphCopy& edgeMap(TargetMap& tMap, 
   1.180 +				  const SourceMap& sMap) const {
   1.181 +      copyMap(tMap, sMap, EdgeIt(source), edgeRefMap);
   1.182 +      return *this;
   1.183 +    }
   1.184 +
   1.185 +    /// \brief Make copy of the given map.
   1.186 +    ///
   1.187 +    /// Makes copy of the given map for the newly created graph. 
   1.188 +    /// The new map's key type is the target graph's edge type,
   1.189 +    /// and the copied map's key type is the source graph's edge
   1.190 +    /// type.  
   1.191 +    template <typename TargetMap, typename SourceMap>
   1.192 +    const UndirGraphCopy& undirEdgeMap(TargetMap& tMap, 
   1.193 +				  const SourceMap& sMap) const {
   1.194 +      copyMap(tMap, sMap, UndirEdgeIt(source), undirEdgeRefMap);
   1.195 +      return *this;
   1.196 +    }
   1.197 +
   1.198 +    /// \brief Gives back the stored node references.
   1.199 +    ///
   1.200 +    /// Gives back the stored node references.
   1.201 +    const NodeRefMap& nodeRef() const {
   1.202 +      return nodeRefMap;
   1.203 +    }
   1.204 +
   1.205 +    /// \brief Gives back the stored edge references.
   1.206 +    ///
   1.207 +    /// Gives back the stored edge references.
   1.208 +    const EdgeRefMap& edgeRef() const {
   1.209 +      return edgeRefMap;
   1.210 +    }
   1.211 +
   1.212 +    /// \brief Gives back the stored undir edge references.
   1.213 +    ///
   1.214 +    /// Gives back the stored undir edge references.
   1.215 +    const UndirEdgeRefMap& undirEdgeRef() const {
   1.216 +      return undirEdgeRefMap;
   1.217 +    }
   1.218 +
   1.219 +    void run() {}
   1.220 +
   1.221 +  private:
   1.222      
   1.223 -    typedef _Graph Graph;
   1.224 +    const Source& source;
   1.225 +    Target& target;
   1.226  
   1.227 -    typedef typename Graph::Node Item;
   1.228 -    typedef typename Graph::NodeIt ItemIt;
   1.229 -
   1.230 -    template <typename _Value>
   1.231 -    class Map : public Graph::template NodeMap<_Value> {
   1.232 -    public:
   1.233 -      typedef typename Graph::template NodeMap<_Value> Parent; 
   1.234 -      typedef typename Parent::Value Value;
   1.235 -
   1.236 -      Map(const Graph& _graph) : Parent(_graph) {}
   1.237 -      Map(const Graph& _graph, const Value& _value) 
   1.238 -	: Parent(_graph, _value) {}
   1.239 -    };
   1.240 -
   1.241 +    NodeRefMap nodeRefMap;
   1.242 +    EdgeRefMap edgeRefMap;
   1.243 +    UndirEdgeRefMap undirEdgeRefMap;
   1.244    };
   1.245  
   1.246 -  template <typename _Graph>
   1.247 -  class ItemSetTraits<_Graph, typename _Graph::Edge> {
   1.248 -  public:
   1.249 -    
   1.250 -    typedef _Graph Graph;
   1.251 +  /// \brief Copy a graph to an other graph.
   1.252 +  ///
   1.253 +  /// Copy a graph to an other graph.
   1.254 +  /// The usage of the function:
   1.255 +  /// 
   1.256 +  /// \code
   1.257 +  /// copyGraph(trg, src).nodeRef(nr).edgeCrossRef(ecr);
   1.258 +  /// \endcode
   1.259 +  /// 
   1.260 +  /// After the copy the \c nr map will contain the mapping from the
   1.261 +  /// source graph's nodes to the target graph's nodes and the \c ecr will
   1.262 +  /// contain the mapping from the target graph's edges to the source's
   1.263 +  /// edges.
   1.264 +  template <typename Target, typename Source>
   1.265 +  UndirGraphCopy<Target, Source> 
   1.266 +  copyUndirGraph(Target& target, const Source& source) {
   1.267 +    return UndirGraphCopy<Target, Source>(target, source);
   1.268 +  }
   1.269  
   1.270 -    typedef typename Graph::Edge Item;
   1.271 -    typedef typename Graph::EdgeIt ItemIt;
   1.272 -
   1.273 -    template <typename _Value>
   1.274 -    class Map : public Graph::template EdgeMap<_Value> {
   1.275 -    public:
   1.276 -      typedef typename Graph::template EdgeMap<_Value> Parent; 
   1.277 -      typedef typename Parent::Value Value;
   1.278 -
   1.279 -      Map(const Graph& _graph) : Parent(_graph) {}
   1.280 -      Map(const Graph& _graph, const Value& _value) 
   1.281 -	: Parent(_graph, _value) {}
   1.282 -    };
   1.283 -
   1.284 -  };
   1.285 -
   1.286 -  template <typename _Graph>
   1.287 -  class ItemSetTraits<_Graph, typename _Graph::UndirEdge> {
   1.288 -  public:
   1.289 -    
   1.290 -    typedef _Graph Graph;
   1.291 -
   1.292 -    typedef typename Graph::UndirEdge Item;
   1.293 -    typedef typename Graph::UndirEdgeIt ItemIt;
   1.294 -
   1.295 -    template <typename _Value>
   1.296 -    class Map : public Graph::template UndirEdgeMap<_Value> {
   1.297 -    public:
   1.298 -      typedef typename Graph::template UndirEdgeMap<_Value> Parent; 
   1.299 -      typedef typename Parent::Value Value;
   1.300 -
   1.301 -      Map(const Graph& _graph) : Parent(_graph) {}
   1.302 -      Map(const Graph& _graph, const Value& _value) 
   1.303 -	: Parent(_graph, _value) {}
   1.304 -    };
   1.305 -
   1.306 -  };
   1.307  
   1.308    /// @}
   1.309  
   1.310    /// \addtogroup graph_maps
   1.311    /// @{
   1.312  
   1.313 -  template <typename Map, typename Enable = void>
   1.314 -  struct ReferenceMapTraits {
   1.315 -    typedef typename Map::Value Value;
   1.316 -    typedef typename Map::Value& Reference;
   1.317 -    typedef const typename Map::Value& ConstReference;
   1.318 -    typedef typename Map::Value* Pointer;
   1.319 -    typedef const typename Map::Value* ConstPointer;
   1.320 -  };
   1.321 -
   1.322 -  template <typename Map>
   1.323 -  struct ReferenceMapTraits<
   1.324 -    Map, 
   1.325 -    typename enable_if<typename Map::FullTypeTag, void>::type
   1.326 -  > {
   1.327 -    typedef typename Map::Value Value;
   1.328 -    typedef typename Map::Reference Reference;
   1.329 -    typedef typename Map::ConstReference ConstReference;
   1.330 -    typedef typename Map::Pointer Pointer;
   1.331 -    typedef typename Map::ConstPointer ConstPointer;
   1.332 -  };
   1.333 -
   1.334    /// Provides an immutable and unique id for each item in the graph.
   1.335  
   1.336    /// The IdMap class provides a unique and immutable id for each item of the
   1.337 @@ -754,7 +880,7 @@
   1.338      /// \brief The getter function of the map.
   1.339      ///
   1.340      /// It gives back the value associated with the key.
   1.341 -    const Value operator[](const Key& key) const {
   1.342 +    Value operator[](const Key& key) const {
   1.343        return Map::operator[](key);
   1.344      }
   1.345  
   1.346 @@ -1192,234 +1318,6 @@
   1.347      return PotentialDifferenceMap<Graph, NodeMap>(graph, potential);
   1.348    }
   1.349  
   1.350 -  /// \brief Container for store values for each ordered pair of nodes
   1.351 -  ///
   1.352 -  /// Container for store values for each ordered pair of nodes.
   1.353 -  template <typename _Graph, typename _Value>
   1.354 -  class NodeMatrixMap 
   1.355 -    : protected AlterationNotifier<typename _Graph::Node>::ObserverBase {
   1.356 -  public:
   1.357 -    typedef _Graph Graph;
   1.358 -    typedef typename Graph::Node Node;
   1.359 -    typedef Node Key;
   1.360 -    typedef _Value Value;
   1.361 -
   1.362 -    /// \brief Creates a node matrix for the given graph
   1.363 -    ///
   1.364 -    /// Creates a node matrix for the given graph.
   1.365 -    NodeMatrixMap(const Graph& _graph) 
   1.366 -      : graph(_graph), values(size(_graph.maxId(Node()) + 1)) {}
   1.367 -
   1.368 -    /// \brief Creates a node matrix for the given graph
   1.369 -    ///
   1.370 -    /// Creates a node matrix for the given graph and assigns each
   1.371 -    /// initial value to the given parameter.
   1.372 -    NodeMatrixMap(const Graph& _graph, const Value& _val) 
   1.373 -      : graph(_graph), values(size(_graph.maxId(Node()) + 1), _val) {}
   1.374 -
   1.375 -    /// \brief Gives back the value assigned to the \c left - \c right
   1.376 -    /// ordered pair.
   1.377 -    ///
   1.378 -    /// Gives back the value assigned to the \c left - \c right ordered pair.
   1.379 -    const Value& operator()(const Node& left, const Node& right) const {
   1.380 -      return values[index(graph.id(left), graph.id(right))];
   1.381 -    }
   1.382 -    
   1.383 -    /// \brief Gives back the value assigned to the \c left - \c right
   1.384 -    /// ordered pair.
   1.385 -    ///
   1.386 -    /// Gives back the value assigned to the \c left - \c right ordered pair.
   1.387 -    Value& operator()(const Node& left, const Node& right) {
   1.388 -      return values[index(graph.id(left), graph.id(right))];
   1.389 -    }
   1.390 -
   1.391 -    /// \brief Setter function for the matrix map.
   1.392 -    ///
   1.393 -    /// Setter function for the matrix map.
   1.394 -    void set(const Node& left, const Node& right, const Value& val) {
   1.395 -      values[index(graph.id(left), graph.id(right))] = val;
   1.396 -    }
   1.397 -
   1.398 -    /// \brief Map for the coloumn view of the matrix
   1.399 -    ///
   1.400 -    /// Map for the coloumn view of the matrix.
   1.401 -    class ColMap : public MapBase<Node, Value> {
   1.402 -      friend class NodeMatrixMap;
   1.403 -    private:
   1.404 -      ColMap(NodeMatrixMap& _matrix, Node _col) 
   1.405 -	: matrix(_matrix), col(_col) {}
   1.406 -
   1.407 -    public:
   1.408 -      /// \brief Subscription operator
   1.409 -      ///
   1.410 -      /// Subscription operator.
   1.411 -      Value& operator[](Node row) {
   1.412 -	return matrix(col, row);
   1.413 -      }
   1.414 -
   1.415 -      /// \brief Setter function
   1.416 -      ///
   1.417 -      /// Setter function.
   1.418 -      void set(Node row, const Value& val) {
   1.419 -	matrix.set(col, row, val);
   1.420 -      }
   1.421 -      
   1.422 -      /// \brief Subscription operator
   1.423 -      ///
   1.424 -      /// Subscription operator.
   1.425 -      const Value& operator[](Node row) const {
   1.426 -	return matrix(col, row);
   1.427 -      }
   1.428 -
   1.429 -    private:
   1.430 -      NodeMatrixMap& matrix;
   1.431 -      Node col;
   1.432 -    };
   1.433 -
   1.434 -    /// \brief Map for the const coloumn view of the matrix
   1.435 -    ///
   1.436 -    /// Map for the const coloumn view of the matrix.
   1.437 -    class ConstColMap : public MapBase<Node, Value> {
   1.438 -      friend class NodeMatrixMap;
   1.439 -    private:
   1.440 -      ConstColMap(const NodeMatrixMap& _matrix, Node _col) 
   1.441 -	: matrix(_matrix), col(_col) {}
   1.442 -      
   1.443 -    public:
   1.444 -      /// \brief Subscription operator
   1.445 -      ///
   1.446 -      /// Subscription operator.
   1.447 -      const Value& operator[](Node row) const {
   1.448 -	return matrix(col, row);
   1.449 -      }
   1.450 -      
   1.451 -    private:
   1.452 -      const NodeMatrixMap& matrix;
   1.453 -      Node col;
   1.454 -    };
   1.455 -
   1.456 -    /// \brief Map for the row view of the matrix
   1.457 -    ///
   1.458 -    /// Map for the row view of the matrix.
   1.459 -    class RowMap : public MapBase<Node, Value> {
   1.460 -    public:
   1.461 -      friend class NodeMatrixMap;
   1.462 -    private:
   1.463 -      RowMap(NodeMatrixMap& _matrix, Node _row) 
   1.464 -	: matrix(_matrix), row(_row) {}
   1.465 -      
   1.466 -    public:
   1.467 -      /// \brief Subscription operator
   1.468 -      ///
   1.469 -      /// Subscription operator.
   1.470 -      Value& operator[](Node col) {
   1.471 -	return matrix(col, row);
   1.472 -      }
   1.473 -
   1.474 -      /// \brief Setter function
   1.475 -      ///
   1.476 -      /// Setter function.
   1.477 -      void set(Node col, const Value& val) {
   1.478 -	matrix.set(col, row, val);
   1.479 -      }
   1.480 -      
   1.481 -      /// \brief Subscription operator
   1.482 -      ///
   1.483 -      /// Subscription operator.
   1.484 -      const Value& operator[](Node col) const {
   1.485 -	return matrix(col, row);
   1.486 -      }
   1.487 -
   1.488 -    private:
   1.489 -      NodeMatrixMap& matrix;
   1.490 -      Node row;
   1.491 -    };
   1.492 -
   1.493 -    /// \brief Map for the const row view of the matrix
   1.494 -    ///
   1.495 -    /// Map for the row const view of the matrix.
   1.496 -    class ConstRowMap : public MapBase<Node, Value> {
   1.497 -    public:
   1.498 -      friend class NodeMatrixMap;
   1.499 -    private:
   1.500 -      ConstRowMap(const NodeMatrixMap& _matrix, Node _row) 
   1.501 -	: matrix(_matrix), row(_row) {}
   1.502 -      
   1.503 -    public:
   1.504 -      /// \brief Subscription operator
   1.505 -      ///
   1.506 -      /// Subscription operator.
   1.507 -      const Value& operator[](Node col) const {
   1.508 -	return matrix(col, row);
   1.509 -      }
   1.510 -      
   1.511 -    private:
   1.512 -      const NodeMatrixMap& matrix;
   1.513 -      Node row;
   1.514 -    };
   1.515 -
   1.516 -    /// \brief Gives back the column view for the given node
   1.517 -    ///
   1.518 -    /// Gives back the column view for the given node
   1.519 -    ConstColMap operator[](Node col) const { return ConstColMap(*this, col); }
   1.520 -    /// \brief Gives back the column view for the given node
   1.521 -    ///
   1.522 -    /// Gives back the column view for the given node
   1.523 -    ColMap operator[](Node col) { return ColMap(*this, col); }
   1.524 -
   1.525 -    /// \brief Gives back the column view for the given node
   1.526 -    ///
   1.527 -    /// Gives back the column view for the given node
   1.528 -    ConstColMap colMap(Node col) const { return ConstColMap(*this, col); }
   1.529 -    /// \brief Gives back the column view for the given node
   1.530 -    ///
   1.531 -    /// Gives back the column view for the given node
   1.532 -    ColMap colMap(Node col) { return ColMap(*this, col); }
   1.533 -
   1.534 -    /// \brief Gives back the row view for the given node
   1.535 -    ///
   1.536 -    /// Gives back the row view for the given node
   1.537 -    ConstRowMap rowMap(Node row) const { return ConstRowMap(*this, row); }
   1.538 -    /// \brief Gives back the row view for the given node
   1.539 -    ///
   1.540 -    /// Gives back the row view for the given node
   1.541 -    RowMap rowMap(Node row) { return RowMap(*this, row); }
   1.542 -
   1.543 -  protected:
   1.544 -
   1.545 -    static int index(int i, int j) {
   1.546 -      if (i < j) {
   1.547 -	return j * j + i;
   1.548 -      } else {
   1.549 -	return i * i + i + j;
   1.550 -      }
   1.551 -    }
   1.552 -
   1.553 -    static int size(int s) {
   1.554 -      return s * s;
   1.555 -    }
   1.556 -
   1.557 -    void add(const Node& node) {
   1.558 -      if (size(graph.id(node) + 1) >= (int)values.size()) {
   1.559 -	values.resize(size(graph.id(node) + 1));	
   1.560 -      }
   1.561 -    }
   1.562 -
   1.563 -    void erase(const Node&) {}
   1.564 -
   1.565 -    void build() {
   1.566 -      values.resize(size(graph.maxId(Node()) + 1));
   1.567 -    }
   1.568 -
   1.569 -    void clear() {
   1.570 -      values.clear();
   1.571 -    }   
   1.572 -    
   1.573 -  private:
   1.574 -    const Graph& graph;
   1.575 -    std::vector<Value> values;
   1.576 -  };
   1.577 -
   1.578    /// \brief Map of the node in-degrees.
   1.579    ///
   1.580    /// This map returns the in-degree of a node. Once it is constructed,
   1.581 @@ -1427,14 +1325,6 @@
   1.582    /// in constant time. On the other hand, the values are updated automatically
   1.583    /// whenever the graph changes.
   1.584    ///
   1.585 -  /// \warning Besides addNode() and addEdge(), a graph structure may provide
   1.586 -  /// alternative ways to mogify the graph. The correct behavior of InDegMap
   1.587 -  /// is not guarantied if these additional featureas are used. For example
   1.588 -  /// the funstions \ref ListGraph::changeSource() "changeSource()",
   1.589 -  /// \ref ListGraph::changeTarget() "changeTarget()" and
   1.590 -  /// \ref ListGraph::reverseEdge() "reverseEdge()"
   1.591 -  /// of \ref ListGraph will \e not update the degree values correctly.
   1.592 -  ///
   1.593    /// \sa OutDegMap
   1.594  
   1.595    template <typename _Graph>
   1.596 @@ -1501,6 +1391,13 @@
   1.597        --deg[graph.target(edge)];
   1.598      }
   1.599  
   1.600 +    virtual void signalChange(const Edge& edge) {
   1.601 +      erase(edge);
   1.602 +    }
   1.603 +
   1.604 +    virtual void commitChange(const Edge& edge) {
   1.605 +      add(edge);
   1.606 +    }
   1.607  
   1.608      virtual void build() {
   1.609        for(typename _Graph::NodeIt it(graph); it != INVALID; ++it) {
   1.610 @@ -1526,14 +1423,6 @@
   1.611    /// in constant time. On the other hand, the values are updated automatically
   1.612    /// whenever the graph changes.
   1.613    ///
   1.614 -  /// \warning Besides addNode() and addEdge(), a graph structure may provide
   1.615 -  /// alternative ways to mogify the graph. The correct behavior of OutDegMap
   1.616 -  /// is not guarantied if these additional featureas are used. For example
   1.617 -  /// the funstions \ref ListGraph::changeSource() "changeSource()",
   1.618 -  /// \ref ListGraph::changeTarget() "changeTarget()" and
   1.619 -  /// \ref ListGraph::reverseEdge() "reverseEdge()"
   1.620 -  /// of \ref ListGraph will \e not update the degree values correctly.
   1.621 -  ///
   1.622    /// \sa InDegMap
   1.623  
   1.624    template <typename _Graph>
   1.625 @@ -1600,6 +1489,14 @@
   1.626        --deg[graph.source(edge)];
   1.627      }
   1.628  
   1.629 +    virtual void signalChange(const Edge& edge) {
   1.630 +      erase(edge);
   1.631 +    }
   1.632 +
   1.633 +    virtual void commitChange(const Edge& edge) {
   1.634 +      add(edge);
   1.635 +    }
   1.636 +
   1.637  
   1.638      virtual void build() {
   1.639        for(typename _Graph::NodeIt it(graph); it != INVALID; ++it) {
   1.640 @@ -1618,47 +1515,6 @@
   1.641      AutoNodeMap deg;
   1.642    };
   1.643  
   1.644 -  // Indicators for the tags
   1.645 -
   1.646 -  template <typename Graph, typename Enable = void>
   1.647 -  struct NodeNumTagIndicator {
   1.648 -    static const bool value = false;
   1.649 -  };
   1.650 -
   1.651 -  template <typename Graph>
   1.652 -  struct NodeNumTagIndicator<
   1.653 -    Graph, 
   1.654 -    typename enable_if<typename Graph::NodeNumTag, void>::type
   1.655 -  > {
   1.656 -    static const bool value = true;
   1.657 -  };
   1.658 -
   1.659 -  template <typename Graph, typename Enable = void>
   1.660 -  struct EdgeNumTagIndicator {
   1.661 -    static const bool value = false;
   1.662 -  };
   1.663 -
   1.664 -  template <typename Graph>
   1.665 -  struct EdgeNumTagIndicator<
   1.666 -    Graph, 
   1.667 -    typename enable_if<typename Graph::EdgeNumTag, void>::type
   1.668 -  > {
   1.669 -    static const bool value = true;
   1.670 -  };
   1.671 -
   1.672 -  template <typename Graph, typename Enable = void>
   1.673 -  struct FindEdgeTagIndicator {
   1.674 -    static const bool value = false;
   1.675 -  };
   1.676 -
   1.677 -  template <typename Graph>
   1.678 -  struct FindEdgeTagIndicator<
   1.679 -    Graph, 
   1.680 -    typename enable_if<typename Graph::FindEdgeTag, void>::type
   1.681 -  > {
   1.682 -    static const bool value = true;
   1.683 -  };
   1.684 -
   1.685  
   1.686    /// @}
   1.687