Test file for the min cost flow algorithms.
3 * This file is a part of LEMON, a generic C++ optimization library
5 * Copyright (C) 2003-2008
6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 * (Egervary Research Group on Combinatorial Optimization, EGRES).
9 * Permission to use, modify and distribute this software is granted
10 * provided that this copyright notice appears in all copies. For
11 * precise terms see the accompanying LICENSE file.
13 * This software is provided "AS IS" with no warranty of any kind,
14 * express or implied, and with no claim as to its suitability for any
19 #ifndef LEMON_BITS_MAP_EXTENDER_H
20 #define LEMON_BITS_MAP_EXTENDER_H
24 #include <lemon/bits/traits.h>
26 #include <lemon/concept_check.h>
27 #include <lemon/concepts/maps.h>
30 ///\brief Extenders for iterable maps.
34 /// \ingroup graphbits
36 /// \brief Extender for maps
37 template <typename _Map>
38 class MapExtender : public _Map {
42 typedef MapExtender Map;
45 typedef typename Parent::Graph Graph;
46 typedef typename Parent::Key Item;
48 typedef typename Parent::Key Key;
49 typedef typename Parent::Value Value;
55 friend class ConstMapIt;
59 MapExtender(const Graph& graph)
62 MapExtender(const Graph& graph, const Value& value)
63 : Parent(graph, value) {}
65 MapExtender& operator=(const MapExtender& cmap) {
66 return operator=<MapExtender>(cmap);
69 template <typename CMap>
70 MapExtender& operator=(const CMap& cmap) {
71 Parent::operator=(cmap);
75 class MapIt : public Item {
79 typedef typename Map::Value Value;
83 MapIt(Invalid i) : Parent(i) { }
85 explicit MapIt(Map& _map) : map(_map) {
86 map.notifier()->first(*this);
89 MapIt(const Map& _map, const Item& item)
90 : Parent(item), map(_map) {}
93 map.notifier()->next(*this);
97 typename MapTraits<Map>::ConstReturnValue operator*() const {
101 typename MapTraits<Map>::ReturnValue operator*() {
105 void set(const Value& value) {
106 map.set(*this, value);
114 class ConstMapIt : public Item {
119 typedef typename Map::Value Value;
123 ConstMapIt(Invalid i) : Parent(i) { }
125 explicit ConstMapIt(Map& _map) : map(_map) {
126 map.notifier()->first(*this);
129 ConstMapIt(const Map& _map, const Item& item)
130 : Parent(item), map(_map) {}
132 ConstMapIt& operator++() {
133 map.notifier()->next(*this);
137 typename MapTraits<Map>::ConstReturnValue operator*() const {
145 class ItemIt : public Item {
152 ItemIt(Invalid i) : Parent(i) { }
154 explicit ItemIt(Map& _map) : map(_map) {
155 map.notifier()->first(*this);
158 ItemIt(const Map& _map, const Item& item)
159 : Parent(item), map(_map) {}
161 ItemIt& operator++() {
162 map.notifier()->next(*this);
172 /// \ingroup graphbits
174 /// \brief Extender for maps which use a subset of the items.
175 template <typename _Graph, typename _Map>
176 class SubMapExtender : public _Map {
180 typedef SubMapExtender Map;
182 typedef _Graph Graph;
184 typedef typename Parent::Key Item;
186 typedef typename Parent::Key Key;
187 typedef typename Parent::Value Value;
193 friend class ConstMapIt;
197 SubMapExtender(const Graph& _graph)
198 : Parent(_graph), graph(_graph) {}
200 SubMapExtender(const Graph& _graph, const Value& _value)
201 : Parent(_graph, _value), graph(_graph) {}
203 SubMapExtender& operator=(const SubMapExtender& cmap) {
204 return operator=<MapExtender>(cmap);
207 template <typename CMap>
208 SubMapExtender& operator=(const CMap& cmap) {
209 checkConcept<concepts::ReadMap<Key, Value>, CMap>();
211 for (graph.first(it); it != INVALID; graph.next(it)) {
212 Parent::set(it, cmap[it]);
217 class MapIt : public Item {
221 typedef typename Map::Value Value;
225 MapIt(Invalid i) : Parent(i) { }
227 explicit MapIt(Map& _map) : map(_map) {
228 map.graph.first(*this);
231 MapIt(const Map& _map, const Item& item)
232 : Parent(item), map(_map) {}
234 MapIt& operator++() {
235 map.graph.next(*this);
239 typename MapTraits<Map>::ConstReturnValue operator*() const {
243 typename MapTraits<Map>::ReturnValue operator*() {
247 void set(const Value& value) {
248 map.set(*this, value);
256 class ConstMapIt : public Item {
261 typedef typename Map::Value Value;
265 ConstMapIt(Invalid i) : Parent(i) { }
267 explicit ConstMapIt(Map& _map) : map(_map) {
268 map.graph.first(*this);
271 ConstMapIt(const Map& _map, const Item& item)
272 : Parent(item), map(_map) {}
274 ConstMapIt& operator++() {
275 map.graph.next(*this);
279 typename MapTraits<Map>::ConstReturnValue operator*() const {
287 class ItemIt : public Item {
294 ItemIt(Invalid i) : Parent(i) { }
296 explicit ItemIt(Map& _map) : map(_map) {
297 map.graph.first(*this);
300 ItemIt(const Map& _map, const Item& item)
301 : Parent(item), map(_map) {}
303 ItemIt& operator++() {
304 map.graph.next(*this);