gravatar
alpar (Alpar Juttner)
alpar@cs.elte.hu
Merge
1 4 1
merge default
3 files changed with 880 insertions and 355 deletions:
↑ Collapse diff ↑
Ignore white space 1536 line context
... ...
@@ -1901,1706 +1901,1705 @@
1901 1901
        a._forward = true;
1902 1902
      }
1903 1903
    }
1904 1904
    void nextOut(Arc &a) const {
1905 1905
      if (!a._forward) {
1906 1906
        Node n = _digraph->target(a);
1907 1907
        _digraph->nextIn(a);
1908 1908
        if (static_cast<const Edge&>(a) == INVALID ) {
1909 1909
          _digraph->firstOut(a, n);
1910 1910
          a._forward = true;
1911 1911
        }
1912 1912
      }
1913 1913
      else {
1914 1914
        _digraph->nextOut(a);
1915 1915
      }
1916 1916
    }
1917 1917

	
1918 1918
    void firstIn(Arc &a, const Node &n) const {
1919 1919
      _digraph->firstOut(a, n);
1920 1920
      if (static_cast<const Edge&>(a) != INVALID ) {
1921 1921
        a._forward = false;
1922 1922
      } else {
1923 1923
        _digraph->firstIn(a, n);
1924 1924
        a._forward = true;
1925 1925
      }
1926 1926
    }
1927 1927
    void nextIn(Arc &a) const {
1928 1928
      if (!a._forward) {
1929 1929
        Node n = _digraph->source(a);
1930 1930
        _digraph->nextOut(a);
1931 1931
        if( static_cast<const Edge&>(a) == INVALID ) {
1932 1932
          _digraph->firstIn(a, n);
1933 1933
          a._forward = true;
1934 1934
        }
1935 1935
      }
1936 1936
      else {
1937 1937
        _digraph->nextIn(a);
1938 1938
      }
1939 1939
    }
1940 1940

	
1941 1941
    void firstInc(Edge &e, bool &d, const Node &n) const {
1942 1942
      d = true;
1943 1943
      _digraph->firstOut(e, n);
1944 1944
      if (e != INVALID) return;
1945 1945
      d = false;
1946 1946
      _digraph->firstIn(e, n);
1947 1947
    }
1948 1948

	
1949 1949
    void nextInc(Edge &e, bool &d) const {
1950 1950
      if (d) {
1951 1951
        Node s = _digraph->source(e);
1952 1952
        _digraph->nextOut(e);
1953 1953
        if (e != INVALID) return;
1954 1954
        d = false;
1955 1955
        _digraph->firstIn(e, s);
1956 1956
      } else {
1957 1957
        _digraph->nextIn(e);
1958 1958
      }
1959 1959
    }
1960 1960

	
1961 1961
    Node u(const Edge& e) const {
1962 1962
      return _digraph->source(e);
1963 1963
    }
1964 1964

	
1965 1965
    Node v(const Edge& e) const {
1966 1966
      return _digraph->target(e);
1967 1967
    }
1968 1968

	
1969 1969
    Node source(const Arc &a) const {
1970 1970
      return a._forward ? _digraph->source(a) : _digraph->target(a);
1971 1971
    }
1972 1972

	
1973 1973
    Node target(const Arc &a) const {
1974 1974
      return a._forward ? _digraph->target(a) : _digraph->source(a);
1975 1975
    }
1976 1976

	
1977 1977
    static Arc direct(const Edge &e, bool d) {
1978 1978
      return Arc(e, d);
1979 1979
    }
1980 1980
    Arc direct(const Edge &e, const Node& n) const {
1981 1981
      return Arc(e, _digraph->source(e) == n);
1982 1982
    }
1983 1983

	
1984 1984
    static bool direction(const Arc &a) { return a._forward; }
1985 1985

	
1986 1986
    Node nodeFromId(int ix) const { return _digraph->nodeFromId(ix); }
1987 1987
    Arc arcFromId(int ix) const {
1988 1988
      return direct(_digraph->arcFromId(ix >> 1), bool(ix & 1));
1989 1989
    }
1990 1990
    Edge edgeFromId(int ix) const { return _digraph->arcFromId(ix); }
1991 1991

	
1992 1992
    int id(const Node &n) const { return _digraph->id(n); }
1993 1993
    int id(const Arc &a) const {
1994 1994
      return  (_digraph->id(a) << 1) | (a._forward ? 1 : 0);
1995 1995
    }
1996 1996
    int id(const Edge &e) const { return _digraph->id(e); }
1997 1997

	
1998 1998
    int maxNodeId() const { return _digraph->maxNodeId(); }
1999 1999
    int maxArcId() const { return (_digraph->maxArcId() << 1) | 1; }
2000 2000
    int maxEdgeId() const { return _digraph->maxArcId(); }
2001 2001

	
2002 2002
    Node addNode() { return _digraph->addNode(); }
2003 2003
    Edge addEdge(const Node& u, const Node& v) {
2004 2004
      return _digraph->addArc(u, v);
2005 2005
    }
2006 2006

	
2007 2007
    void erase(const Node& i) { _digraph->erase(i); }
2008 2008
    void erase(const Edge& i) { _digraph->erase(i); }
2009 2009

	
2010 2010
    void clear() { _digraph->clear(); }
2011 2011

	
2012 2012
    typedef NodeNumTagIndicator<Digraph> NodeNumTag;
2013 2013
    int nodeNum() const { return _digraph->nodeNum(); }
2014 2014

	
2015 2015
    typedef ArcNumTagIndicator<Digraph> ArcNumTag;
2016 2016
    int arcNum() const { return 2 * _digraph->arcNum(); }
2017 2017

	
2018 2018
    typedef ArcNumTag EdgeNumTag;
2019 2019
    int edgeNum() const { return _digraph->arcNum(); }
2020 2020

	
2021 2021
    typedef FindArcTagIndicator<Digraph> FindArcTag;
2022 2022
    Arc findArc(Node s, Node t, Arc p = INVALID) const {
2023 2023
      if (p == INVALID) {
2024 2024
        Edge arc = _digraph->findArc(s, t);
2025 2025
        if (arc != INVALID) return direct(arc, true);
2026 2026
        arc = _digraph->findArc(t, s);
2027 2027
        if (arc != INVALID) return direct(arc, false);
2028 2028
      } else if (direction(p)) {
2029 2029
        Edge arc = _digraph->findArc(s, t, p);
2030 2030
        if (arc != INVALID) return direct(arc, true);
2031 2031
        arc = _digraph->findArc(t, s);
2032 2032
        if (arc != INVALID) return direct(arc, false);
2033 2033
      } else {
2034 2034
        Edge arc = _digraph->findArc(t, s, p);
2035 2035
        if (arc != INVALID) return direct(arc, false);
2036 2036
      }
2037 2037
      return INVALID;
2038 2038
    }
2039 2039

	
2040 2040
    typedef FindArcTag FindEdgeTag;
2041 2041
    Edge findEdge(Node s, Node t, Edge p = INVALID) const {
2042 2042
      if (s != t) {
2043 2043
        if (p == INVALID) {
2044 2044
          Edge arc = _digraph->findArc(s, t);
2045 2045
          if (arc != INVALID) return arc;
2046 2046
          arc = _digraph->findArc(t, s);
2047 2047
          if (arc != INVALID) return arc;
2048 2048
        } else if (_digraph->source(p) == s) {
2049 2049
          Edge arc = _digraph->findArc(s, t, p);
2050 2050
          if (arc != INVALID) return arc;
2051 2051
          arc = _digraph->findArc(t, s);
2052 2052
          if (arc != INVALID) return arc;
2053 2053
        } else {
2054 2054
          Edge arc = _digraph->findArc(t, s, p);
2055 2055
          if (arc != INVALID) return arc;
2056 2056
        }
2057 2057
      } else {
2058 2058
        return _digraph->findArc(s, t, p);
2059 2059
      }
2060 2060
      return INVALID;
2061 2061
    }
2062 2062

	
2063 2063
  private:
2064 2064

	
2065 2065
    template <typename _Value>
2066 2066
    class ArcMapBase {
2067 2067
    private:
2068 2068

	
2069 2069
      typedef typename Digraph::template ArcMap<_Value> MapImpl;
2070 2070

	
2071 2071
    public:
2072 2072

	
2073 2073
      typedef typename MapTraits<MapImpl>::ReferenceMapTag ReferenceMapTag;
2074 2074

	
2075 2075
      typedef _Value Value;
2076 2076
      typedef Arc Key;
2077 2077
      typedef typename MapTraits<MapImpl>::ConstReturnValue ConstReturnValue;
2078 2078
      typedef typename MapTraits<MapImpl>::ReturnValue ReturnValue;
2079 2079
      typedef typename MapTraits<MapImpl>::ConstReturnValue ConstReference;
2080 2080
      typedef typename MapTraits<MapImpl>::ReturnValue Reference;
2081 2081

	
2082 2082
      ArcMapBase(const Adaptor& adaptor) :
2083 2083
        _forward(*adaptor._digraph), _backward(*adaptor._digraph) {}
2084 2084

	
2085 2085
      ArcMapBase(const Adaptor& adaptor, const Value& v)
2086 2086
        : _forward(*adaptor._digraph, v), _backward(*adaptor._digraph, v) {}
2087 2087

	
2088 2088
      void set(const Arc& a, const Value& v) {
2089 2089
        if (direction(a)) {
2090 2090
          _forward.set(a, v);
2091 2091
        } else {
2092 2092
          _backward.set(a, v);
2093 2093
        }
2094 2094
      }
2095 2095

	
2096 2096
      ConstReturnValue operator[](const Arc& a) const {
2097 2097
        if (direction(a)) {
2098 2098
          return _forward[a];
2099 2099
        } else {
2100 2100
          return _backward[a];
2101 2101
        }
2102 2102
      }
2103 2103

	
2104 2104
      ReturnValue operator[](const Arc& a) {
2105 2105
        if (direction(a)) {
2106 2106
          return _forward[a];
2107 2107
        } else {
2108 2108
          return _backward[a];
2109 2109
        }
2110 2110
      }
2111 2111

	
2112 2112
    protected:
2113 2113

	
2114 2114
      MapImpl _forward, _backward;
2115 2115

	
2116 2116
    };
2117 2117

	
2118 2118
  public:
2119 2119

	
2120 2120
    template <typename _Value>
2121 2121
    class NodeMap : public Digraph::template NodeMap<_Value> {
2122 2122
    public:
2123 2123

	
2124 2124
      typedef _Value Value;
2125 2125
      typedef typename Digraph::template NodeMap<Value> Parent;
2126 2126

	
2127 2127
      explicit NodeMap(const Adaptor& adaptor)
2128 2128
        : Parent(*adaptor._digraph) {}
2129 2129

	
2130 2130
      NodeMap(const Adaptor& adaptor, const _Value& value)
2131 2131
        : Parent(*adaptor._digraph, value) { }
2132 2132

	
2133 2133
    private:
2134 2134
      NodeMap& operator=(const NodeMap& cmap) {
2135 2135
        return operator=<NodeMap>(cmap);
2136 2136
      }
2137 2137

	
2138 2138
      template <typename CMap>
2139 2139
      NodeMap& operator=(const CMap& cmap) {
2140 2140
        Parent::operator=(cmap);
2141 2141
        return *this;
2142 2142
      }
2143 2143

	
2144 2144
    };
2145 2145

	
2146 2146
    template <typename _Value>
2147 2147
    class ArcMap
2148 2148
      : public SubMapExtender<Adaptor, ArcMapBase<_Value> >
2149 2149
    {
2150 2150
    public:
2151 2151
      typedef _Value Value;
2152 2152
      typedef SubMapExtender<Adaptor, ArcMapBase<Value> > Parent;
2153 2153

	
2154 2154
      explicit ArcMap(const Adaptor& adaptor)
2155 2155
        : Parent(adaptor) {}
2156 2156

	
2157 2157
      ArcMap(const Adaptor& adaptor, const Value& value)
2158 2158
        : Parent(adaptor, value) {}
2159 2159

	
2160 2160
    private:
2161 2161
      ArcMap& operator=(const ArcMap& cmap) {
2162 2162
        return operator=<ArcMap>(cmap);
2163 2163
      }
2164 2164

	
2165 2165
      template <typename CMap>
2166 2166
      ArcMap& operator=(const CMap& cmap) {
2167 2167
        Parent::operator=(cmap);
2168 2168
        return *this;
2169 2169
      }
2170 2170
    };
2171 2171

	
2172 2172
    template <typename _Value>
2173 2173
    class EdgeMap : public Digraph::template ArcMap<_Value> {
2174 2174
    public:
2175 2175

	
2176 2176
      typedef _Value Value;
2177 2177
      typedef typename Digraph::template ArcMap<Value> Parent;
2178 2178

	
2179 2179
      explicit EdgeMap(const Adaptor& adaptor)
2180 2180
        : Parent(*adaptor._digraph) {}
2181 2181

	
2182 2182
      EdgeMap(const Adaptor& adaptor, const Value& value)
2183 2183
        : Parent(*adaptor._digraph, value) {}
2184 2184

	
2185 2185
    private:
2186 2186
      EdgeMap& operator=(const EdgeMap& cmap) {
2187 2187
        return operator=<EdgeMap>(cmap);
2188 2188
      }
2189 2189

	
2190 2190
      template <typename CMap>
2191 2191
      EdgeMap& operator=(const CMap& cmap) {
2192 2192
        Parent::operator=(cmap);
2193 2193
        return *this;
2194 2194
      }
2195 2195

	
2196 2196
    };
2197 2197

	
2198 2198
    typedef typename ItemSetTraits<Digraph, Node>::ItemNotifier NodeNotifier;
2199 2199
    NodeNotifier& notifier(Node) const { return _digraph->notifier(Node()); }
2200 2200

	
2201 2201
    typedef typename ItemSetTraits<Digraph, Edge>::ItemNotifier EdgeNotifier;
2202 2202
    EdgeNotifier& notifier(Edge) const { return _digraph->notifier(Edge()); }
2203 2203

	
2204 2204
  protected:
2205 2205

	
2206 2206
    UndirectorBase() : _digraph(0) {}
2207 2207

	
2208 2208
    Digraph* _digraph;
2209 2209

	
2210 2210
    void setDigraph(Digraph& digraph) {
2211 2211
      _digraph = &digraph;
2212 2212
    }
2213 2213

	
2214 2214
  };
2215 2215

	
2216 2216
  /// \ingroup graph_adaptors
2217 2217
  ///
2218 2218
  /// \brief Adaptor class for viewing a digraph as an undirected graph.
2219 2219
  ///
2220 2220
  /// Undirector adaptor can be used for viewing a digraph as an undirected
2221 2221
  /// graph. All arcs of the underlying digraph are showed in the
2222 2222
  /// adaptor as an edge (and also as a pair of arcs, of course).
2223 2223
  /// This adaptor conforms to the \ref concepts::Graph "Graph" concept.
2224 2224
  ///
2225 2225
  /// The adapted digraph can also be modified through this adaptor
2226 2226
  /// by adding or removing nodes or edges, unless the \c GR template
2227 2227
  /// parameter is set to be \c const.
2228 2228
  ///
2229 2229
  /// \tparam GR The type of the adapted digraph.
2230 2230
  /// It must conform to the \ref concepts::Digraph "Digraph" concept.
2231 2231
  /// It can also be specified to be \c const.
2232 2232
  ///
2233 2233
  /// \note The \c Node type of this adaptor and the adapted digraph are
2234 2234
  /// convertible to each other, moreover the \c Edge type of the adaptor
2235 2235
  /// and the \c Arc type of the adapted digraph are also convertible to
2236 2236
  /// each other.
2237 2237
  /// (Thus the \c Arc type of the adaptor is convertible to the \c Arc type
2238 2238
  /// of the adapted digraph.)
2239 2239
  template<typename GR>
2240 2240
#ifdef DOXYGEN
2241 2241
  class Undirector {
2242 2242
#else
2243 2243
  class Undirector :
2244 2244
    public GraphAdaptorExtender<UndirectorBase<GR> > {
2245 2245
#endif
2246 2246
  public:
2247 2247
    /// The type of the adapted digraph.
2248 2248
    typedef GR Digraph;
2249 2249
    typedef GraphAdaptorExtender<UndirectorBase<GR> > Parent;
2250 2250
  protected:
2251 2251
    Undirector() { }
2252 2252
  public:
2253 2253

	
2254 2254
    /// \brief Constructor
2255 2255
    ///
2256 2256
    /// Creates an undirected graph from the given digraph.
2257 2257
    Undirector(Digraph& digraph) {
2258 2258
      setDigraph(digraph);
2259 2259
    }
2260 2260

	
2261 2261
    /// \brief Arc map combined from two original arc maps
2262 2262
    ///
2263 2263
    /// This map adaptor class adapts two arc maps of the underlying
2264 2264
    /// digraph to get an arc map of the undirected graph.
2265 2265
    /// Its value type is inherited from the first arc map type
2266 2266
    /// (\c %ForwardMap).
2267 2267
    template <typename ForwardMap, typename BackwardMap>
2268 2268
    class CombinedArcMap {
2269 2269
    public:
2270 2270

	
2271 2271
      /// The key type of the map
2272 2272
      typedef typename Parent::Arc Key;
2273 2273
      /// The value type of the map
2274 2274
      typedef typename ForwardMap::Value Value;
2275 2275

	
2276 2276
      typedef typename MapTraits<ForwardMap>::ReferenceMapTag ReferenceMapTag;
2277 2277

	
2278 2278
      typedef typename MapTraits<ForwardMap>::ReturnValue ReturnValue;
2279 2279
      typedef typename MapTraits<ForwardMap>::ConstReturnValue ConstReturnValue;
2280 2280
      typedef typename MapTraits<ForwardMap>::ReturnValue Reference;
2281 2281
      typedef typename MapTraits<ForwardMap>::ConstReturnValue ConstReference;
2282 2282

	
2283 2283
      /// Constructor
2284 2284
      CombinedArcMap(ForwardMap& forward, BackwardMap& backward)
2285 2285
        : _forward(&forward), _backward(&backward) {}
2286 2286

	
2287 2287
      /// Sets the value associated with the given key.
2288 2288
      void set(const Key& e, const Value& a) {
2289 2289
        if (Parent::direction(e)) {
2290 2290
          _forward->set(e, a);
2291 2291
        } else {
2292 2292
          _backward->set(e, a);
2293 2293
        }
2294 2294
      }
2295 2295

	
2296 2296
      /// Returns the value associated with the given key.
2297 2297
      ConstReturnValue operator[](const Key& e) const {
2298 2298
        if (Parent::direction(e)) {
2299 2299
          return (*_forward)[e];
2300 2300
        } else {
2301 2301
          return (*_backward)[e];
2302 2302
        }
2303 2303
      }
2304 2304

	
2305 2305
      /// Returns a reference to the value associated with the given key.
2306 2306
      ReturnValue operator[](const Key& e) {
2307 2307
        if (Parent::direction(e)) {
2308 2308
          return (*_forward)[e];
2309 2309
        } else {
2310 2310
          return (*_backward)[e];
2311 2311
        }
2312 2312
      }
2313 2313

	
2314 2314
    protected:
2315 2315

	
2316 2316
      ForwardMap* _forward;
2317 2317
      BackwardMap* _backward;
2318 2318

	
2319 2319
    };
2320 2320

	
2321 2321
    /// \brief Returns a combined arc map
2322 2322
    ///
2323 2323
    /// This function just returns a combined arc map.
2324 2324
    template <typename ForwardMap, typename BackwardMap>
2325 2325
    static CombinedArcMap<ForwardMap, BackwardMap>
2326 2326
    combinedArcMap(ForwardMap& forward, BackwardMap& backward) {
2327 2327
      return CombinedArcMap<ForwardMap, BackwardMap>(forward, backward);
2328 2328
    }
2329 2329

	
2330 2330
    template <typename ForwardMap, typename BackwardMap>
2331 2331
    static CombinedArcMap<const ForwardMap, BackwardMap>
2332 2332
    combinedArcMap(const ForwardMap& forward, BackwardMap& backward) {
2333 2333
      return CombinedArcMap<const ForwardMap,
2334 2334
        BackwardMap>(forward, backward);
2335 2335
    }
2336 2336

	
2337 2337
    template <typename ForwardMap, typename BackwardMap>
2338 2338
    static CombinedArcMap<ForwardMap, const BackwardMap>
2339 2339
    combinedArcMap(ForwardMap& forward, const BackwardMap& backward) {
2340 2340
      return CombinedArcMap<ForwardMap,
2341 2341
        const BackwardMap>(forward, backward);
2342 2342
    }
2343 2343

	
2344 2344
    template <typename ForwardMap, typename BackwardMap>
2345 2345
    static CombinedArcMap<const ForwardMap, const BackwardMap>
2346 2346
    combinedArcMap(const ForwardMap& forward, const BackwardMap& backward) {
2347 2347
      return CombinedArcMap<const ForwardMap,
2348 2348
        const BackwardMap>(forward, backward);
2349 2349
    }
2350 2350

	
2351 2351
  };
2352 2352

	
2353 2353
  /// \brief Returns a read-only Undirector adaptor
2354 2354
  ///
2355 2355
  /// This function just returns a read-only \ref Undirector adaptor.
2356 2356
  /// \ingroup graph_adaptors
2357 2357
  /// \relates Undirector
2358 2358
  template<typename GR>
2359 2359
  Undirector<const GR> undirector(const GR& digraph) {
2360 2360
    return Undirector<const GR>(digraph);
2361 2361
  }
2362 2362

	
2363 2363

	
2364 2364
  template <typename _Graph, typename _DirectionMap>
2365 2365
  class OrienterBase {
2366 2366
  public:
2367 2367

	
2368 2368
    typedef _Graph Graph;
2369 2369
    typedef _DirectionMap DirectionMap;
2370 2370

	
2371 2371
    typedef typename Graph::Node Node;
2372 2372
    typedef typename Graph::Edge Arc;
2373 2373

	
2374 2374
    void reverseArc(const Arc& arc) {
2375 2375
      _direction->set(arc, !(*_direction)[arc]);
2376 2376
    }
2377 2377

	
2378 2378
    void first(Node& i) const { _graph->first(i); }
2379 2379
    void first(Arc& i) const { _graph->first(i); }
2380 2380
    void firstIn(Arc& i, const Node& n) const {
2381 2381
      bool d = true;
2382 2382
      _graph->firstInc(i, d, n);
2383 2383
      while (i != INVALID && d == (*_direction)[i]) _graph->nextInc(i, d);
2384 2384
    }
2385 2385
    void firstOut(Arc& i, const Node& n ) const {
2386 2386
      bool d = true;
2387 2387
      _graph->firstInc(i, d, n);
2388 2388
      while (i != INVALID && d != (*_direction)[i]) _graph->nextInc(i, d);
2389 2389
    }
2390 2390

	
2391 2391
    void next(Node& i) const { _graph->next(i); }
2392 2392
    void next(Arc& i) const { _graph->next(i); }
2393 2393
    void nextIn(Arc& i) const {
2394 2394
      bool d = !(*_direction)[i];
2395 2395
      _graph->nextInc(i, d);
2396 2396
      while (i != INVALID && d == (*_direction)[i]) _graph->nextInc(i, d);
2397 2397
    }
2398 2398
    void nextOut(Arc& i) const {
2399 2399
      bool d = (*_direction)[i];
2400 2400
      _graph->nextInc(i, d);
2401 2401
      while (i != INVALID && d != (*_direction)[i]) _graph->nextInc(i, d);
2402 2402
    }
2403 2403

	
2404 2404
    Node source(const Arc& e) const {
2405 2405
      return (*_direction)[e] ? _graph->u(e) : _graph->v(e);
2406 2406
    }
2407 2407
    Node target(const Arc& e) const {
2408 2408
      return (*_direction)[e] ? _graph->v(e) : _graph->u(e);
2409 2409
    }
2410 2410

	
2411 2411
    typedef NodeNumTagIndicator<Graph> NodeNumTag;
2412 2412
    int nodeNum() const { return _graph->nodeNum(); }
2413 2413

	
2414 2414
    typedef EdgeNumTagIndicator<Graph> ArcNumTag;
2415 2415
    int arcNum() const { return _graph->edgeNum(); }
2416 2416

	
2417 2417
    typedef FindEdgeTagIndicator<Graph> FindArcTag;
2418 2418
    Arc findArc(const Node& u, const Node& v,
2419 2419
                const Arc& prev = INVALID) const {
2420 2420
      Arc arc = _graph->findEdge(u, v, prev);
2421 2421
      while (arc != INVALID && source(arc) != u) {
2422 2422
        arc = _graph->findEdge(u, v, arc);
2423 2423
      }
2424 2424
      return arc;
2425 2425
    }
2426 2426

	
2427 2427
    Node addNode() {
2428 2428
      return Node(_graph->addNode());
2429 2429
    }
2430 2430

	
2431 2431
    Arc addArc(const Node& u, const Node& v) {
2432 2432
      Arc arc = _graph->addEdge(u, v);
2433 2433
      _direction->set(arc, _graph->u(arc) == u);
2434 2434
      return arc;
2435 2435
    }
2436 2436

	
2437 2437
    void erase(const Node& i) { _graph->erase(i); }
2438 2438
    void erase(const Arc& i) { _graph->erase(i); }
2439 2439

	
2440 2440
    void clear() { _graph->clear(); }
2441 2441

	
2442 2442
    int id(const Node& v) const { return _graph->id(v); }
2443 2443
    int id(const Arc& e) const { return _graph->id(e); }
2444 2444

	
2445 2445
    Node nodeFromId(int idx) const { return _graph->nodeFromId(idx); }
2446 2446
    Arc arcFromId(int idx) const { return _graph->edgeFromId(idx); }
2447 2447

	
2448 2448
    int maxNodeId() const { return _graph->maxNodeId(); }
2449 2449
    int maxArcId() const { return _graph->maxEdgeId(); }
2450 2450

	
2451 2451
    typedef typename ItemSetTraits<Graph, Node>::ItemNotifier NodeNotifier;
2452 2452
    NodeNotifier& notifier(Node) const { return _graph->notifier(Node()); }
2453 2453

	
2454 2454
    typedef typename ItemSetTraits<Graph, Arc>::ItemNotifier ArcNotifier;
2455 2455
    ArcNotifier& notifier(Arc) const { return _graph->notifier(Arc()); }
2456 2456

	
2457 2457
    template <typename _Value>
2458 2458
    class NodeMap : public _Graph::template NodeMap<_Value> {
2459 2459
    public:
2460 2460

	
2461 2461
      typedef typename _Graph::template NodeMap<_Value> Parent;
2462 2462

	
2463 2463
      explicit NodeMap(const OrienterBase& adapter)
2464 2464
        : Parent(*adapter._graph) {}
2465 2465

	
2466 2466
      NodeMap(const OrienterBase& adapter, const _Value& value)
2467 2467
        : Parent(*adapter._graph, value) {}
2468 2468

	
2469 2469
    private:
2470 2470
      NodeMap& operator=(const NodeMap& cmap) {
2471 2471
        return operator=<NodeMap>(cmap);
2472 2472
      }
2473 2473

	
2474 2474
      template <typename CMap>
2475 2475
      NodeMap& operator=(const CMap& cmap) {
2476 2476
        Parent::operator=(cmap);
2477 2477
        return *this;
2478 2478
      }
2479 2479

	
2480 2480
    };
2481 2481

	
2482 2482
    template <typename _Value>
2483 2483
    class ArcMap : public _Graph::template EdgeMap<_Value> {
2484 2484
    public:
2485 2485

	
2486 2486
      typedef typename Graph::template EdgeMap<_Value> Parent;
2487 2487

	
2488 2488
      explicit ArcMap(const OrienterBase& adapter)
2489 2489
        : Parent(*adapter._graph) { }
2490 2490

	
2491 2491
      ArcMap(const OrienterBase& adapter, const _Value& value)
2492 2492
        : Parent(*adapter._graph, value) { }
2493 2493

	
2494 2494
    private:
2495 2495
      ArcMap& operator=(const ArcMap& cmap) {
2496 2496
        return operator=<ArcMap>(cmap);
2497 2497
      }
2498 2498

	
2499 2499
      template <typename CMap>
2500 2500
      ArcMap& operator=(const CMap& cmap) {
2501 2501
        Parent::operator=(cmap);
2502 2502
        return *this;
2503 2503
      }
2504 2504
    };
2505 2505

	
2506 2506

	
2507 2507

	
2508 2508
  protected:
2509 2509
    Graph* _graph;
2510 2510
    DirectionMap* _direction;
2511 2511

	
2512 2512
    void setDirectionMap(DirectionMap& direction) {
2513 2513
      _direction = &direction;
2514 2514
    }
2515 2515

	
2516 2516
    void setGraph(Graph& graph) {
2517 2517
      _graph = &graph;
2518 2518
    }
2519 2519

	
2520 2520
  };
2521 2521

	
2522 2522
  /// \ingroup graph_adaptors
2523 2523
  ///
2524 2524
  /// \brief Adaptor class for orienting the edges of a graph to get a digraph
2525 2525
  ///
2526 2526
  /// Orienter adaptor can be used for orienting the edges of a graph to
2527 2527
  /// get a digraph. A \c bool edge map of the underlying graph must be
2528 2528
  /// specified, which define the direction of the arcs in the adaptor.
2529 2529
  /// The arcs can be easily reversed by the \c reverseArc() member function
2530 2530
  /// of the adaptor.
2531 2531
  /// This class conforms to the \ref concepts::Digraph "Digraph" concept.
2532 2532
  ///
2533 2533
  /// The adapted graph can also be modified through this adaptor
2534 2534
  /// by adding or removing nodes or arcs, unless the \c GR template
2535 2535
  /// parameter is set to be \c const.
2536 2536
  ///
2537 2537
  /// \tparam GR The type of the adapted graph.
2538 2538
  /// It must conform to the \ref concepts::Graph "Graph" concept.
2539 2539
  /// It can also be specified to be \c const.
2540 2540
  /// \tparam DM The type of the direction map.
2541 2541
  /// It must be a \c bool (or convertible) edge map of the
2542 2542
  /// adapted graph. The default type is
2543 2543
  /// \ref concepts::Graph::EdgeMap "GR::EdgeMap<bool>".
2544 2544
  ///
2545 2545
  /// \note The \c Node type of this adaptor and the adapted graph are
2546 2546
  /// convertible to each other, moreover the \c Arc type of the adaptor
2547 2547
  /// and the \c Edge type of the adapted graph are also convertible to
2548 2548
  /// each other.
2549 2549
#ifdef DOXYGEN
2550 2550
  template<typename GR,
2551 2551
           typename DM>
2552 2552
  class Orienter {
2553 2553
#else
2554 2554
  template<typename GR,
2555 2555
           typename DM = typename GR::template EdgeMap<bool> >
2556 2556
  class Orienter :
2557 2557
    public DigraphAdaptorExtender<OrienterBase<GR, DM> > {
2558 2558
#endif
2559 2559
  public:
2560 2560

	
2561 2561
    /// The type of the adapted graph.
2562 2562
    typedef GR Graph;
2563 2563
    /// The type of the direction edge map.
2564 2564
    typedef DM DirectionMap;
2565 2565

	
2566 2566
    typedef DigraphAdaptorExtender<OrienterBase<GR, DM> > Parent;
2567 2567
    typedef typename Parent::Arc Arc;
2568 2568
  protected:
2569 2569
    Orienter() { }
2570 2570
  public:
2571 2571

	
2572 2572
    /// \brief Constructor
2573 2573
    ///
2574 2574
    /// Constructor of the adaptor.
2575 2575
    Orienter(Graph& graph, DirectionMap& direction) {
2576 2576
      setGraph(graph);
2577 2577
      setDirectionMap(direction);
2578 2578
    }
2579 2579

	
2580 2580
    /// \brief Reverses the given arc
2581 2581
    ///
2582 2582
    /// This function reverses the given arc.
2583 2583
    /// It is done by simply negate the assigned value of \c a
2584 2584
    /// in the direction map.
2585 2585
    void reverseArc(const Arc& a) {
2586 2586
      Parent::reverseArc(a);
2587 2587
    }
2588 2588
  };
2589 2589

	
2590 2590
  /// \brief Returns a read-only Orienter adaptor
2591 2591
  ///
2592 2592
  /// This function just returns a read-only \ref Orienter adaptor.
2593 2593
  /// \ingroup graph_adaptors
2594 2594
  /// \relates Orienter
2595 2595
  template<typename GR, typename DM>
2596 2596
  Orienter<const GR, DM>
2597 2597
  orienter(const GR& graph, DM& direction_map) {
2598 2598
    return Orienter<const GR, DM>(graph, direction_map);
2599 2599
  }
2600 2600

	
2601 2601
  template<typename GR, typename DM>
2602 2602
  Orienter<const GR, const DM>
2603 2603
  orienter(const GR& graph, const DM& direction_map) {
2604 2604
    return Orienter<const GR, const DM>(graph, direction_map);
2605 2605
  }
2606 2606

	
2607 2607
  namespace _adaptor_bits {
2608 2608

	
2609 2609
    template<typename Digraph,
2610 2610
             typename CapacityMap,
2611 2611
             typename FlowMap,
2612 2612
             typename Tolerance>
2613 2613
    class ResForwardFilter {
2614 2614
    public:
2615 2615

	
2616 2616
      typedef typename Digraph::Arc Key;
2617 2617
      typedef bool Value;
2618 2618

	
2619 2619
    private:
2620 2620

	
2621 2621
      const CapacityMap* _capacity;
2622 2622
      const FlowMap* _flow;
2623 2623
      Tolerance _tolerance;
2624 2624
    public:
2625 2625

	
2626 2626
      ResForwardFilter(const CapacityMap& capacity, const FlowMap& flow,
2627 2627
                       const Tolerance& tolerance = Tolerance())
2628 2628
        : _capacity(&capacity), _flow(&flow), _tolerance(tolerance) { }
2629 2629

	
2630 2630
      bool operator[](const typename Digraph::Arc& a) const {
2631 2631
        return _tolerance.positive((*_capacity)[a] - (*_flow)[a]);
2632 2632
      }
2633 2633
    };
2634 2634

	
2635 2635
    template<typename Digraph,
2636 2636
             typename CapacityMap,
2637 2637
             typename FlowMap,
2638 2638
             typename Tolerance>
2639 2639
    class ResBackwardFilter {
2640 2640
    public:
2641 2641

	
2642 2642
      typedef typename Digraph::Arc Key;
2643 2643
      typedef bool Value;
2644 2644

	
2645 2645
    private:
2646 2646

	
2647 2647
      const CapacityMap* _capacity;
2648 2648
      const FlowMap* _flow;
2649 2649
      Tolerance _tolerance;
2650 2650

	
2651 2651
    public:
2652 2652

	
2653 2653
      ResBackwardFilter(const CapacityMap& capacity, const FlowMap& flow,
2654 2654
                        const Tolerance& tolerance = Tolerance())
2655 2655
        : _capacity(&capacity), _flow(&flow), _tolerance(tolerance) { }
2656 2656

	
2657 2657
      bool operator[](const typename Digraph::Arc& a) const {
2658 2658
        return _tolerance.positive((*_flow)[a]);
2659 2659
      }
2660 2660
    };
2661 2661

	
2662 2662
  }
2663 2663

	
2664 2664
  /// \ingroup graph_adaptors
2665 2665
  ///
2666 2666
  /// \brief Adaptor class for composing the residual digraph for directed
2667 2667
  /// flow and circulation problems.
2668 2668
  ///
2669
  /// Residual can be used for composing the \e residual digraph for directed
2670
  /// flow and circulation problems. Let \f$ G=(V, A) \f$ be a directed graph
2671
  /// and let \f$ F \f$ be a number type. Let \f$ flow, cap: A\to F \f$ be
2672
  /// functions on the arcs.
2669
  /// ResidualDigraph can be used for composing the \e residual digraph
2670
  /// for directed flow and circulation problems. Let \f$ G=(V, A) \f$
2671
  /// be a directed graph and let \f$ F \f$ be a number type.
2672
  /// Let \f$ flow, cap: A\to F \f$ be functions on the arcs.
2673 2673
  /// This adaptor implements a digraph structure with node set \f$ V \f$
2674 2674
  /// and arc set \f$ A_{forward}\cup A_{backward} \f$,
2675 2675
  /// where \f$ A_{forward}=\{uv : uv\in A, flow(uv)<cap(uv)\} \f$ and
2676 2676
  /// \f$ A_{backward}=\{vu : uv\in A, flow(uv)>0\} \f$, i.e. the so
2677 2677
  /// called residual digraph.
2678 2678
  /// When the union \f$ A_{forward}\cup A_{backward} \f$ is taken,
2679 2679
  /// multiplicities are counted, i.e. the adaptor has exactly
2680 2680
  /// \f$ |A_{forward}| + |A_{backward}|\f$ arcs (it may have parallel
2681 2681
  /// arcs).
2682 2682
  /// This class conforms to the \ref concepts::Digraph "Digraph" concept.
2683 2683
  ///
2684 2684
  /// \tparam GR The type of the adapted digraph.
2685 2685
  /// It must conform to the \ref concepts::Digraph "Digraph" concept.
2686 2686
  /// It is implicitly \c const.
2687 2687
  /// \tparam CM The type of the capacity map.
2688 2688
  /// It must be an arc map of some numerical type, which defines
2689 2689
  /// the capacities in the flow problem. It is implicitly \c const.
2690 2690
  /// The default type is
2691 2691
  /// \ref concepts::Digraph::ArcMap "GR::ArcMap<int>".
2692 2692
  /// \tparam FM The type of the flow map.
2693 2693
  /// It must be an arc map of some numerical type, which defines
2694 2694
  /// the flow values in the flow problem. The default type is \c CM.
2695 2695
  /// \tparam TL The tolerance type for handling inexact computation.
2696 2696
  /// The default tolerance type depends on the value type of the
2697 2697
  /// capacity map.
2698 2698
  ///
2699 2699
  /// \note This adaptor is implemented using Undirector and FilterArcs
2700 2700
  /// adaptors.
2701 2701
  ///
2702 2702
  /// \note The \c Node type of this adaptor and the adapted digraph are
2703 2703
  /// convertible to each other, moreover the \c Arc type of the adaptor
2704 2704
  /// is convertible to the \c Arc type of the adapted digraph.
2705 2705
#ifdef DOXYGEN
2706 2706
  template<typename GR, typename CM, typename FM, typename TL>
2707
  class Residual
2707
  class ResidualDigraph
2708 2708
#else
2709 2709
  template<typename GR,
2710 2710
           typename CM = typename GR::template ArcMap<int>,
2711 2711
           typename FM = CM,
2712 2712
           typename TL = Tolerance<typename CM::Value> >
2713
  class Residual :
2713
  class ResidualDigraph :
2714 2714
    public FilterArcs<
2715 2715
      Undirector<const GR>,
2716 2716
      typename Undirector<const GR>::template CombinedArcMap<
2717 2717
        _adaptor_bits::ResForwardFilter<const GR, CM, FM, TL>,
2718 2718
        _adaptor_bits::ResBackwardFilter<const GR, CM, FM, TL> > >
2719 2719
#endif
2720 2720
  {
2721 2721
  public:
2722 2722

	
2723 2723
    /// The type of the underlying digraph.
2724 2724
    typedef GR Digraph;
2725 2725
    /// The type of the capacity map.
2726 2726
    typedef CM CapacityMap;
2727 2727
    /// The type of the flow map.
2728 2728
    typedef FM FlowMap;
2729 2729
    /// The tolerance type.
2730 2730
    typedef TL Tolerance;
2731 2731

	
2732 2732
    typedef typename CapacityMap::Value Value;
2733
    typedef Residual Adaptor;
2733
    typedef ResidualDigraph Adaptor;
2734 2734

	
2735 2735
  protected:
2736 2736

	
2737 2737
    typedef Undirector<const Digraph> Undirected;
2738 2738

	
2739 2739
    typedef _adaptor_bits::ResForwardFilter<const Digraph, CapacityMap,
2740 2740
                                            FlowMap, Tolerance> ForwardFilter;
2741 2741

	
2742 2742
    typedef _adaptor_bits::ResBackwardFilter<const Digraph, CapacityMap,
2743 2743
                                             FlowMap, Tolerance> BackwardFilter;
2744 2744

	
2745 2745
    typedef typename Undirected::
2746 2746
      template CombinedArcMap<ForwardFilter, BackwardFilter> ArcFilter;
2747 2747

	
2748 2748
    typedef FilterArcs<Undirected, ArcFilter> Parent;
2749 2749

	
2750 2750
    const CapacityMap* _capacity;
2751 2751
    FlowMap* _flow;
2752 2752

	
2753 2753
    Undirected _graph;
2754 2754
    ForwardFilter _forward_filter;
2755 2755
    BackwardFilter _backward_filter;
2756 2756
    ArcFilter _arc_filter;
2757 2757

	
2758 2758
  public:
2759 2759

	
2760 2760
    /// \brief Constructor
2761 2761
    ///
2762 2762
    /// Constructor of the residual digraph adaptor. The parameters are the
2763 2763
    /// digraph, the capacity map, the flow map, and a tolerance object.
2764
    Residual(const Digraph& digraph, const CapacityMap& capacity,
2765
             FlowMap& flow, const Tolerance& tolerance = Tolerance())
2764
    ResidualDigraph(const Digraph& digraph, const CapacityMap& capacity,
2765
                    FlowMap& flow, const Tolerance& tolerance = Tolerance())
2766 2766
      : Parent(), _capacity(&capacity), _flow(&flow), _graph(digraph),
2767 2767
        _forward_filter(capacity, flow, tolerance),
2768 2768
        _backward_filter(capacity, flow, tolerance),
2769 2769
        _arc_filter(_forward_filter, _backward_filter)
2770 2770
    {
2771 2771
      Parent::setDigraph(_graph);
2772 2772
      Parent::setArcFilterMap(_arc_filter);
2773 2773
    }
2774 2774

	
2775 2775
    typedef typename Parent::Arc Arc;
2776 2776

	
2777 2777
    /// \brief Returns the residual capacity of the given arc.
2778 2778
    ///
2779 2779
    /// Returns the residual capacity of the given arc.
2780 2780
    Value residualCapacity(const Arc& a) const {
2781 2781
      if (Undirected::direction(a)) {
2782 2782
        return (*_capacity)[a] - (*_flow)[a];
2783 2783
      } else {
2784 2784
        return (*_flow)[a];
2785 2785
      }
2786 2786
    }
2787 2787

	
2788 2788
    /// \brief Augments on the given arc in the residual digraph.
2789 2789
    ///
2790 2790
    /// Augments on the given arc in the residual digraph. It increases
2791 2791
    /// or decreases the flow value on the original arc according to the
2792 2792
    /// direction of the residual arc.
2793 2793
    void augment(const Arc& a, const Value& v) const {
2794 2794
      if (Undirected::direction(a)) {
2795 2795
        _flow->set(a, (*_flow)[a] + v);
2796 2796
      } else {
2797 2797
        _flow->set(a, (*_flow)[a] - v);
2798 2798
      }
2799 2799
    }
2800 2800

	
2801 2801
    /// \brief Returns \c true if the given residual arc is a forward arc.
2802 2802
    ///
2803 2803
    /// Returns \c true if the given residual arc has the same orientation
2804 2804
    /// as the original arc, i.e. it is a so called forward arc.
2805 2805
    static bool forward(const Arc& a) {
2806 2806
      return Undirected::direction(a);
2807 2807
    }
2808 2808

	
2809 2809
    /// \brief Returns \c true if the given residual arc is a backward arc.
2810 2810
    ///
2811 2811
    /// Returns \c true if the given residual arc has the opposite orientation
2812 2812
    /// than the original arc, i.e. it is a so called backward arc.
2813 2813
    static bool backward(const Arc& a) {
2814 2814
      return !Undirected::direction(a);
2815 2815
    }
2816 2816

	
2817 2817
    /// \brief Returns the forward oriented residual arc.
2818 2818
    ///
2819 2819
    /// Returns the forward oriented residual arc related to the given
2820 2820
    /// arc of the underlying digraph.
2821 2821
    static Arc forward(const typename Digraph::Arc& a) {
2822 2822
      return Undirected::direct(a, true);
2823 2823
    }
2824 2824

	
2825 2825
    /// \brief Returns the backward oriented residual arc.
2826 2826
    ///
2827 2827
    /// Returns the backward oriented residual arc related to the given
2828 2828
    /// arc of the underlying digraph.
2829 2829
    static Arc backward(const typename Digraph::Arc& a) {
2830 2830
      return Undirected::direct(a, false);
2831 2831
    }
2832 2832

	
2833 2833
    /// \brief Residual capacity map.
2834 2834
    ///
2835 2835
    /// This map adaptor class can be used for obtaining the residual
2836 2836
    /// capacities as an arc map of the residual digraph.
2837 2837
    /// Its value type is inherited from the capacity map.
2838 2838
    class ResidualCapacity {
2839 2839
    protected:
2840 2840
      const Adaptor* _adaptor;
2841 2841
    public:
2842 2842
      /// The key type of the map
2843 2843
      typedef Arc Key;
2844 2844
      /// The value type of the map
2845 2845
      typedef typename CapacityMap::Value Value;
2846 2846

	
2847 2847
      /// Constructor
2848 2848
      ResidualCapacity(const Adaptor& adaptor) : _adaptor(&adaptor) {}
2849 2849

	
2850 2850
      /// Returns the value associated with the given residual arc
2851 2851
      Value operator[](const Arc& a) const {
2852 2852
        return _adaptor->residualCapacity(a);
2853 2853
      }
2854 2854

	
2855 2855
    };
2856 2856

	
2857 2857
    /// \brief Returns a residual capacity map
2858 2858
    ///
2859 2859
    /// This function just returns a residual capacity map.
2860 2860
    ResidualCapacity residualCapacity() const {
2861 2861
      return ResidualCapacity(*this);
2862 2862
    }
2863 2863

	
2864 2864
  };
2865 2865

	
2866 2866
  /// \brief Returns a (read-only) Residual adaptor
2867 2867
  ///
2868 2868
  /// This function just returns a (read-only) \ref Residual adaptor.
2869 2869
  /// \ingroup graph_adaptors
2870 2870
  /// \relates Residual
2871 2871
  template<typename GR, typename CM, typename FM>
2872
  Residual<GR, CM, FM> residual(const GR& digraph,
2873
                                const CM& capacity_map,
2874
                                FM& flow_map) {
2875
    return Residual<GR, CM, FM> (digraph, capacity_map, flow_map);
2872
  ResidualDigraph<GR, CM, FM>
2873
  residualDigraph(const GR& digraph, const CM& capacity_map, FM& flow_map) {
2874
    return ResidualDigraph<GR, CM, FM> (digraph, capacity_map, flow_map);
2876 2875
  }
2877 2876

	
2878 2877

	
2879 2878
  template <typename _Digraph>
2880 2879
  class SplitNodesBase {
2881 2880
  public:
2882 2881

	
2883 2882
    typedef _Digraph Digraph;
2884 2883
    typedef DigraphAdaptorBase<const _Digraph> Parent;
2885 2884
    typedef SplitNodesBase Adaptor;
2886 2885

	
2887 2886
    typedef typename Digraph::Node DigraphNode;
2888 2887
    typedef typename Digraph::Arc DigraphArc;
2889 2888

	
2890 2889
    class Node;
2891 2890
    class Arc;
2892 2891

	
2893 2892
  private:
2894 2893

	
2895 2894
    template <typename T> class NodeMapBase;
2896 2895
    template <typename T> class ArcMapBase;
2897 2896

	
2898 2897
  public:
2899 2898

	
2900 2899
    class Node : public DigraphNode {
2901 2900
      friend class SplitNodesBase;
2902 2901
      template <typename T> friend class NodeMapBase;
2903 2902
    private:
2904 2903

	
2905 2904
      bool _in;
2906 2905
      Node(DigraphNode node, bool in)
2907 2906
        : DigraphNode(node), _in(in) {}
2908 2907

	
2909 2908
    public:
2910 2909

	
2911 2910
      Node() {}
2912 2911
      Node(Invalid) : DigraphNode(INVALID), _in(true) {}
2913 2912

	
2914 2913
      bool operator==(const Node& node) const {
2915 2914
        return DigraphNode::operator==(node) && _in == node._in;
2916 2915
      }
2917 2916

	
2918 2917
      bool operator!=(const Node& node) const {
2919 2918
        return !(*this == node);
2920 2919
      }
2921 2920

	
2922 2921
      bool operator<(const Node& node) const {
2923 2922
        return DigraphNode::operator<(node) ||
2924 2923
          (DigraphNode::operator==(node) && _in < node._in);
2925 2924
      }
2926 2925
    };
2927 2926

	
2928 2927
    class Arc {
2929 2928
      friend class SplitNodesBase;
2930 2929
      template <typename T> friend class ArcMapBase;
2931 2930
    private:
2932 2931
      typedef BiVariant<DigraphArc, DigraphNode> ArcImpl;
2933 2932

	
2934 2933
      explicit Arc(const DigraphArc& arc) : _item(arc) {}
2935 2934
      explicit Arc(const DigraphNode& node) : _item(node) {}
2936 2935

	
2937 2936
      ArcImpl _item;
2938 2937

	
2939 2938
    public:
2940 2939
      Arc() {}
2941 2940
      Arc(Invalid) : _item(DigraphArc(INVALID)) {}
2942 2941

	
2943 2942
      bool operator==(const Arc& arc) const {
2944 2943
        if (_item.firstState()) {
2945 2944
          if (arc._item.firstState()) {
2946 2945
            return _item.first() == arc._item.first();
2947 2946
          }
2948 2947
        } else {
2949 2948
          if (arc._item.secondState()) {
2950 2949
            return _item.second() == arc._item.second();
2951 2950
          }
2952 2951
        }
2953 2952
        return false;
2954 2953
      }
2955 2954

	
2956 2955
      bool operator!=(const Arc& arc) const {
2957 2956
        return !(*this == arc);
2958 2957
      }
2959 2958

	
2960 2959
      bool operator<(const Arc& arc) const {
2961 2960
        if (_item.firstState()) {
2962 2961
          if (arc._item.firstState()) {
2963 2962
            return _item.first() < arc._item.first();
2964 2963
          }
2965 2964
          return false;
2966 2965
        } else {
2967 2966
          if (arc._item.secondState()) {
2968 2967
            return _item.second() < arc._item.second();
2969 2968
          }
2970 2969
          return true;
2971 2970
        }
2972 2971
      }
2973 2972

	
2974 2973
      operator DigraphArc() const { return _item.first(); }
2975 2974
      operator DigraphNode() const { return _item.second(); }
2976 2975

	
2977 2976
    };
2978 2977

	
2979 2978
    void first(Node& n) const {
2980 2979
      _digraph->first(n);
2981 2980
      n._in = true;
2982 2981
    }
2983 2982

	
2984 2983
    void next(Node& n) const {
2985 2984
      if (n._in) {
2986 2985
        n._in = false;
2987 2986
      } else {
2988 2987
        n._in = true;
2989 2988
        _digraph->next(n);
2990 2989
      }
2991 2990
    }
2992 2991

	
2993 2992
    void first(Arc& e) const {
2994 2993
      e._item.setSecond();
2995 2994
      _digraph->first(e._item.second());
2996 2995
      if (e._item.second() == INVALID) {
2997 2996
        e._item.setFirst();
2998 2997
        _digraph->first(e._item.first());
2999 2998
      }
3000 2999
    }
3001 3000

	
3002 3001
    void next(Arc& e) const {
3003 3002
      if (e._item.secondState()) {
3004 3003
        _digraph->next(e._item.second());
3005 3004
        if (e._item.second() == INVALID) {
3006 3005
          e._item.setFirst();
3007 3006
          _digraph->first(e._item.first());
3008 3007
        }
3009 3008
      } else {
3010 3009
        _digraph->next(e._item.first());
3011 3010
      }
3012 3011
    }
3013 3012

	
3014 3013
    void firstOut(Arc& e, const Node& n) const {
3015 3014
      if (n._in) {
3016 3015
        e._item.setSecond(n);
3017 3016
      } else {
3018 3017
        e._item.setFirst();
3019 3018
        _digraph->firstOut(e._item.first(), n);
3020 3019
      }
3021 3020
    }
3022 3021

	
3023 3022
    void nextOut(Arc& e) const {
3024 3023
      if (!e._item.firstState()) {
3025 3024
        e._item.setFirst(INVALID);
3026 3025
      } else {
3027 3026
        _digraph->nextOut(e._item.first());
3028 3027
      }
3029 3028
    }
3030 3029

	
3031 3030
    void firstIn(Arc& e, const Node& n) const {
3032 3031
      if (!n._in) {
3033 3032
        e._item.setSecond(n);
3034 3033
      } else {
3035 3034
        e._item.setFirst();
3036 3035
        _digraph->firstIn(e._item.first(), n);
3037 3036
      }
3038 3037
    }
3039 3038

	
3040 3039
    void nextIn(Arc& e) const {
3041 3040
      if (!e._item.firstState()) {
3042 3041
        e._item.setFirst(INVALID);
3043 3042
      } else {
3044 3043
        _digraph->nextIn(e._item.first());
3045 3044
      }
3046 3045
    }
3047 3046

	
3048 3047
    Node source(const Arc& e) const {
3049 3048
      if (e._item.firstState()) {
3050 3049
        return Node(_digraph->source(e._item.first()), false);
3051 3050
      } else {
3052 3051
        return Node(e._item.second(), true);
3053 3052
      }
3054 3053
    }
3055 3054

	
3056 3055
    Node target(const Arc& e) const {
3057 3056
      if (e._item.firstState()) {
3058 3057
        return Node(_digraph->target(e._item.first()), true);
3059 3058
      } else {
3060 3059
        return Node(e._item.second(), false);
3061 3060
      }
3062 3061
    }
3063 3062

	
3064 3063
    int id(const Node& n) const {
3065 3064
      return (_digraph->id(n) << 1) | (n._in ? 0 : 1);
3066 3065
    }
3067 3066
    Node nodeFromId(int ix) const {
3068 3067
      return Node(_digraph->nodeFromId(ix >> 1), (ix & 1) == 0);
3069 3068
    }
3070 3069
    int maxNodeId() const {
3071 3070
      return 2 * _digraph->maxNodeId() + 1;
3072 3071
    }
3073 3072

	
3074 3073
    int id(const Arc& e) const {
3075 3074
      if (e._item.firstState()) {
3076 3075
        return _digraph->id(e._item.first()) << 1;
3077 3076
      } else {
3078 3077
        return (_digraph->id(e._item.second()) << 1) | 1;
3079 3078
      }
3080 3079
    }
3081 3080
    Arc arcFromId(int ix) const {
3082 3081
      if ((ix & 1) == 0) {
3083 3082
        return Arc(_digraph->arcFromId(ix >> 1));
3084 3083
      } else {
3085 3084
        return Arc(_digraph->nodeFromId(ix >> 1));
3086 3085
      }
3087 3086
    }
3088 3087
    int maxArcId() const {
3089 3088
      return std::max(_digraph->maxNodeId() << 1,
3090 3089
                      (_digraph->maxArcId() << 1) | 1);
3091 3090
    }
3092 3091

	
3093 3092
    static bool inNode(const Node& n) {
3094 3093
      return n._in;
3095 3094
    }
3096 3095

	
3097 3096
    static bool outNode(const Node& n) {
3098 3097
      return !n._in;
3099 3098
    }
3100 3099

	
3101 3100
    static bool origArc(const Arc& e) {
3102 3101
      return e._item.firstState();
3103 3102
    }
3104 3103

	
3105 3104
    static bool bindArc(const Arc& e) {
3106 3105
      return e._item.secondState();
3107 3106
    }
3108 3107

	
3109 3108
    static Node inNode(const DigraphNode& n) {
3110 3109
      return Node(n, true);
3111 3110
    }
3112 3111

	
3113 3112
    static Node outNode(const DigraphNode& n) {
3114 3113
      return Node(n, false);
3115 3114
    }
3116 3115

	
3117 3116
    static Arc arc(const DigraphNode& n) {
3118 3117
      return Arc(n);
3119 3118
    }
3120 3119

	
3121 3120
    static Arc arc(const DigraphArc& e) {
3122 3121
      return Arc(e);
3123 3122
    }
3124 3123

	
3125 3124
    typedef True NodeNumTag;
3126 3125
    int nodeNum() const {
3127 3126
      return  2 * countNodes(*_digraph);
3128 3127
    }
3129 3128

	
3130 3129
    typedef True ArcNumTag;
3131 3130
    int arcNum() const {
3132 3131
      return countArcs(*_digraph) + countNodes(*_digraph);
3133 3132
    }
3134 3133

	
3135 3134
    typedef True FindArcTag;
3136 3135
    Arc findArc(const Node& u, const Node& v,
3137 3136
                const Arc& prev = INVALID) const {
3138 3137
      if (inNode(u) && outNode(v)) {
3139 3138
        if (static_cast<const DigraphNode&>(u) ==
3140 3139
            static_cast<const DigraphNode&>(v) && prev == INVALID) {
3141 3140
          return Arc(u);
3142 3141
        }
3143 3142
      }
3144 3143
      else if (outNode(u) && inNode(v)) {
3145 3144
        return Arc(::lemon::findArc(*_digraph, u, v, prev));
3146 3145
      }
3147 3146
      return INVALID;
3148 3147
    }
3149 3148

	
3150 3149
  private:
3151 3150

	
3152 3151
    template <typename _Value>
3153 3152
    class NodeMapBase
3154 3153
      : public MapTraits<typename Parent::template NodeMap<_Value> > {
3155 3154
      typedef typename Parent::template NodeMap<_Value> NodeImpl;
3156 3155
    public:
3157 3156
      typedef Node Key;
3158 3157
      typedef _Value Value;
3159 3158
      typedef typename MapTraits<NodeImpl>::ReferenceMapTag ReferenceMapTag;
3160 3159
      typedef typename MapTraits<NodeImpl>::ReturnValue ReturnValue;
3161 3160
      typedef typename MapTraits<NodeImpl>::ConstReturnValue ConstReturnValue;
3162 3161
      typedef typename MapTraits<NodeImpl>::ReturnValue Reference;
3163 3162
      typedef typename MapTraits<NodeImpl>::ConstReturnValue ConstReference;
3164 3163

	
3165 3164
      NodeMapBase(const Adaptor& adaptor)
3166 3165
        : _in_map(*adaptor._digraph), _out_map(*adaptor._digraph) {}
3167 3166
      NodeMapBase(const Adaptor& adaptor, const Value& value)
3168 3167
        : _in_map(*adaptor._digraph, value),
3169 3168
          _out_map(*adaptor._digraph, value) {}
3170 3169

	
3171 3170
      void set(const Node& key, const Value& val) {
3172 3171
        if (Adaptor::inNode(key)) { _in_map.set(key, val); }
3173 3172
        else {_out_map.set(key, val); }
3174 3173
      }
3175 3174

	
3176 3175
      ReturnValue operator[](const Node& key) {
3177 3176
        if (Adaptor::inNode(key)) { return _in_map[key]; }
3178 3177
        else { return _out_map[key]; }
3179 3178
      }
3180 3179

	
3181 3180
      ConstReturnValue operator[](const Node& key) const {
3182 3181
        if (Adaptor::inNode(key)) { return _in_map[key]; }
3183 3182
        else { return _out_map[key]; }
3184 3183
      }
3185 3184

	
3186 3185
    private:
3187 3186
      NodeImpl _in_map, _out_map;
3188 3187
    };
3189 3188

	
3190 3189
    template <typename _Value>
3191 3190
    class ArcMapBase
3192 3191
      : public MapTraits<typename Parent::template ArcMap<_Value> > {
3193 3192
      typedef typename Parent::template ArcMap<_Value> ArcImpl;
3194 3193
      typedef typename Parent::template NodeMap<_Value> NodeImpl;
3195 3194
    public:
3196 3195
      typedef Arc Key;
3197 3196
      typedef _Value Value;
3198 3197
      typedef typename MapTraits<ArcImpl>::ReferenceMapTag ReferenceMapTag;
3199 3198
      typedef typename MapTraits<ArcImpl>::ReturnValue ReturnValue;
3200 3199
      typedef typename MapTraits<ArcImpl>::ConstReturnValue ConstReturnValue;
3201 3200
      typedef typename MapTraits<ArcImpl>::ReturnValue Reference;
3202 3201
      typedef typename MapTraits<ArcImpl>::ConstReturnValue ConstReference;
3203 3202

	
3204 3203
      ArcMapBase(const Adaptor& adaptor)
3205 3204
        : _arc_map(*adaptor._digraph), _node_map(*adaptor._digraph) {}
3206 3205
      ArcMapBase(const Adaptor& adaptor, const Value& value)
3207 3206
        : _arc_map(*adaptor._digraph, value),
3208 3207
          _node_map(*adaptor._digraph, value) {}
3209 3208

	
3210 3209
      void set(const Arc& key, const Value& val) {
3211 3210
        if (Adaptor::origArc(key)) {
3212 3211
          _arc_map.set(key._item.first(), val);
3213 3212
        } else {
3214 3213
          _node_map.set(key._item.second(), val);
3215 3214
        }
3216 3215
      }
3217 3216

	
3218 3217
      ReturnValue operator[](const Arc& key) {
3219 3218
        if (Adaptor::origArc(key)) {
3220 3219
          return _arc_map[key._item.first()];
3221 3220
        } else {
3222 3221
          return _node_map[key._item.second()];
3223 3222
        }
3224 3223
      }
3225 3224

	
3226 3225
      ConstReturnValue operator[](const Arc& key) const {
3227 3226
        if (Adaptor::origArc(key)) {
3228 3227
          return _arc_map[key._item.first()];
3229 3228
        } else {
3230 3229
          return _node_map[key._item.second()];
3231 3230
        }
3232 3231
      }
3233 3232

	
3234 3233
    private:
3235 3234
      ArcImpl _arc_map;
3236 3235
      NodeImpl _node_map;
3237 3236
    };
3238 3237

	
3239 3238
  public:
3240 3239

	
3241 3240
    template <typename _Value>
3242 3241
    class NodeMap
3243 3242
      : public SubMapExtender<Adaptor, NodeMapBase<_Value> >
3244 3243
    {
3245 3244
    public:
3246 3245
      typedef _Value Value;
3247 3246
      typedef SubMapExtender<Adaptor, NodeMapBase<Value> > Parent;
3248 3247

	
3249 3248
      NodeMap(const Adaptor& adaptor)
3250 3249
        : Parent(adaptor) {}
3251 3250

	
3252 3251
      NodeMap(const Adaptor& adaptor, const Value& value)
3253 3252
        : Parent(adaptor, value) {}
3254 3253

	
3255 3254
    private:
3256 3255
      NodeMap& operator=(const NodeMap& cmap) {
3257 3256
        return operator=<NodeMap>(cmap);
3258 3257
      }
3259 3258

	
3260 3259
      template <typename CMap>
3261 3260
      NodeMap& operator=(const CMap& cmap) {
3262 3261
        Parent::operator=(cmap);
3263 3262
        return *this;
3264 3263
      }
3265 3264
    };
3266 3265

	
3267 3266
    template <typename _Value>
3268 3267
    class ArcMap
3269 3268
      : public SubMapExtender<Adaptor, ArcMapBase<_Value> >
3270 3269
    {
3271 3270
    public:
3272 3271
      typedef _Value Value;
3273 3272
      typedef SubMapExtender<Adaptor, ArcMapBase<Value> > Parent;
3274 3273

	
3275 3274
      ArcMap(const Adaptor& adaptor)
3276 3275
        : Parent(adaptor) {}
3277 3276

	
3278 3277
      ArcMap(const Adaptor& adaptor, const Value& value)
3279 3278
        : Parent(adaptor, value) {}
3280 3279

	
3281 3280
    private:
3282 3281
      ArcMap& operator=(const ArcMap& cmap) {
3283 3282
        return operator=<ArcMap>(cmap);
3284 3283
      }
3285 3284

	
3286 3285
      template <typename CMap>
3287 3286
      ArcMap& operator=(const CMap& cmap) {
3288 3287
        Parent::operator=(cmap);
3289 3288
        return *this;
3290 3289
      }
3291 3290
    };
3292 3291

	
3293 3292
  protected:
3294 3293

	
3295 3294
    SplitNodesBase() : _digraph(0) {}
3296 3295

	
3297 3296
    Digraph* _digraph;
3298 3297

	
3299 3298
    void setDigraph(Digraph& digraph) {
3300 3299
      _digraph = &digraph;
3301 3300
    }
3302 3301

	
3303 3302
  };
3304 3303

	
3305 3304
  /// \ingroup graph_adaptors
3306 3305
  ///
3307 3306
  /// \brief Adaptor class for splitting the nodes of a digraph.
3308 3307
  ///
3309 3308
  /// SplitNodes adaptor can be used for splitting each node into an
3310 3309
  /// \e in-node and an \e out-node in a digraph. Formaly, the adaptor
3311 3310
  /// replaces each node \f$ u \f$ in the digraph with two nodes,
3312 3311
  /// namely node \f$ u_{in} \f$ and node \f$ u_{out} \f$.
3313 3312
  /// If there is a \f$ (v, u) \f$ arc in the original digraph, then the
3314 3313
  /// new target of the arc will be \f$ u_{in} \f$ and similarly the
3315 3314
  /// source of each original \f$ (u, v) \f$ arc will be \f$ u_{out} \f$.
3316 3315
  /// The adaptor adds an additional \e bind \e arc from \f$ u_{in} \f$
3317 3316
  /// to \f$ u_{out} \f$ for each node \f$ u \f$ of the original digraph.
3318 3317
  ///
3319 3318
  /// The aim of this class is running an algorithm with respect to node
3320 3319
  /// costs or capacities if the algorithm considers only arc costs or
3321 3320
  /// capacities directly.
3322 3321
  /// In this case you can use \c SplitNodes adaptor, and set the node
3323 3322
  /// costs/capacities of the original digraph to the \e bind \e arcs
3324 3323
  /// in the adaptor.
3325 3324
  ///
3326 3325
  /// \tparam GR The type of the adapted digraph.
3327 3326
  /// It must conform to the \ref concepts::Digraph "Digraph" concept.
3328 3327
  /// It is implicitly \c const.
3329 3328
  ///
3330 3329
  /// \note The \c Node type of this adaptor is converible to the \c Node
3331 3330
  /// type of the adapted digraph.
3332 3331
  template <typename GR>
3333 3332
#ifdef DOXYGEN
3334 3333
  class SplitNodes {
3335 3334
#else
3336 3335
  class SplitNodes
3337 3336
    : public DigraphAdaptorExtender<SplitNodesBase<const GR> > {
3338 3337
#endif
3339 3338
  public:
3340 3339
    typedef GR Digraph;
3341 3340
    typedef DigraphAdaptorExtender<SplitNodesBase<const GR> > Parent;
3342 3341

	
3343 3342
    typedef typename Digraph::Node DigraphNode;
3344 3343
    typedef typename Digraph::Arc DigraphArc;
3345 3344

	
3346 3345
    typedef typename Parent::Node Node;
3347 3346
    typedef typename Parent::Arc Arc;
3348 3347

	
3349 3348
    /// \brief Constructor
3350 3349
    ///
3351 3350
    /// Constructor of the adaptor.
3352 3351
    SplitNodes(const Digraph& g) {
3353 3352
      Parent::setDigraph(g);
3354 3353
    }
3355 3354

	
3356 3355
    /// \brief Returns \c true if the given node is an in-node.
3357 3356
    ///
3358 3357
    /// Returns \c true if the given node is an in-node.
3359 3358
    static bool inNode(const Node& n) {
3360 3359
      return Parent::inNode(n);
3361 3360
    }
3362 3361

	
3363 3362
    /// \brief Returns \c true if the given node is an out-node.
3364 3363
    ///
3365 3364
    /// Returns \c true if the given node is an out-node.
3366 3365
    static bool outNode(const Node& n) {
3367 3366
      return Parent::outNode(n);
3368 3367
    }
3369 3368

	
3370 3369
    /// \brief Returns \c true if the given arc is an original arc.
3371 3370
    ///
3372 3371
    /// Returns \c true if the given arc is one of the arcs in the
3373 3372
    /// original digraph.
3374 3373
    static bool origArc(const Arc& a) {
3375 3374
      return Parent::origArc(a);
3376 3375
    }
3377 3376

	
3378 3377
    /// \brief Returns \c true if the given arc is a bind arc.
3379 3378
    ///
3380 3379
    /// Returns \c true if the given arc is a bind arc, i.e. it connects
3381 3380
    /// an in-node and an out-node.
3382 3381
    static bool bindArc(const Arc& a) {
3383 3382
      return Parent::bindArc(a);
3384 3383
    }
3385 3384

	
3386 3385
    /// \brief Returns the in-node created from the given original node.
3387 3386
    ///
3388 3387
    /// Returns the in-node created from the given original node.
3389 3388
    static Node inNode(const DigraphNode& n) {
3390 3389
      return Parent::inNode(n);
3391 3390
    }
3392 3391

	
3393 3392
    /// \brief Returns the out-node created from the given original node.
3394 3393
    ///
3395 3394
    /// Returns the out-node created from the given original node.
3396 3395
    static Node outNode(const DigraphNode& n) {
3397 3396
      return Parent::outNode(n);
3398 3397
    }
3399 3398

	
3400 3399
    /// \brief Returns the bind arc that corresponds to the given
3401 3400
    /// original node.
3402 3401
    ///
3403 3402
    /// Returns the bind arc in the adaptor that corresponds to the given
3404 3403
    /// original node, i.e. the arc connecting the in-node and out-node
3405 3404
    /// of \c n.
3406 3405
    static Arc arc(const DigraphNode& n) {
3407 3406
      return Parent::arc(n);
3408 3407
    }
3409 3408

	
3410 3409
    /// \brief Returns the arc that corresponds to the given original arc.
3411 3410
    ///
3412 3411
    /// Returns the arc in the adaptor that corresponds to the given
3413 3412
    /// original arc.
3414 3413
    static Arc arc(const DigraphArc& a) {
3415 3414
      return Parent::arc(a);
3416 3415
    }
3417 3416

	
3418 3417
    /// \brief Node map combined from two original node maps
3419 3418
    ///
3420 3419
    /// This map adaptor class adapts two node maps of the original digraph
3421 3420
    /// to get a node map of the split digraph.
3422 3421
    /// Its value type is inherited from the first node map type
3423 3422
    /// (\c InNodeMap).
3424 3423
    template <typename InNodeMap, typename OutNodeMap>
3425 3424
    class CombinedNodeMap {
3426 3425
    public:
3427 3426

	
3428 3427
      /// The key type of the map
3429 3428
      typedef Node Key;
3430 3429
      /// The value type of the map
3431 3430
      typedef typename InNodeMap::Value Value;
3432 3431

	
3433 3432
      typedef typename MapTraits<InNodeMap>::ReferenceMapTag ReferenceMapTag;
3434 3433
      typedef typename MapTraits<InNodeMap>::ReturnValue ReturnValue;
3435 3434
      typedef typename MapTraits<InNodeMap>::ConstReturnValue ConstReturnValue;
3436 3435
      typedef typename MapTraits<InNodeMap>::ReturnValue Reference;
3437 3436
      typedef typename MapTraits<InNodeMap>::ConstReturnValue ConstReference;
3438 3437

	
3439 3438
      /// Constructor
3440 3439
      CombinedNodeMap(InNodeMap& in_map, OutNodeMap& out_map)
3441 3440
        : _in_map(in_map), _out_map(out_map) {}
3442 3441

	
3443 3442
      /// Returns the value associated with the given key.
3444 3443
      Value operator[](const Key& key) const {
3445 3444
        if (Parent::inNode(key)) {
3446 3445
          return _in_map[key];
3447 3446
        } else {
3448 3447
          return _out_map[key];
3449 3448
        }
3450 3449
      }
3451 3450

	
3452 3451
      /// Returns a reference to the value associated with the given key.
3453 3452
      Value& operator[](const Key& key) {
3454 3453
        if (Parent::inNode(key)) {
3455 3454
          return _in_map[key];
3456 3455
        } else {
3457 3456
          return _out_map[key];
3458 3457
        }
3459 3458
      }
3460 3459

	
3461 3460
      /// Sets the value associated with the given key.
3462 3461
      void set(const Key& key, const Value& value) {
3463 3462
        if (Parent::inNode(key)) {
3464 3463
          _in_map.set(key, value);
3465 3464
        } else {
3466 3465
          _out_map.set(key, value);
3467 3466
        }
3468 3467
      }
3469 3468

	
3470 3469
    private:
3471 3470

	
3472 3471
      InNodeMap& _in_map;
3473 3472
      OutNodeMap& _out_map;
3474 3473

	
3475 3474
    };
3476 3475

	
3477 3476

	
3478 3477
    /// \brief Returns a combined node map
3479 3478
    ///
3480 3479
    /// This function just returns a combined node map.
3481 3480
    template <typename InNodeMap, typename OutNodeMap>
3482 3481
    static CombinedNodeMap<InNodeMap, OutNodeMap>
3483 3482
    combinedNodeMap(InNodeMap& in_map, OutNodeMap& out_map) {
3484 3483
      return CombinedNodeMap<InNodeMap, OutNodeMap>(in_map, out_map);
3485 3484
    }
3486 3485

	
3487 3486
    template <typename InNodeMap, typename OutNodeMap>
3488 3487
    static CombinedNodeMap<const InNodeMap, OutNodeMap>
3489 3488
    combinedNodeMap(const InNodeMap& in_map, OutNodeMap& out_map) {
3490 3489
      return CombinedNodeMap<const InNodeMap, OutNodeMap>(in_map, out_map);
3491 3490
    }
3492 3491

	
3493 3492
    template <typename InNodeMap, typename OutNodeMap>
3494 3493
    static CombinedNodeMap<InNodeMap, const OutNodeMap>
3495 3494
    combinedNodeMap(InNodeMap& in_map, const OutNodeMap& out_map) {
3496 3495
      return CombinedNodeMap<InNodeMap, const OutNodeMap>(in_map, out_map);
3497 3496
    }
3498 3497

	
3499 3498
    template <typename InNodeMap, typename OutNodeMap>
3500 3499
    static CombinedNodeMap<const InNodeMap, const OutNodeMap>
3501 3500
    combinedNodeMap(const InNodeMap& in_map, const OutNodeMap& out_map) {
3502 3501
      return CombinedNodeMap<const InNodeMap,
3503 3502
        const OutNodeMap>(in_map, out_map);
3504 3503
    }
3505 3504

	
3506 3505
    /// \brief Arc map combined from an arc map and a node map of the
3507 3506
    /// original digraph.
3508 3507
    ///
3509 3508
    /// This map adaptor class adapts an arc map and a node map of the
3510 3509
    /// original digraph to get an arc map of the split digraph.
3511 3510
    /// Its value type is inherited from the original arc map type
3512 3511
    /// (\c ArcMap).
3513 3512
    template <typename ArcMap, typename NodeMap>
3514 3513
    class CombinedArcMap {
3515 3514
    public:
3516 3515

	
3517 3516
      /// The key type of the map
3518 3517
      typedef Arc Key;
3519 3518
      /// The value type of the map
3520 3519
      typedef typename ArcMap::Value Value;
3521 3520

	
3522 3521
      typedef typename MapTraits<ArcMap>::ReferenceMapTag ReferenceMapTag;
3523 3522
      typedef typename MapTraits<ArcMap>::ReturnValue ReturnValue;
3524 3523
      typedef typename MapTraits<ArcMap>::ConstReturnValue ConstReturnValue;
3525 3524
      typedef typename MapTraits<ArcMap>::ReturnValue Reference;
3526 3525
      typedef typename MapTraits<ArcMap>::ConstReturnValue ConstReference;
3527 3526

	
3528 3527
      /// Constructor
3529 3528
      CombinedArcMap(ArcMap& arc_map, NodeMap& node_map)
3530 3529
        : _arc_map(arc_map), _node_map(node_map) {}
3531 3530

	
3532 3531
      /// Returns the value associated with the given key.
3533 3532
      Value operator[](const Key& arc) const {
3534 3533
        if (Parent::origArc(arc)) {
3535 3534
          return _arc_map[arc];
3536 3535
        } else {
3537 3536
          return _node_map[arc];
3538 3537
        }
3539 3538
      }
3540 3539

	
3541 3540
      /// Returns a reference to the value associated with the given key.
3542 3541
      Value& operator[](const Key& arc) {
3543 3542
        if (Parent::origArc(arc)) {
3544 3543
          return _arc_map[arc];
3545 3544
        } else {
3546 3545
          return _node_map[arc];
3547 3546
        }
3548 3547
      }
3549 3548

	
3550 3549
      /// Sets the value associated with the given key.
3551 3550
      void set(const Arc& arc, const Value& val) {
3552 3551
        if (Parent::origArc(arc)) {
3553 3552
          _arc_map.set(arc, val);
3554 3553
        } else {
3555 3554
          _node_map.set(arc, val);
3556 3555
        }
3557 3556
      }
3558 3557

	
3559 3558
    private:
3560 3559
      ArcMap& _arc_map;
3561 3560
      NodeMap& _node_map;
3562 3561
    };
3563 3562

	
3564 3563
    /// \brief Returns a combined arc map
3565 3564
    ///
3566 3565
    /// This function just returns a combined arc map.
3567 3566
    template <typename ArcMap, typename NodeMap>
3568 3567
    static CombinedArcMap<ArcMap, NodeMap>
3569 3568
    combinedArcMap(ArcMap& arc_map, NodeMap& node_map) {
3570 3569
      return CombinedArcMap<ArcMap, NodeMap>(arc_map, node_map);
3571 3570
    }
3572 3571

	
3573 3572
    template <typename ArcMap, typename NodeMap>
3574 3573
    static CombinedArcMap<const ArcMap, NodeMap>
3575 3574
    combinedArcMap(const ArcMap& arc_map, NodeMap& node_map) {
3576 3575
      return CombinedArcMap<const ArcMap, NodeMap>(arc_map, node_map);
3577 3576
    }
3578 3577

	
3579 3578
    template <typename ArcMap, typename NodeMap>
3580 3579
    static CombinedArcMap<ArcMap, const NodeMap>
3581 3580
    combinedArcMap(ArcMap& arc_map, const NodeMap& node_map) {
3582 3581
      return CombinedArcMap<ArcMap, const NodeMap>(arc_map, node_map);
3583 3582
    }
3584 3583

	
3585 3584
    template <typename ArcMap, typename NodeMap>
3586 3585
    static CombinedArcMap<const ArcMap, const NodeMap>
3587 3586
    combinedArcMap(const ArcMap& arc_map, const NodeMap& node_map) {
3588 3587
      return CombinedArcMap<const ArcMap, const NodeMap>(arc_map, node_map);
3589 3588
    }
3590 3589

	
3591 3590
  };
3592 3591

	
3593 3592
  /// \brief Returns a (read-only) SplitNodes adaptor
3594 3593
  ///
3595 3594
  /// This function just returns a (read-only) \ref SplitNodes adaptor.
3596 3595
  /// \ingroup graph_adaptors
3597 3596
  /// \relates SplitNodes
3598 3597
  template<typename GR>
3599 3598
  SplitNodes<GR>
3600 3599
  splitNodes(const GR& digraph) {
3601 3600
    return SplitNodes<GR>(digraph);
3602 3601
  }
3603 3602

	
3604 3603
} //namespace lemon
3605 3604

	
3606 3605
#endif //LEMON_ADAPTORS_H
Ignore white space 6 line context
1 1
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
2 2

	
3 3
LINK_DIRECTORIES(${CMAKE_BINARY_DIR}/lemon)
4 4

	
5 5
SET(TESTS
6
  adaptors_test
6 7
  bfs_test
7 8
  circulation_test
8 9
  counter_test
9 10
  dfs_test
10 11
  digraph_test
11 12
  dijkstra_test
12 13
  dim_test
13 14
  error_test
14
  graph_adaptor_test
15 15
  graph_copy_test
16 16
  graph_test
17 17
  graph_utils_test
18 18
  hao_orlin_test
19 19
  heap_test
20 20
  kruskal_test
21 21
  lp_test
22 22
  mip_test
23 23
  maps_test
24 24
  max_matching_test
25 25
  radix_sort_test
26 26
  path_test
27 27
  preflow_test
28 28
  random_test
29 29
  suurballe_test
30 30
  time_measure_test
31 31
  unionfind_test)
32 32

	
33 33
FOREACH(TEST_NAME ${TESTS})
34 34
  ADD_EXECUTABLE(${TEST_NAME} ${TEST_NAME}.cc)
35 35
  TARGET_LINK_LIBRARIES(${TEST_NAME} lemon)
36 36
  ADD_TEST(${TEST_NAME} ${TEST_NAME})
37 37
ENDFOREACH(TEST_NAME)
Ignore white space 6 line context
1 1
EXTRA_DIST += \
2 2
	test/CMakeLists.txt
3 3

	
4 4
noinst_HEADERS += \
5 5
	test/graph_test.h \
6 6
	test/test_tools.h
7 7

	
8 8
check_PROGRAMS += \
9
	test/adaptors_test \
9 10
	test/bfs_test \
10 11
	test/circulation_test \
11 12
	test/counter_test \
12 13
	test/dfs_test \
13 14
	test/digraph_test \
14 15
	test/dijkstra_test \
15 16
	test/dim_test \
16 17
	test/error_test \
17
	test/graph_adaptor_test \
18 18
	test/graph_copy_test \
19 19
	test/graph_test \
20 20
	test/graph_utils_test \
21 21
	test/hao_orlin_test \
22 22
	test/heap_test \
23 23
	test/kruskal_test \
24 24
	test/maps_test \
25 25
	test/max_matching_test \
26 26
	test/path_test \
27 27
	test/preflow_test \
28 28
	test/radix_sort_test \
29 29
	test/random_test \
30 30
	test/suurballe_test \
31 31
	test/test_tools_fail \
32 32
	test/test_tools_pass \
33 33
	test/time_measure_test \
34 34
	test/unionfind_test
35 35

	
36 36
if HAVE_LP
37 37
check_PROGRAMS += test/lp_test
38 38
endif HAVE_LP
39 39
if HAVE_MIP
40 40
check_PROGRAMS += test/mip_test
41 41
endif HAVE_MIP
42 42

	
43 43
TESTS += $(check_PROGRAMS)
44 44
XFAIL_TESTS += test/test_tools_fail$(EXEEXT)
45 45

	
46
test_adaptors_test_SOURCES = test/adaptors_test.cc
46 47
test_bfs_test_SOURCES = test/bfs_test.cc
47 48
test_circulation_test_SOURCES = test/circulation_test.cc
48 49
test_counter_test_SOURCES = test/counter_test.cc
49 50
test_dfs_test_SOURCES = test/dfs_test.cc
50 51
test_digraph_test_SOURCES = test/digraph_test.cc
51 52
test_dijkstra_test_SOURCES = test/dijkstra_test.cc
52 53
test_dim_test_SOURCES = test/dim_test.cc
53 54
test_error_test_SOURCES = test/error_test.cc
54
test_graph_adaptor_test_SOURCES = test/graph_adaptor_test.cc
55 55
test_graph_copy_test_SOURCES = test/graph_copy_test.cc
56 56
test_graph_test_SOURCES = test/graph_test.cc
57 57
test_graph_utils_test_SOURCES = test/graph_utils_test.cc
58 58
test_heap_test_SOURCES = test/heap_test.cc
59 59
test_kruskal_test_SOURCES = test/kruskal_test.cc
60 60
test_hao_orlin_test_SOURCES = test/hao_orlin_test.cc
61 61
test_lp_test_SOURCES = test/lp_test.cc
62 62
test_maps_test_SOURCES = test/maps_test.cc
63 63
test_mip_test_SOURCES = test/mip_test.cc
64 64
test_max_matching_test_SOURCES = test/max_matching_test.cc
65 65
test_path_test_SOURCES = test/path_test.cc
66 66
test_preflow_test_SOURCES = test/preflow_test.cc
67 67
test_radix_sort_test_SOURCES = test/radix_sort_test.cc
68 68
test_suurballe_test_SOURCES = test/suurballe_test.cc
69 69
test_random_test_SOURCES = test/random_test.cc
70 70
test_test_tools_fail_SOURCES = test/test_tools_fail.cc
71 71
test_test_tools_pass_SOURCES = test/test_tools_pass.cc
72 72
test_time_measure_test_SOURCES = test/time_measure_test.cc
73 73
test_unionfind_test_SOURCES = test/unionfind_test.cc
Ignore white space 6 line context
1 1
/* -*- mode: C++; indent-tabs-mode: nil; -*-
2 2
 *
3 3
 * This file is a part of LEMON, a generic C++ optimization library.
4 4
 *
5 5
 * Copyright (C) 2003-2009
6 6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8 8
 *
9 9
 * Permission to use, modify and distribute this software is granted
10 10
 * provided that this copyright notice appears in all copies. For
11 11
 * precise terms see the accompanying LICENSE file.
12 12
 *
13 13
 * This software is provided "AS IS" with no warranty of any kind,
14 14
 * express or implied, and with no claim as to its suitability for any
15 15
 * purpose.
16 16
 *
17 17
 */
18 18

	
19
#include<iostream>
20
#include<lemon/concept_check.h>
19
#include <iostream>
20
#include <limits>
21 21

	
22
#include<lemon/list_graph.h>
23
#include<lemon/smart_graph.h>
24

	
25
#include<lemon/concepts/digraph.h>
26
#include<lemon/concepts/graph.h>
27

	
28
#include<lemon/adaptors.h>
29

	
30
#include <limits>
22
#include <lemon/list_graph.h>
23
#include <lemon/grid_graph.h>
31 24
#include <lemon/bfs.h>
32 25
#include <lemon/path.h>
33 26

	
34
#include"test/test_tools.h"
35
#include"test/graph_test.h"
27
#include <lemon/concepts/digraph.h>
28
#include <lemon/concepts/graph.h>
29
#include <lemon/concepts/graph_components.h>
30
#include <lemon/concepts/maps.h>
31
#include <lemon/concept_check.h>
32

	
33
#include <lemon/adaptors.h>
34

	
35
#include "test/test_tools.h"
36
#include "test/graph_test.h"
36 37

	
37 38
using namespace lemon;
38 39

	
39 40
void checkReverseDigraph() {
41
  // Check concepts
40 42
  checkConcept<concepts::Digraph, ReverseDigraph<concepts::Digraph> >();
43
  checkConcept<concepts::Digraph, ReverseDigraph<ListDigraph> >();
44
  checkConcept<concepts::AlterableDigraphComponent<>,
45
               ReverseDigraph<ListDigraph> >();
46
  checkConcept<concepts::ExtendableDigraphComponent<>,
47
               ReverseDigraph<ListDigraph> >();
48
  checkConcept<concepts::ErasableDigraphComponent<>,
49
               ReverseDigraph<ListDigraph> >();
50
  checkConcept<concepts::ClearableDigraphComponent<>,
51
               ReverseDigraph<ListDigraph> >();
41 52

	
53
  // Create a digraph and an adaptor
42 54
  typedef ListDigraph Digraph;
43 55
  typedef ReverseDigraph<Digraph> Adaptor;
44 56

	
45 57
  Digraph digraph;
46 58
  Adaptor adaptor(digraph);
47 59

	
60
  // Add nodes and arcs to the original digraph
48 61
  Digraph::Node n1 = digraph.addNode();
49 62
  Digraph::Node n2 = digraph.addNode();
50 63
  Digraph::Node n3 = digraph.addNode();
51 64

	
52 65
  Digraph::Arc a1 = digraph.addArc(n1, n2);
53 66
  Digraph::Arc a2 = digraph.addArc(n1, n3);
54 67
  Digraph::Arc a3 = digraph.addArc(n2, n3);
55 68

	
69
  // Check the adaptor
56 70
  checkGraphNodeList(adaptor, 3);
57 71
  checkGraphArcList(adaptor, 3);
58 72
  checkGraphConArcList(adaptor, 3);
59 73

	
60 74
  checkGraphOutArcList(adaptor, n1, 0);
61 75
  checkGraphOutArcList(adaptor, n2, 1);
62 76
  checkGraphOutArcList(adaptor, n3, 2);
63 77

	
64 78
  checkGraphInArcList(adaptor, n1, 2);
65 79
  checkGraphInArcList(adaptor, n2, 1);
66 80
  checkGraphInArcList(adaptor, n3, 0);
67 81

	
68 82
  checkNodeIds(adaptor);
69 83
  checkArcIds(adaptor);
70 84

	
71 85
  checkGraphNodeMap(adaptor);
72 86
  checkGraphArcMap(adaptor);
73 87

	
88
  // Check the orientation of the arcs
74 89
  for (Adaptor::ArcIt a(adaptor); a != INVALID; ++a) {
75 90
    check(adaptor.source(a) == digraph.target(a), "Wrong reverse");
76 91
    check(adaptor.target(a) == digraph.source(a), "Wrong reverse");
77 92
  }
93

	
94
  // Add and erase nodes and arcs in the digraph through the adaptor
95
  Adaptor::Node n4 = adaptor.addNode();
96

	
97
  Adaptor::Arc a4 = adaptor.addArc(n4, n3);
98
  Adaptor::Arc a5 = adaptor.addArc(n2, n4);
99
  Adaptor::Arc a6 = adaptor.addArc(n2, n4);
100
  Adaptor::Arc a7 = adaptor.addArc(n1, n4);
101
  Adaptor::Arc a8 = adaptor.addArc(n1, n2);
102

	
103
  adaptor.erase(a1);
104
  adaptor.erase(n3);
105

	
106
  // Check the adaptor
107
  checkGraphNodeList(adaptor, 3);
108
  checkGraphArcList(adaptor, 4);
109
  checkGraphConArcList(adaptor, 4);
110

	
111
  checkGraphOutArcList(adaptor, n1, 2);
112
  checkGraphOutArcList(adaptor, n2, 2);
113
  checkGraphOutArcList(adaptor, n4, 0);
114

	
115
  checkGraphInArcList(adaptor, n1, 0);
116
  checkGraphInArcList(adaptor, n2, 1);
117
  checkGraphInArcList(adaptor, n4, 3);
118

	
119
  checkNodeIds(adaptor);
120
  checkArcIds(adaptor);
121

	
122
  checkGraphNodeMap(adaptor);
123
  checkGraphArcMap(adaptor);
124

	
125
  // Check the digraph
126
  checkGraphNodeList(digraph, 3);
127
  checkGraphArcList(digraph, 4);
128
  checkGraphConArcList(digraph, 4);
129

	
130
  checkGraphOutArcList(digraph, n1, 0);
131
  checkGraphOutArcList(digraph, n2, 1);
132
  checkGraphOutArcList(digraph, n4, 3);
133

	
134
  checkGraphInArcList(digraph, n1, 2);
135
  checkGraphInArcList(digraph, n2, 2);
136
  checkGraphInArcList(digraph, n4, 0);
137

	
138
  checkNodeIds(digraph);
139
  checkArcIds(digraph);
140

	
141
  checkGraphNodeMap(digraph);
142
  checkGraphArcMap(digraph);
143

	
144
  // Check the conversion of nodes and arcs
145
  Digraph::Node nd = n4;
146
  nd = n4;
147
  Adaptor::Node na = n1;
148
  na = n2;
149
  Digraph::Arc ad = a4;
150
  ad = a5;
151
  Adaptor::Arc aa = a1;
152
  aa = a2;
78 153
}
79 154

	
80 155
void checkSubDigraph() {
81
  checkConcept<concepts::Digraph,
82
    SubDigraph<concepts::Digraph,
83
    concepts::Digraph::NodeMap<bool>,
84
    concepts::Digraph::ArcMap<bool> > >();
156
  // Check concepts
157
  checkConcept<concepts::Digraph, SubDigraph<concepts::Digraph> >();
158
  checkConcept<concepts::Digraph, SubDigraph<ListDigraph> >();
159
  checkConcept<concepts::AlterableDigraphComponent<>,
160
               SubDigraph<ListDigraph> >();
161
  checkConcept<concepts::ExtendableDigraphComponent<>,
162
               SubDigraph<ListDigraph> >();
163
  checkConcept<concepts::ErasableDigraphComponent<>,
164
               SubDigraph<ListDigraph> >();
165
  checkConcept<concepts::ClearableDigraphComponent<>,
166
               SubDigraph<ListDigraph> >();
85 167

	
168
  // Create a digraph and an adaptor
86 169
  typedef ListDigraph Digraph;
87 170
  typedef Digraph::NodeMap<bool> NodeFilter;
88 171
  typedef Digraph::ArcMap<bool> ArcFilter;
89 172
  typedef SubDigraph<Digraph, NodeFilter, ArcFilter> Adaptor;
90 173

	
91 174
  Digraph digraph;
92 175
  NodeFilter node_filter(digraph);
93 176
  ArcFilter arc_filter(digraph);
94 177
  Adaptor adaptor(digraph, node_filter, arc_filter);
95 178

	
179
  // Add nodes and arcs to the original digraph and the adaptor
96 180
  Digraph::Node n1 = digraph.addNode();
97 181
  Digraph::Node n2 = digraph.addNode();
98
  Digraph::Node n3 = digraph.addNode();
182
  Adaptor::Node n3 = adaptor.addNode();
183

	
184
  node_filter[n1] = node_filter[n2] = node_filter[n3] = true;
99 185

	
100 186
  Digraph::Arc a1 = digraph.addArc(n1, n2);
101 187
  Digraph::Arc a2 = digraph.addArc(n1, n3);
102
  Digraph::Arc a3 = digraph.addArc(n2, n3);
103

	
104
  node_filter[n1] = node_filter[n2] = node_filter[n3] = true;
105
  arc_filter[a1] = arc_filter[a2] = arc_filter[a3] = true;
106

	
107
  checkGraphNodeList(adaptor, 3);
108
  checkGraphArcList(adaptor, 3);
109
  checkGraphConArcList(adaptor, 3);
110

	
111
  checkGraphOutArcList(adaptor, n1, 2);
112
  checkGraphOutArcList(adaptor, n2, 1);
113
  checkGraphOutArcList(adaptor, n3, 0);
114

	
115
  checkGraphInArcList(adaptor, n1, 0);
116
  checkGraphInArcList(adaptor, n2, 1);
117
  checkGraphInArcList(adaptor, n3, 2);
118

	
119
  checkNodeIds(adaptor);
120
  checkArcIds(adaptor);
121

	
122
  checkGraphNodeMap(adaptor);
123
  checkGraphArcMap(adaptor);
124

	
125
  arc_filter[a2] = false;
126

	
127
  checkGraphNodeList(adaptor, 3);
128
  checkGraphArcList(adaptor, 2);
129
  checkGraphConArcList(adaptor, 2);
130

	
131
  checkGraphOutArcList(adaptor, n1, 1);
132
  checkGraphOutArcList(adaptor, n2, 1);
133
  checkGraphOutArcList(adaptor, n3, 0);
134

	
135
  checkGraphInArcList(adaptor, n1, 0);
136
  checkGraphInArcList(adaptor, n2, 1);
137
  checkGraphInArcList(adaptor, n3, 1);
138

	
139
  checkNodeIds(adaptor);
140
  checkArcIds(adaptor);
141

	
142
  checkGraphNodeMap(adaptor);
143
  checkGraphArcMap(adaptor);
144

	
145
  node_filter[n1] = false;
146

	
147
  checkGraphNodeList(adaptor, 2);
148
  checkGraphArcList(adaptor, 1);
149
  checkGraphConArcList(adaptor, 1);
150

	
151
  checkGraphOutArcList(adaptor, n2, 1);
152
  checkGraphOutArcList(adaptor, n3, 0);
153

	
154
  checkGraphInArcList(adaptor, n2, 0);
155
  checkGraphInArcList(adaptor, n3, 1);
156

	
157
  checkNodeIds(adaptor);
158
  checkArcIds(adaptor);
159

	
160
  checkGraphNodeMap(adaptor);
161
  checkGraphArcMap(adaptor);
162

	
163
  node_filter[n1] = node_filter[n2] = node_filter[n3] = false;
164
  arc_filter[a1] = arc_filter[a2] = arc_filter[a3] = false;
165

	
166
  checkGraphNodeList(adaptor, 0);
167
  checkGraphArcList(adaptor, 0);
168
  checkGraphConArcList(adaptor, 0);
169

	
170
  checkNodeIds(adaptor);
171
  checkArcIds(adaptor);
172

	
173
  checkGraphNodeMap(adaptor);
174
  checkGraphArcMap(adaptor);
175
}
176

	
177
void checkFilterNodes1() {
178
  checkConcept<concepts::Digraph,
179
    FilterNodes<concepts::Digraph,
180
      concepts::Digraph::NodeMap<bool> > >();
181

	
182
  typedef ListDigraph Digraph;
183
  typedef Digraph::NodeMap<bool> NodeFilter;
184
  typedef FilterNodes<Digraph, NodeFilter> Adaptor;
185

	
186
  Digraph digraph;
187
  NodeFilter node_filter(digraph);
188
  Adaptor adaptor(digraph, node_filter);
189

	
190
  Digraph::Node n1 = digraph.addNode();
191
  Digraph::Node n2 = digraph.addNode();
192
  Digraph::Node n3 = digraph.addNode();
193

	
194
  Digraph::Arc a1 = digraph.addArc(n1, n2);
195
  Digraph::Arc a2 = digraph.addArc(n1, n3);
196
  Digraph::Arc a3 = digraph.addArc(n2, n3);
197

	
198
  node_filter[n1] = node_filter[n2] = node_filter[n3] = true;
199

	
200
  checkGraphNodeList(adaptor, 3);
201
  checkGraphArcList(adaptor, 3);
202
  checkGraphConArcList(adaptor, 3);
203

	
204
  checkGraphOutArcList(adaptor, n1, 2);
205
  checkGraphOutArcList(adaptor, n2, 1);
206
  checkGraphOutArcList(adaptor, n3, 0);
207

	
208
  checkGraphInArcList(adaptor, n1, 0);
209
  checkGraphInArcList(adaptor, n2, 1);
210
  checkGraphInArcList(adaptor, n3, 2);
211

	
212
  checkNodeIds(adaptor);
213
  checkArcIds(adaptor);
214

	
215
  checkGraphNodeMap(adaptor);
216
  checkGraphArcMap(adaptor);
217

	
218
  node_filter[n1] = false;
219

	
220
  checkGraphNodeList(adaptor, 2);
221
  checkGraphArcList(adaptor, 1);
222
  checkGraphConArcList(adaptor, 1);
223

	
224
  checkGraphOutArcList(adaptor, n2, 1);
225
  checkGraphOutArcList(adaptor, n3, 0);
226

	
227
  checkGraphInArcList(adaptor, n2, 0);
228
  checkGraphInArcList(adaptor, n3, 1);
229

	
230
  checkNodeIds(adaptor);
231
  checkArcIds(adaptor);
232

	
233
  checkGraphNodeMap(adaptor);
234
  checkGraphArcMap(adaptor);
235

	
236
  node_filter[n1] = node_filter[n2] = node_filter[n3] = false;
237

	
238
  checkGraphNodeList(adaptor, 0);
239
  checkGraphArcList(adaptor, 0);
240
  checkGraphConArcList(adaptor, 0);
241

	
242
  checkNodeIds(adaptor);
243
  checkArcIds(adaptor);
244

	
245
  checkGraphNodeMap(adaptor);
246
  checkGraphArcMap(adaptor);
247
}
248

	
249
void checkFilterArcs() {
250
  checkConcept<concepts::Digraph,
251
    FilterArcs<concepts::Digraph,
252
    concepts::Digraph::ArcMap<bool> > >();
253

	
254
  typedef ListDigraph Digraph;
255
  typedef Digraph::ArcMap<bool> ArcFilter;
256
  typedef FilterArcs<Digraph, ArcFilter> Adaptor;
257

	
258
  Digraph digraph;
259
  ArcFilter arc_filter(digraph);
260
  Adaptor adaptor(digraph, arc_filter);
261

	
262
  Digraph::Node n1 = digraph.addNode();
263
  Digraph::Node n2 = digraph.addNode();
264
  Digraph::Node n3 = digraph.addNode();
265

	
266
  Digraph::Arc a1 = digraph.addArc(n1, n2);
267
  Digraph::Arc a2 = digraph.addArc(n1, n3);
268
  Digraph::Arc a3 = digraph.addArc(n2, n3);
188
  Adaptor::Arc a3 = adaptor.addArc(n2, n3);
269 189

	
270 190
  arc_filter[a1] = arc_filter[a2] = arc_filter[a3] = true;
271 191

	
272 192
  checkGraphNodeList(adaptor, 3);
273 193
  checkGraphArcList(adaptor, 3);
274 194
  checkGraphConArcList(adaptor, 3);
275 195

	
276 196
  checkGraphOutArcList(adaptor, n1, 2);
277 197
  checkGraphOutArcList(adaptor, n2, 1);
278 198
  checkGraphOutArcList(adaptor, n3, 0);
279 199

	
280 200
  checkGraphInArcList(adaptor, n1, 0);
281 201
  checkGraphInArcList(adaptor, n2, 1);
282 202
  checkGraphInArcList(adaptor, n3, 2);
283 203

	
284 204
  checkNodeIds(adaptor);
285 205
  checkArcIds(adaptor);
286 206

	
287 207
  checkGraphNodeMap(adaptor);
288 208
  checkGraphArcMap(adaptor);
289 209

	
290
  arc_filter[a2] = false;
210
  // Hide an arc
211
  adaptor.status(a2, false);
212
  adaptor.disable(a3);
213
  if (!adaptor.status(a3)) adaptor.enable(a3);
291 214

	
292 215
  checkGraphNodeList(adaptor, 3);
293 216
  checkGraphArcList(adaptor, 2);
294 217
  checkGraphConArcList(adaptor, 2);
295 218

	
296 219
  checkGraphOutArcList(adaptor, n1, 1);
297 220
  checkGraphOutArcList(adaptor, n2, 1);
298 221
  checkGraphOutArcList(adaptor, n3, 0);
299 222

	
300 223
  checkGraphInArcList(adaptor, n1, 0);
301 224
  checkGraphInArcList(adaptor, n2, 1);
302 225
  checkGraphInArcList(adaptor, n3, 1);
303 226

	
304 227
  checkNodeIds(adaptor);
305 228
  checkArcIds(adaptor);
306 229

	
307 230
  checkGraphNodeMap(adaptor);
308 231
  checkGraphArcMap(adaptor);
309 232

	
233
  // Hide a node
234
  adaptor.status(n1, false);
235
  adaptor.disable(n3);
236
  if (!adaptor.status(n3)) adaptor.enable(n3);
237

	
238
  checkGraphNodeList(adaptor, 2);
239
  checkGraphArcList(adaptor, 1);
240
  checkGraphConArcList(adaptor, 1);
241

	
242
  checkGraphOutArcList(adaptor, n2, 1);
243
  checkGraphOutArcList(adaptor, n3, 0);
244

	
245
  checkGraphInArcList(adaptor, n2, 0);
246
  checkGraphInArcList(adaptor, n3, 1);
247

	
248
  checkNodeIds(adaptor);
249
  checkArcIds(adaptor);
250

	
251
  checkGraphNodeMap(adaptor);
252
  checkGraphArcMap(adaptor);
253

	
254
  // Hide all nodes and arcs
255
  node_filter[n1] = node_filter[n2] = node_filter[n3] = false;
256
  arc_filter[a1] = arc_filter[a2] = arc_filter[a3] = false;
257

	
258
  checkGraphNodeList(adaptor, 0);
259
  checkGraphArcList(adaptor, 0);
260
  checkGraphConArcList(adaptor, 0);
261

	
262
  checkNodeIds(adaptor);
263
  checkArcIds(adaptor);
264

	
265
  checkGraphNodeMap(adaptor);
266
  checkGraphArcMap(adaptor);
267

	
268
  // Check the conversion of nodes and arcs
269
  Digraph::Node nd = n3;
270
  nd = n3;
271
  Adaptor::Node na = n1;
272
  na = n2;
273
  Digraph::Arc ad = a3;
274
  ad = a3;
275
  Adaptor::Arc aa = a1;
276
  aa = a2;
277
}
278

	
279
void checkFilterNodes1() {
280
  // Check concepts
281
  checkConcept<concepts::Digraph, FilterNodes<concepts::Digraph> >();
282
  checkConcept<concepts::Digraph, FilterNodes<ListDigraph> >();
283
  checkConcept<concepts::AlterableDigraphComponent<>,
284
               FilterNodes<ListDigraph> >();
285
  checkConcept<concepts::ExtendableDigraphComponent<>,
286
               FilterNodes<ListDigraph> >();
287
  checkConcept<concepts::ErasableDigraphComponent<>,
288
               FilterNodes<ListDigraph> >();
289
  checkConcept<concepts::ClearableDigraphComponent<>,
290
               FilterNodes<ListDigraph> >();
291

	
292
  // Create a digraph and an adaptor
293
  typedef ListDigraph Digraph;
294
  typedef Digraph::NodeMap<bool> NodeFilter;
295
  typedef FilterNodes<Digraph, NodeFilter> Adaptor;
296

	
297
  Digraph digraph;
298
  NodeFilter node_filter(digraph);
299
  Adaptor adaptor(digraph, node_filter);
300

	
301
  // Add nodes and arcs to the original digraph and the adaptor
302
  Digraph::Node n1 = digraph.addNode();
303
  Digraph::Node n2 = digraph.addNode();
304
  Adaptor::Node n3 = adaptor.addNode();
305

	
306
  node_filter[n1] = node_filter[n2] = node_filter[n3] = true;
307

	
308
  Digraph::Arc a1 = digraph.addArc(n1, n2);
309
  Digraph::Arc a2 = digraph.addArc(n1, n3);
310
  Adaptor::Arc a3 = adaptor.addArc(n2, n3);
311

	
312
  checkGraphNodeList(adaptor, 3);
313
  checkGraphArcList(adaptor, 3);
314
  checkGraphConArcList(adaptor, 3);
315

	
316
  checkGraphOutArcList(adaptor, n1, 2);
317
  checkGraphOutArcList(adaptor, n2, 1);
318
  checkGraphOutArcList(adaptor, n3, 0);
319

	
320
  checkGraphInArcList(adaptor, n1, 0);
321
  checkGraphInArcList(adaptor, n2, 1);
322
  checkGraphInArcList(adaptor, n3, 2);
323

	
324
  checkNodeIds(adaptor);
325
  checkArcIds(adaptor);
326

	
327
  checkGraphNodeMap(adaptor);
328
  checkGraphArcMap(adaptor);
329

	
330
  // Hide a node
331
  adaptor.status(n1, false);
332
  adaptor.disable(n3);
333
  if (!adaptor.status(n3)) adaptor.enable(n3);
334

	
335
  checkGraphNodeList(adaptor, 2);
336
  checkGraphArcList(adaptor, 1);
337
  checkGraphConArcList(adaptor, 1);
338

	
339
  checkGraphOutArcList(adaptor, n2, 1);
340
  checkGraphOutArcList(adaptor, n3, 0);
341

	
342
  checkGraphInArcList(adaptor, n2, 0);
343
  checkGraphInArcList(adaptor, n3, 1);
344

	
345
  checkNodeIds(adaptor);
346
  checkArcIds(adaptor);
347

	
348
  checkGraphNodeMap(adaptor);
349
  checkGraphArcMap(adaptor);
350

	
351
  // Hide all nodes
352
  node_filter[n1] = node_filter[n2] = node_filter[n3] = false;
353

	
354
  checkGraphNodeList(adaptor, 0);
355
  checkGraphArcList(adaptor, 0);
356
  checkGraphConArcList(adaptor, 0);
357

	
358
  checkNodeIds(adaptor);
359
  checkArcIds(adaptor);
360

	
361
  checkGraphNodeMap(adaptor);
362
  checkGraphArcMap(adaptor);
363

	
364
  // Check the conversion of nodes and arcs
365
  Digraph::Node nd = n3;
366
  nd = n3;
367
  Adaptor::Node na = n1;
368
  na = n2;
369
  Digraph::Arc ad = a3;
370
  ad = a3;
371
  Adaptor::Arc aa = a1;
372
  aa = a2;
373
}
374

	
375
void checkFilterArcs() {
376
  // Check concepts
377
  checkConcept<concepts::Digraph, FilterArcs<concepts::Digraph> >();
378
  checkConcept<concepts::Digraph, FilterArcs<ListDigraph> >();
379
  checkConcept<concepts::AlterableDigraphComponent<>,
380
               FilterArcs<ListDigraph> >();
381
  checkConcept<concepts::ExtendableDigraphComponent<>,
382
               FilterArcs<ListDigraph> >();
383
  checkConcept<concepts::ErasableDigraphComponent<>,
384
               FilterArcs<ListDigraph> >();
385
  checkConcept<concepts::ClearableDigraphComponent<>,
386
               FilterArcs<ListDigraph> >();
387

	
388
  // Create a digraph and an adaptor
389
  typedef ListDigraph Digraph;
390
  typedef Digraph::ArcMap<bool> ArcFilter;
391
  typedef FilterArcs<Digraph, ArcFilter> Adaptor;
392

	
393
  Digraph digraph;
394
  ArcFilter arc_filter(digraph);
395
  Adaptor adaptor(digraph, arc_filter);
396

	
397
  // Add nodes and arcs to the original digraph and the adaptor
398
  Digraph::Node n1 = digraph.addNode();
399
  Digraph::Node n2 = digraph.addNode();
400
  Adaptor::Node n3 = adaptor.addNode();
401

	
402
  Digraph::Arc a1 = digraph.addArc(n1, n2);
403
  Digraph::Arc a2 = digraph.addArc(n1, n3);
404
  Adaptor::Arc a3 = adaptor.addArc(n2, n3);
405

	
406
  arc_filter[a1] = arc_filter[a2] = arc_filter[a3] = true;
407

	
408
  checkGraphNodeList(adaptor, 3);
409
  checkGraphArcList(adaptor, 3);
410
  checkGraphConArcList(adaptor, 3);
411

	
412
  checkGraphOutArcList(adaptor, n1, 2);
413
  checkGraphOutArcList(adaptor, n2, 1);
414
  checkGraphOutArcList(adaptor, n3, 0);
415

	
416
  checkGraphInArcList(adaptor, n1, 0);
417
  checkGraphInArcList(adaptor, n2, 1);
418
  checkGraphInArcList(adaptor, n3, 2);
419

	
420
  checkNodeIds(adaptor);
421
  checkArcIds(adaptor);
422

	
423
  checkGraphNodeMap(adaptor);
424
  checkGraphArcMap(adaptor);
425

	
426
  // Hide an arc
427
  adaptor.status(a2, false);
428
  adaptor.disable(a3);
429
  if (!adaptor.status(a3)) adaptor.enable(a3);
430

	
431
  checkGraphNodeList(adaptor, 3);
432
  checkGraphArcList(adaptor, 2);
433
  checkGraphConArcList(adaptor, 2);
434

	
435
  checkGraphOutArcList(adaptor, n1, 1);
436
  checkGraphOutArcList(adaptor, n2, 1);
437
  checkGraphOutArcList(adaptor, n3, 0);
438

	
439
  checkGraphInArcList(adaptor, n1, 0);
440
  checkGraphInArcList(adaptor, n2, 1);
441
  checkGraphInArcList(adaptor, n3, 1);
442

	
443
  checkNodeIds(adaptor);
444
  checkArcIds(adaptor);
445

	
446
  checkGraphNodeMap(adaptor);
447
  checkGraphArcMap(adaptor);
448

	
449
  // Hide all arcs
310 450
  arc_filter[a1] = arc_filter[a2] = arc_filter[a3] = false;
311 451

	
312 452
  checkGraphNodeList(adaptor, 3);
313 453
  checkGraphArcList(adaptor, 0);
314 454
  checkGraphConArcList(adaptor, 0);
315 455

	
316 456
  checkNodeIds(adaptor);
317 457
  checkArcIds(adaptor);
318 458

	
319 459
  checkGraphNodeMap(adaptor);
320 460
  checkGraphArcMap(adaptor);
461

	
462
  // Check the conversion of nodes and arcs
463
  Digraph::Node nd = n3;
464
  nd = n3;
465
  Adaptor::Node na = n1;
466
  na = n2;
467
  Digraph::Arc ad = a3;
468
  ad = a3;
469
  Adaptor::Arc aa = a1;
470
  aa = a2;
321 471
}
322 472

	
323 473
void checkUndirector() {
474
  // Check concepts
324 475
  checkConcept<concepts::Graph, Undirector<concepts::Digraph> >();
476
  checkConcept<concepts::Graph, Undirector<ListDigraph> >();
477
  checkConcept<concepts::AlterableGraphComponent<>,
478
               Undirector<ListDigraph> >();
479
  checkConcept<concepts::ExtendableGraphComponent<>,
480
               Undirector<ListDigraph> >();
481
  checkConcept<concepts::ErasableGraphComponent<>,
482
               Undirector<ListDigraph> >();
483
  checkConcept<concepts::ClearableGraphComponent<>,
484
               Undirector<ListDigraph> >();
325 485

	
486

	
487
  // Create a digraph and an adaptor
326 488
  typedef ListDigraph Digraph;
327 489
  typedef Undirector<Digraph> Adaptor;
328 490

	
329 491
  Digraph digraph;
330 492
  Adaptor adaptor(digraph);
331 493

	
494
  // Add nodes and arcs/edges to the original digraph and the adaptor
332 495
  Digraph::Node n1 = digraph.addNode();
333 496
  Digraph::Node n2 = digraph.addNode();
334
  Digraph::Node n3 = digraph.addNode();
497
  Adaptor::Node n3 = adaptor.addNode();
335 498

	
336 499
  Digraph::Arc a1 = digraph.addArc(n1, n2);
337 500
  Digraph::Arc a2 = digraph.addArc(n1, n3);
338
  Digraph::Arc a3 = digraph.addArc(n2, n3);
501
  Adaptor::Edge e3 = adaptor.addEdge(n2, n3);
339 502

	
503
  // Check the original digraph
504
  checkGraphNodeList(digraph, 3);
505
  checkGraphArcList(digraph, 3);
506
  checkGraphConArcList(digraph, 3);
507

	
508
  checkGraphOutArcList(digraph, n1, 2);
509
  checkGraphOutArcList(digraph, n2, 1);
510
  checkGraphOutArcList(digraph, n3, 0);
511

	
512
  checkGraphInArcList(digraph, n1, 0);
513
  checkGraphInArcList(digraph, n2, 1);
514
  checkGraphInArcList(digraph, n3, 2);
515

	
516
  checkNodeIds(digraph);
517
  checkArcIds(digraph);
518

	
519
  checkGraphNodeMap(digraph);
520
  checkGraphArcMap(digraph);
521

	
522
  // Check the adaptor
340 523
  checkGraphNodeList(adaptor, 3);
341 524
  checkGraphArcList(adaptor, 6);
342 525
  checkGraphEdgeList(adaptor, 3);
343 526
  checkGraphConArcList(adaptor, 6);
344 527
  checkGraphConEdgeList(adaptor, 3);
345 528

	
346
  checkGraphOutArcList(adaptor, n1, 2);
347
  checkGraphOutArcList(adaptor, n2, 2);
348
  checkGraphOutArcList(adaptor, n3, 2);
349

	
350
  checkGraphInArcList(adaptor, n1, 2);
351
  checkGraphInArcList(adaptor, n2, 2);
352
  checkGraphInArcList(adaptor, n3, 2);
353

	
354
  checkGraphIncEdgeList(adaptor, n1, 2);
355
  checkGraphIncEdgeList(adaptor, n2, 2);
356
  checkGraphIncEdgeList(adaptor, n3, 2);
529
  checkGraphIncEdgeArcLists(adaptor, n1, 2);
530
  checkGraphIncEdgeArcLists(adaptor, n2, 2);
531
  checkGraphIncEdgeArcLists(adaptor, n3, 2);
357 532

	
358 533
  checkNodeIds(adaptor);
359 534
  checkArcIds(adaptor);
360 535
  checkEdgeIds(adaptor);
361 536

	
362 537
  checkGraphNodeMap(adaptor);
363 538
  checkGraphArcMap(adaptor);
364 539
  checkGraphEdgeMap(adaptor);
365 540

	
541
  // Check the edges of the adaptor
366 542
  for (Adaptor::EdgeIt e(adaptor); e != INVALID; ++e) {
367 543
    check(adaptor.u(e) == digraph.source(e), "Wrong undir");
368 544
    check(adaptor.v(e) == digraph.target(e), "Wrong undir");
369 545
  }
370 546

	
547
  // Check CombinedArcMap
548
  typedef Adaptor::CombinedArcMap
549
    <Digraph::ArcMap<int>, Digraph::ArcMap<int> > IntCombinedMap;
550
  typedef Adaptor::CombinedArcMap
551
    <Digraph::ArcMap<bool>, Digraph::ArcMap<bool> > BoolCombinedMap;
552
  checkConcept<concepts::ReferenceMap<Adaptor::Arc, int, int&, const int&>,
553
    IntCombinedMap>();
554
  checkConcept<concepts::ReferenceMap<Adaptor::Arc, bool, bool&, const bool&>,
555
    BoolCombinedMap>();
556

	
557
  Digraph::ArcMap<int> fw_map(digraph), bk_map(digraph);
558
  for (Digraph::ArcIt a(digraph); a != INVALID; ++a) {
559
    fw_map[a] = digraph.id(a);
560
    bk_map[a] = -digraph.id(a);
561
  }
562

	
563
  Adaptor::CombinedArcMap<Digraph::ArcMap<int>, Digraph::ArcMap<int> >
564
    comb_map(fw_map, bk_map);
565
  for (Adaptor::ArcIt a(adaptor); a != INVALID; ++a) {
566
    if (adaptor.source(a) == digraph.source(a)) {
567
      check(comb_map[a] == fw_map[a], "Wrong combined map");
568
    } else {
569
      check(comb_map[a] == bk_map[a], "Wrong combined map");
570
    }
571
  }
572

	
573
  // Check the conversion of nodes and arcs/edges
574
  Digraph::Node nd = n3;
575
  nd = n3;
576
  Adaptor::Node na = n1;
577
  na = n2;
578
  Digraph::Arc ad = e3;
579
  ad = e3;
580
  Adaptor::Edge ea = a1;
581
  ea = a2;
371 582
}
372 583

	
373
void checkResidual() {
374
  checkConcept<concepts::Digraph,
375
    Residual<concepts::Digraph,
376
    concepts::Digraph::ArcMap<int>,
377
    concepts::Digraph::ArcMap<int> > >();
584
void checkResidualDigraph() {
585
  // Check concepts
586
  checkConcept<concepts::Digraph, ResidualDigraph<concepts::Digraph> >();
587
  checkConcept<concepts::Digraph, ResidualDigraph<ListDigraph> >();
378 588

	
589
  // Create a digraph and an adaptor
379 590
  typedef ListDigraph Digraph;
380 591
  typedef Digraph::ArcMap<int> IntArcMap;
381
  typedef Residual<Digraph, IntArcMap> Adaptor;
592
  typedef ResidualDigraph<Digraph, IntArcMap> Adaptor;
382 593

	
383 594
  Digraph digraph;
384 595
  IntArcMap capacity(digraph), flow(digraph);
385 596
  Adaptor adaptor(digraph, capacity, flow);
386 597

	
387 598
  Digraph::Node n1 = digraph.addNode();
388 599
  Digraph::Node n2 = digraph.addNode();
389 600
  Digraph::Node n3 = digraph.addNode();
390 601
  Digraph::Node n4 = digraph.addNode();
391 602

	
392 603
  Digraph::Arc a1 = digraph.addArc(n1, n2);
393 604
  Digraph::Arc a2 = digraph.addArc(n1, n3);
394 605
  Digraph::Arc a3 = digraph.addArc(n1, n4);
395 606
  Digraph::Arc a4 = digraph.addArc(n2, n3);
396 607
  Digraph::Arc a5 = digraph.addArc(n2, n4);
397 608
  Digraph::Arc a6 = digraph.addArc(n3, n4);
398 609

	
399 610
  capacity[a1] = 8;
400 611
  capacity[a2] = 6;
401 612
  capacity[a3] = 4;
402 613
  capacity[a4] = 4;
403 614
  capacity[a5] = 6;
404 615
  capacity[a6] = 10;
405 616

	
406
  for (Adaptor::ArcIt a(adaptor); a != INVALID; ++a) {
617
  // Check the adaptor with various flow values
618
  for (Digraph::ArcIt a(digraph); a != INVALID; ++a) {
407 619
    flow[a] = 0;
408 620
  }
409 621

	
410 622
  checkGraphNodeList(adaptor, 4);
411 623
  checkGraphArcList(adaptor, 6);
412 624
  checkGraphConArcList(adaptor, 6);
413 625

	
414 626
  checkGraphOutArcList(adaptor, n1, 3);
415 627
  checkGraphOutArcList(adaptor, n2, 2);
416 628
  checkGraphOutArcList(adaptor, n3, 1);
417 629
  checkGraphOutArcList(adaptor, n4, 0);
418 630

	
419 631
  checkGraphInArcList(adaptor, n1, 0);
420 632
  checkGraphInArcList(adaptor, n2, 1);
421 633
  checkGraphInArcList(adaptor, n3, 2);
422 634
  checkGraphInArcList(adaptor, n4, 3);
423 635

	
424
  for (Adaptor::ArcIt a(adaptor); a != INVALID; ++a) {
636
  for (Digraph::ArcIt a(digraph); a != INVALID; ++a) {
425 637
    flow[a] = capacity[a] / 2;
426 638
  }
427 639

	
428 640
  checkGraphNodeList(adaptor, 4);
429 641
  checkGraphArcList(adaptor, 12);
430 642
  checkGraphConArcList(adaptor, 12);
431 643

	
432 644
  checkGraphOutArcList(adaptor, n1, 3);
433 645
  checkGraphOutArcList(adaptor, n2, 3);
434 646
  checkGraphOutArcList(adaptor, n3, 3);
435 647
  checkGraphOutArcList(adaptor, n4, 3);
436 648

	
437 649
  checkGraphInArcList(adaptor, n1, 3);
438 650
  checkGraphInArcList(adaptor, n2, 3);
439 651
  checkGraphInArcList(adaptor, n3, 3);
440 652
  checkGraphInArcList(adaptor, n4, 3);
441 653

	
442 654
  checkNodeIds(adaptor);
443 655
  checkArcIds(adaptor);
444 656

	
445 657
  checkGraphNodeMap(adaptor);
446 658
  checkGraphArcMap(adaptor);
447 659

	
448
  for (Adaptor::ArcIt a(adaptor); a != INVALID; ++a) {
660
  for (Digraph::ArcIt a(digraph); a != INVALID; ++a) {
449 661
    flow[a] = capacity[a];
450 662
  }
451 663

	
452 664
  checkGraphNodeList(adaptor, 4);
453 665
  checkGraphArcList(adaptor, 6);
454 666
  checkGraphConArcList(adaptor, 6);
455 667

	
456 668
  checkGraphOutArcList(adaptor, n1, 0);
457 669
  checkGraphOutArcList(adaptor, n2, 1);
458 670
  checkGraphOutArcList(adaptor, n3, 2);
459 671
  checkGraphOutArcList(adaptor, n4, 3);
460 672

	
461 673
  checkGraphInArcList(adaptor, n1, 3);
462 674
  checkGraphInArcList(adaptor, n2, 2);
463 675
  checkGraphInArcList(adaptor, n3, 1);
464 676
  checkGraphInArcList(adaptor, n4, 0);
465 677

	
678
  // Saturate all backward arcs
679
  // (set the flow to zero on all forward arcs)
466 680
  for (Adaptor::ArcIt a(adaptor); a != INVALID; ++a) {
467
    flow[a] = 0;
681
    if (adaptor.backward(a))
682
      adaptor.augment(a, adaptor.residualCapacity(a));
468 683
  }
469 684

	
685
  checkGraphNodeList(adaptor, 4);
686
  checkGraphArcList(adaptor, 6);
687
  checkGraphConArcList(adaptor, 6);
688

	
689
  checkGraphOutArcList(adaptor, n1, 3);
690
  checkGraphOutArcList(adaptor, n2, 2);
691
  checkGraphOutArcList(adaptor, n3, 1);
692
  checkGraphOutArcList(adaptor, n4, 0);
693

	
694
  checkGraphInArcList(adaptor, n1, 0);
695
  checkGraphInArcList(adaptor, n2, 1);
696
  checkGraphInArcList(adaptor, n3, 2);
697
  checkGraphInArcList(adaptor, n4, 3);
698

	
699
  // Find maximum flow by augmenting along shortest paths
470 700
  int flow_value = 0;
701
  Adaptor::ResidualCapacity res_cap(adaptor);
471 702
  while (true) {
472 703

	
473 704
    Bfs<Adaptor> bfs(adaptor);
474 705
    bfs.run(n1, n4);
475 706

	
476 707
    if (!bfs.reached(n4)) break;
477 708

	
478 709
    Path<Adaptor> p = bfs.path(n4);
479 710

	
480 711
    int min = std::numeric_limits<int>::max();
481 712
    for (Path<Adaptor>::ArcIt a(p); a != INVALID; ++a) {
482
      if (adaptor.residualCapacity(a) < min)
483
        min = adaptor.residualCapacity(a);
713
      if (res_cap[a] < min) min = res_cap[a];
484 714
    }
485 715

	
486 716
    for (Path<Adaptor>::ArcIt a(p); a != INVALID; ++a) {
487 717
      adaptor.augment(a, min);
488 718
    }
489 719
    flow_value += min;
490 720
  }
491 721

	
492 722
  check(flow_value == 18, "Wrong flow with res graph adaptor");
493 723

	
724
  // Check forward() and backward()
725
  for (Adaptor::ArcIt a(adaptor); a != INVALID; ++a) {
726
    check(adaptor.forward(a) != adaptor.backward(a),
727
          "Wrong forward() or backward()");
728
    check((adaptor.forward(a) && adaptor.forward(Digraph::Arc(a)) == a) ||
729
          (adaptor.backward(a) && adaptor.backward(Digraph::Arc(a)) == a),
730
          "Wrong forward() or backward()");
731
  }
732

	
733
  // Check the conversion of nodes and arcs
734
  Digraph::Node nd = Adaptor::NodeIt(adaptor);
735
  nd = ++Adaptor::NodeIt(adaptor);
736
  Adaptor::Node na = n1;
737
  na = n2;
738
  Digraph::Arc ad = Adaptor::ArcIt(adaptor);
739
  ad = ++Adaptor::ArcIt(adaptor);
494 740
}
495 741

	
496 742
void checkSplitNodes() {
743
  // Check concepts
497 744
  checkConcept<concepts::Digraph, SplitNodes<concepts::Digraph> >();
745
  checkConcept<concepts::Digraph, SplitNodes<ListDigraph> >();
498 746

	
747
  // Create a digraph and an adaptor
499 748
  typedef ListDigraph Digraph;
500 749
  typedef SplitNodes<Digraph> Adaptor;
501 750

	
502 751
  Digraph digraph;
503 752
  Adaptor adaptor(digraph);
504 753

	
505 754
  Digraph::Node n1 = digraph.addNode();
506 755
  Digraph::Node n2 = digraph.addNode();
507 756
  Digraph::Node n3 = digraph.addNode();
508 757

	
509 758
  Digraph::Arc a1 = digraph.addArc(n1, n2);
510 759
  Digraph::Arc a2 = digraph.addArc(n1, n3);
511 760
  Digraph::Arc a3 = digraph.addArc(n2, n3);
512 761

	
513 762
  checkGraphNodeList(adaptor, 6);
514 763
  checkGraphArcList(adaptor, 6);
515 764
  checkGraphConArcList(adaptor, 6);
516 765

	
517 766
  checkGraphOutArcList(adaptor, adaptor.inNode(n1), 1);
518 767
  checkGraphOutArcList(adaptor, adaptor.outNode(n1), 2);
519 768
  checkGraphOutArcList(adaptor, adaptor.inNode(n2), 1);
520 769
  checkGraphOutArcList(adaptor, adaptor.outNode(n2), 1);
521 770
  checkGraphOutArcList(adaptor, adaptor.inNode(n3), 1);
522 771
  checkGraphOutArcList(adaptor, adaptor.outNode(n3), 0);
523 772

	
524 773
  checkGraphInArcList(adaptor, adaptor.inNode(n1), 0);
525 774
  checkGraphInArcList(adaptor, adaptor.outNode(n1), 1);
526 775
  checkGraphInArcList(adaptor, adaptor.inNode(n2), 1);
527 776
  checkGraphInArcList(adaptor, adaptor.outNode(n2), 1);
528 777
  checkGraphInArcList(adaptor, adaptor.inNode(n3), 2);
529 778
  checkGraphInArcList(adaptor, adaptor.outNode(n3), 1);
530 779

	
531 780
  checkNodeIds(adaptor);
532 781
  checkArcIds(adaptor);
533 782

	
534 783
  checkGraphNodeMap(adaptor);
535 784
  checkGraphArcMap(adaptor);
536 785

	
786
  // Check split
537 787
  for (Adaptor::ArcIt a(adaptor); a != INVALID; ++a) {
538 788
    if (adaptor.origArc(a)) {
539 789
      Digraph::Arc oa = a;
540 790
      check(adaptor.source(a) == adaptor.outNode(digraph.source(oa)),
541 791
            "Wrong split");
542 792
      check(adaptor.target(a) == adaptor.inNode(digraph.target(oa)),
543 793
            "Wrong split");
544 794
    } else {
545 795
      Digraph::Node on = a;
546 796
      check(adaptor.source(a) == adaptor.inNode(on), "Wrong split");
547 797
      check(adaptor.target(a) == adaptor.outNode(on), "Wrong split");
548 798
    }
549 799
  }
800

	
801
  // Check combined node map
802
  typedef Adaptor::CombinedNodeMap
803
    <Digraph::NodeMap<int>, Digraph::NodeMap<int> > IntCombinedNodeMap;
804
  typedef Adaptor::CombinedNodeMap
805
    <Digraph::NodeMap<bool>, Digraph::NodeMap<bool> > BoolCombinedNodeMap;
806
  checkConcept<concepts::ReferenceMap<Adaptor::Node, int, int&, const int&>,
807
    IntCombinedNodeMap>();
808
//checkConcept<concepts::ReferenceMap<Adaptor::Node, bool, bool&, const bool&>,
809
//  BoolCombinedNodeMap>();
810
  checkConcept<concepts::ReadWriteMap<Adaptor::Node, bool>,
811
    BoolCombinedNodeMap>();
812

	
813
  Digraph::NodeMap<int> in_map(digraph), out_map(digraph);
814
  for (Digraph::NodeIt n(digraph); n != INVALID; ++n) {
815
    in_map[n] = digraph.id(n);
816
    out_map[n] = -digraph.id(n);
817
  }
818

	
819
  Adaptor::CombinedNodeMap<Digraph::NodeMap<int>, Digraph::NodeMap<int> >
820
    node_map(in_map, out_map);
821
  for (Adaptor::NodeIt n(adaptor); n != INVALID; ++n) {
822
    if (adaptor.inNode(n)) {
823
      check(node_map[n] == in_map[n], "Wrong combined node map");
824
    } else {
825
      check(node_map[n] == out_map[n], "Wrong combined node map");
826
    }
827
  }
828

	
829
  // Check combined arc map
830
  typedef Adaptor::CombinedArcMap
831
    <Digraph::ArcMap<int>, Digraph::NodeMap<int> > IntCombinedArcMap;
832
  typedef Adaptor::CombinedArcMap
833
    <Digraph::ArcMap<bool>, Digraph::NodeMap<bool> > BoolCombinedArcMap;
834
  checkConcept<concepts::ReferenceMap<Adaptor::Arc, int, int&, const int&>,
835
    IntCombinedArcMap>();
836
//checkConcept<concepts::ReferenceMap<Adaptor::Arc, bool, bool&, const bool&>,
837
//  BoolCombinedArcMap>();
838
  checkConcept<concepts::ReadWriteMap<Adaptor::Arc, bool>,
839
    BoolCombinedArcMap>();
840

	
841
  Digraph::ArcMap<int> a_map(digraph);
842
  for (Digraph::ArcIt a(digraph); a != INVALID; ++a) {
843
    a_map[a] = digraph.id(a);
844
  }
845

	
846
  Adaptor::CombinedArcMap<Digraph::ArcMap<int>, Digraph::NodeMap<int> >
847
    arc_map(a_map, out_map);
848
  for (Digraph::ArcIt a(digraph); a != INVALID; ++a) {
849
    check(arc_map[adaptor.arc(a)] == a_map[a],  "Wrong combined arc map");
850
  }
851
  for (Digraph::NodeIt n(digraph); n != INVALID; ++n) {
852
    check(arc_map[adaptor.arc(n)] == out_map[n],  "Wrong combined arc map");
853
  }
854

	
855
  // Check the conversion of nodes
856
  Digraph::Node nd = adaptor.inNode(n1);
857
  check (nd == n1, "Wrong node conversion");
858
  nd = adaptor.outNode(n2);
859
  check (nd == n2, "Wrong node conversion");
550 860
}
551 861

	
552 862
void checkSubGraph() {
553
  checkConcept<concepts::Graph,
554
    SubGraph<concepts::Graph,
555
    concepts::Graph::NodeMap<bool>,
556
    concepts::Graph::EdgeMap<bool> > >();
863
  // Check concepts
864
  checkConcept<concepts::Graph, SubGraph<concepts::Graph> >();
865
  checkConcept<concepts::Graph, SubGraph<ListGraph> >();
866
  checkConcept<concepts::AlterableGraphComponent<>,
867
               SubGraph<ListGraph> >();
868
  checkConcept<concepts::ExtendableGraphComponent<>,
869
               SubGraph<ListGraph> >();
870
  checkConcept<concepts::ErasableGraphComponent<>,
871
               SubGraph<ListGraph> >();
872
  checkConcept<concepts::ClearableGraphComponent<>,
873
               SubGraph<ListGraph> >();
557 874

	
875
  // Create a graph and an adaptor
558 876
  typedef ListGraph Graph;
559 877
  typedef Graph::NodeMap<bool> NodeFilter;
560 878
  typedef Graph::EdgeMap<bool> EdgeFilter;
561 879
  typedef SubGraph<Graph, NodeFilter, EdgeFilter> Adaptor;
562 880

	
563 881
  Graph graph;
564 882
  NodeFilter node_filter(graph);
565 883
  EdgeFilter edge_filter(graph);
566 884
  Adaptor adaptor(graph, node_filter, edge_filter);
567 885

	
886
  // Add nodes and edges to the original graph and the adaptor
568 887
  Graph::Node n1 = graph.addNode();
569 888
  Graph::Node n2 = graph.addNode();
570
  Graph::Node n3 = graph.addNode();
571
  Graph::Node n4 = graph.addNode();
889
  Adaptor::Node n3 = adaptor.addNode();
890
  Adaptor::Node n4 = adaptor.addNode();
891

	
892
  node_filter[n1] = node_filter[n2] = node_filter[n3] = node_filter[n4] = true;
572 893

	
573 894
  Graph::Edge e1 = graph.addEdge(n1, n2);
574 895
  Graph::Edge e2 = graph.addEdge(n1, n3);
575
  Graph::Edge e3 = graph.addEdge(n2, n3);
576
  Graph::Edge e4 = graph.addEdge(n3, n4);
896
  Adaptor::Edge e3 = adaptor.addEdge(n2, n3);
897
  Adaptor::Edge e4 = adaptor.addEdge(n3, n4);
577 898

	
578
  node_filter[n1] = node_filter[n2] = node_filter[n3] = node_filter[n4] = true;
579 899
  edge_filter[e1] = edge_filter[e2] = edge_filter[e3] = edge_filter[e4] = true;
580 900

	
581 901
  checkGraphNodeList(adaptor, 4);
582 902
  checkGraphArcList(adaptor, 8);
583 903
  checkGraphEdgeList(adaptor, 4);
584 904
  checkGraphConArcList(adaptor, 8);
585 905
  checkGraphConEdgeList(adaptor, 4);
586 906

	
587
  checkGraphOutArcList(adaptor, n1, 2);
588
  checkGraphOutArcList(adaptor, n2, 2);
589
  checkGraphOutArcList(adaptor, n3, 3);
590
  checkGraphOutArcList(adaptor, n4, 1);
591

	
592
  checkGraphInArcList(adaptor, n1, 2);
593
  checkGraphInArcList(adaptor, n2, 2);
594
  checkGraphInArcList(adaptor, n3, 3);
595
  checkGraphInArcList(adaptor, n4, 1);
596

	
597
  checkGraphIncEdgeList(adaptor, n1, 2);
598
  checkGraphIncEdgeList(adaptor, n2, 2);
599
  checkGraphIncEdgeList(adaptor, n3, 3);
600
  checkGraphIncEdgeList(adaptor, n4, 1);
907
  checkGraphIncEdgeArcLists(adaptor, n1, 2);
908
  checkGraphIncEdgeArcLists(adaptor, n2, 2);
909
  checkGraphIncEdgeArcLists(adaptor, n3, 3);
910
  checkGraphIncEdgeArcLists(adaptor, n4, 1);
601 911

	
602 912
  checkNodeIds(adaptor);
603 913
  checkArcIds(adaptor);
604 914
  checkEdgeIds(adaptor);
605 915

	
606 916
  checkGraphNodeMap(adaptor);
607 917
  checkGraphArcMap(adaptor);
608 918
  checkGraphEdgeMap(adaptor);
609 919

	
610
  edge_filter[e2] = false;
920
  // Hide an edge
921
  adaptor.status(e2, false);
922
  adaptor.disable(e3);
923
  if (!adaptor.status(e3)) adaptor.enable(e3);
611 924

	
612 925
  checkGraphNodeList(adaptor, 4);
613 926
  checkGraphArcList(adaptor, 6);
614 927
  checkGraphEdgeList(adaptor, 3);
615 928
  checkGraphConArcList(adaptor, 6);
616 929
  checkGraphConEdgeList(adaptor, 3);
617 930

	
618
  checkGraphOutArcList(adaptor, n1, 1);
619
  checkGraphOutArcList(adaptor, n2, 2);
620
  checkGraphOutArcList(adaptor, n3, 2);
621
  checkGraphOutArcList(adaptor, n4, 1);
622

	
623
  checkGraphInArcList(adaptor, n1, 1);
624
  checkGraphInArcList(adaptor, n2, 2);
625
  checkGraphInArcList(adaptor, n3, 2);
626
  checkGraphInArcList(adaptor, n4, 1);
627

	
628
  checkGraphIncEdgeList(adaptor, n1, 1);
629
  checkGraphIncEdgeList(adaptor, n2, 2);
630
  checkGraphIncEdgeList(adaptor, n3, 2);
631
  checkGraphIncEdgeList(adaptor, n4, 1);
931
  checkGraphIncEdgeArcLists(adaptor, n1, 1);
932
  checkGraphIncEdgeArcLists(adaptor, n2, 2);
933
  checkGraphIncEdgeArcLists(adaptor, n3, 2);
934
  checkGraphIncEdgeArcLists(adaptor, n4, 1);
632 935

	
633 936
  checkNodeIds(adaptor);
634 937
  checkArcIds(adaptor);
635 938
  checkEdgeIds(adaptor);
636 939

	
637 940
  checkGraphNodeMap(adaptor);
638 941
  checkGraphArcMap(adaptor);
639 942
  checkGraphEdgeMap(adaptor);
640 943

	
641
  node_filter[n1] = false;
944
  // Hide a node
945
  adaptor.status(n1, false);
946
  adaptor.disable(n3);
947
  if (!adaptor.status(n3)) adaptor.enable(n3);
642 948

	
643 949
  checkGraphNodeList(adaptor, 3);
644 950
  checkGraphArcList(adaptor, 4);
645 951
  checkGraphEdgeList(adaptor, 2);
646 952
  checkGraphConArcList(adaptor, 4);
647 953
  checkGraphConEdgeList(adaptor, 2);
648 954

	
649
  checkGraphOutArcList(adaptor, n2, 1);
650
  checkGraphOutArcList(adaptor, n3, 2);
651
  checkGraphOutArcList(adaptor, n4, 1);
652

	
653
  checkGraphInArcList(adaptor, n2, 1);
654
  checkGraphInArcList(adaptor, n3, 2);
655
  checkGraphInArcList(adaptor, n4, 1);
656

	
657
  checkGraphIncEdgeList(adaptor, n2, 1);
658
  checkGraphIncEdgeList(adaptor, n3, 2);
659
  checkGraphIncEdgeList(adaptor, n4, 1);
955
  checkGraphIncEdgeArcLists(adaptor, n2, 1);
956
  checkGraphIncEdgeArcLists(adaptor, n3, 2);
957
  checkGraphIncEdgeArcLists(adaptor, n4, 1);
660 958

	
661 959
  checkNodeIds(adaptor);
662 960
  checkArcIds(adaptor);
663 961
  checkEdgeIds(adaptor);
664 962

	
665 963
  checkGraphNodeMap(adaptor);
666 964
  checkGraphArcMap(adaptor);
667 965
  checkGraphEdgeMap(adaptor);
668 966

	
967
  // Hide all nodes and edges
669 968
  node_filter[n1] = node_filter[n2] = node_filter[n3] = node_filter[n4] = false;
670 969
  edge_filter[e1] = edge_filter[e2] = edge_filter[e3] = edge_filter[e4] = false;
671 970

	
672 971
  checkGraphNodeList(adaptor, 0);
673 972
  checkGraphArcList(adaptor, 0);
674 973
  checkGraphEdgeList(adaptor, 0);
675 974
  checkGraphConArcList(adaptor, 0);
676 975
  checkGraphConEdgeList(adaptor, 0);
677 976

	
678 977
  checkNodeIds(adaptor);
679 978
  checkArcIds(adaptor);
680 979
  checkEdgeIds(adaptor);
681 980

	
682 981
  checkGraphNodeMap(adaptor);
683 982
  checkGraphArcMap(adaptor);
684 983
  checkGraphEdgeMap(adaptor);
984

	
985
  // Check the conversion of nodes and edges
986
  Graph::Node ng = n3;
987
  ng = n4;
988
  Adaptor::Node na = n1;
989
  na = n2;
990
  Graph::Edge eg = e3;
991
  eg = e4;
992
  Adaptor::Edge ea = e1;
993
  ea = e2;
685 994
}
686 995

	
687 996
void checkFilterNodes2() {
688
  checkConcept<concepts::Graph,
689
    FilterNodes<concepts::Graph,
690
      concepts::Graph::NodeMap<bool> > >();
997
  // Check concepts
998
  checkConcept<concepts::Graph, FilterNodes<concepts::Graph> >();
999
  checkConcept<concepts::Graph, FilterNodes<ListGraph> >();
1000
  checkConcept<concepts::AlterableGraphComponent<>,
1001
               FilterNodes<ListGraph> >();
1002
  checkConcept<concepts::ExtendableGraphComponent<>,
1003
               FilterNodes<ListGraph> >();
1004
  checkConcept<concepts::ErasableGraphComponent<>,
1005
               FilterNodes<ListGraph> >();
1006
  checkConcept<concepts::ClearableGraphComponent<>,
1007
               FilterNodes<ListGraph> >();
691 1008

	
1009
  // Create a graph and an adaptor
692 1010
  typedef ListGraph Graph;
693 1011
  typedef Graph::NodeMap<bool> NodeFilter;
694 1012
  typedef FilterNodes<Graph, NodeFilter> Adaptor;
695 1013

	
1014
  // Add nodes and edges to the original graph and the adaptor
696 1015
  Graph graph;
697 1016
  NodeFilter node_filter(graph);
698 1017
  Adaptor adaptor(graph, node_filter);
699 1018

	
700 1019
  Graph::Node n1 = graph.addNode();
701 1020
  Graph::Node n2 = graph.addNode();
702
  Graph::Node n3 = graph.addNode();
703
  Graph::Node n4 = graph.addNode();
1021
  Adaptor::Node n3 = adaptor.addNode();
1022
  Adaptor::Node n4 = adaptor.addNode();
1023

	
1024
  node_filter[n1] = node_filter[n2] = node_filter[n3] = node_filter[n4] = true;
704 1025

	
705 1026
  Graph::Edge e1 = graph.addEdge(n1, n2);
706 1027
  Graph::Edge e2 = graph.addEdge(n1, n3);
707
  Graph::Edge e3 = graph.addEdge(n2, n3);
708
  Graph::Edge e4 = graph.addEdge(n3, n4);
709

	
710
  node_filter[n1] = node_filter[n2] = node_filter[n3] = node_filter[n4] = true;
1028
  Adaptor::Edge e3 = adaptor.addEdge(n2, n3);
1029
  Adaptor::Edge e4 = adaptor.addEdge(n3, n4);
711 1030

	
712 1031
  checkGraphNodeList(adaptor, 4);
713 1032
  checkGraphArcList(adaptor, 8);
714 1033
  checkGraphEdgeList(adaptor, 4);
715 1034
  checkGraphConArcList(adaptor, 8);
716 1035
  checkGraphConEdgeList(adaptor, 4);
717 1036

	
718
  checkGraphOutArcList(adaptor, n1, 2);
719
  checkGraphOutArcList(adaptor, n2, 2);
720
  checkGraphOutArcList(adaptor, n3, 3);
721
  checkGraphOutArcList(adaptor, n4, 1);
722

	
723
  checkGraphInArcList(adaptor, n1, 2);
724
  checkGraphInArcList(adaptor, n2, 2);
725
  checkGraphInArcList(adaptor, n3, 3);
726
  checkGraphInArcList(adaptor, n4, 1);
727

	
728
  checkGraphIncEdgeList(adaptor, n1, 2);
729
  checkGraphIncEdgeList(adaptor, n2, 2);
730
  checkGraphIncEdgeList(adaptor, n3, 3);
731
  checkGraphIncEdgeList(adaptor, n4, 1);
1037
  checkGraphIncEdgeArcLists(adaptor, n1, 2);
1038
  checkGraphIncEdgeArcLists(adaptor, n2, 2);
1039
  checkGraphIncEdgeArcLists(adaptor, n3, 3);
1040
  checkGraphIncEdgeArcLists(adaptor, n4, 1);
732 1041

	
733 1042
  checkNodeIds(adaptor);
734 1043
  checkArcIds(adaptor);
735 1044
  checkEdgeIds(adaptor);
736 1045

	
737 1046
  checkGraphNodeMap(adaptor);
738 1047
  checkGraphArcMap(adaptor);
739 1048
  checkGraphEdgeMap(adaptor);
740 1049

	
741
  node_filter[n1] = false;
1050
  // Hide a node
1051
  adaptor.status(n1, false);
1052
  adaptor.disable(n3);
1053
  if (!adaptor.status(n3)) adaptor.enable(n3);
742 1054

	
743 1055
  checkGraphNodeList(adaptor, 3);
744 1056
  checkGraphArcList(adaptor, 4);
745 1057
  checkGraphEdgeList(adaptor, 2);
746 1058
  checkGraphConArcList(adaptor, 4);
747 1059
  checkGraphConEdgeList(adaptor, 2);
748 1060

	
749
  checkGraphOutArcList(adaptor, n2, 1);
750
  checkGraphOutArcList(adaptor, n3, 2);
751
  checkGraphOutArcList(adaptor, n4, 1);
752

	
753
  checkGraphInArcList(adaptor, n2, 1);
754
  checkGraphInArcList(adaptor, n3, 2);
755
  checkGraphInArcList(adaptor, n4, 1);
756

	
757
  checkGraphIncEdgeList(adaptor, n2, 1);
758
  checkGraphIncEdgeList(adaptor, n3, 2);
759
  checkGraphIncEdgeList(adaptor, n4, 1);
1061
  checkGraphIncEdgeArcLists(adaptor, n2, 1);
1062
  checkGraphIncEdgeArcLists(adaptor, n3, 2);
1063
  checkGraphIncEdgeArcLists(adaptor, n4, 1);
760 1064

	
761 1065
  checkNodeIds(adaptor);
762 1066
  checkArcIds(adaptor);
763 1067
  checkEdgeIds(adaptor);
764 1068

	
765 1069
  checkGraphNodeMap(adaptor);
766 1070
  checkGraphArcMap(adaptor);
767 1071
  checkGraphEdgeMap(adaptor);
768 1072

	
1073
  // Hide all nodes
769 1074
  node_filter[n1] = node_filter[n2] = node_filter[n3] = node_filter[n4] = false;
770 1075

	
771 1076
  checkGraphNodeList(adaptor, 0);
772 1077
  checkGraphArcList(adaptor, 0);
773 1078
  checkGraphEdgeList(adaptor, 0);
774 1079
  checkGraphConArcList(adaptor, 0);
775 1080
  checkGraphConEdgeList(adaptor, 0);
776 1081

	
777 1082
  checkNodeIds(adaptor);
778 1083
  checkArcIds(adaptor);
779 1084
  checkEdgeIds(adaptor);
780 1085

	
781 1086
  checkGraphNodeMap(adaptor);
782 1087
  checkGraphArcMap(adaptor);
783 1088
  checkGraphEdgeMap(adaptor);
1089

	
1090
  // Check the conversion of nodes and edges
1091
  Graph::Node ng = n3;
1092
  ng = n4;
1093
  Adaptor::Node na = n1;
1094
  na = n2;
1095
  Graph::Edge eg = e3;
1096
  eg = e4;
1097
  Adaptor::Edge ea = e1;
1098
  ea = e2;
784 1099
}
785 1100

	
786 1101
void checkFilterEdges() {
787
  checkConcept<concepts::Graph,
788
    FilterEdges<concepts::Graph,
789
    concepts::Graph::EdgeMap<bool> > >();
1102
  // Check concepts
1103
  checkConcept<concepts::Graph, FilterEdges<concepts::Graph> >();
1104
  checkConcept<concepts::Graph, FilterEdges<ListGraph> >();
1105
  checkConcept<concepts::AlterableGraphComponent<>,
1106
               FilterEdges<ListGraph> >();
1107
  checkConcept<concepts::ExtendableGraphComponent<>,
1108
               FilterEdges<ListGraph> >();
1109
  checkConcept<concepts::ErasableGraphComponent<>,
1110
               FilterEdges<ListGraph> >();
1111
  checkConcept<concepts::ClearableGraphComponent<>,
1112
               FilterEdges<ListGraph> >();
790 1113

	
1114
  // Create a graph and an adaptor
791 1115
  typedef ListGraph Graph;
792 1116
  typedef Graph::EdgeMap<bool> EdgeFilter;
793 1117
  typedef FilterEdges<Graph, EdgeFilter> Adaptor;
794 1118

	
795 1119
  Graph graph;
796 1120
  EdgeFilter edge_filter(graph);
797 1121
  Adaptor adaptor(graph, edge_filter);
798 1122

	
1123
  // Add nodes and edges to the original graph and the adaptor
799 1124
  Graph::Node n1 = graph.addNode();
800 1125
  Graph::Node n2 = graph.addNode();
801
  Graph::Node n3 = graph.addNode();
802
  Graph::Node n4 = graph.addNode();
1126
  Adaptor::Node n3 = adaptor.addNode();
1127
  Adaptor::Node n4 = adaptor.addNode();
803 1128

	
804 1129
  Graph::Edge e1 = graph.addEdge(n1, n2);
805 1130
  Graph::Edge e2 = graph.addEdge(n1, n3);
806
  Graph::Edge e3 = graph.addEdge(n2, n3);
807
  Graph::Edge e4 = graph.addEdge(n3, n4);
1131
  Adaptor::Edge e3 = adaptor.addEdge(n2, n3);
1132
  Adaptor::Edge e4 = adaptor.addEdge(n3, n4);
808 1133

	
809 1134
  edge_filter[e1] = edge_filter[e2] = edge_filter[e3] = edge_filter[e4] = true;
810 1135

	
811 1136
  checkGraphNodeList(adaptor, 4);
812 1137
  checkGraphArcList(adaptor, 8);
813 1138
  checkGraphEdgeList(adaptor, 4);
814 1139
  checkGraphConArcList(adaptor, 8);
815 1140
  checkGraphConEdgeList(adaptor, 4);
816 1141

	
817
  checkGraphOutArcList(adaptor, n1, 2);
818
  checkGraphOutArcList(adaptor, n2, 2);
819
  checkGraphOutArcList(adaptor, n3, 3);
820
  checkGraphOutArcList(adaptor, n4, 1);
821

	
822
  checkGraphInArcList(adaptor, n1, 2);
823
  checkGraphInArcList(adaptor, n2, 2);
824
  checkGraphInArcList(adaptor, n3, 3);
825
  checkGraphInArcList(adaptor, n4, 1);
826

	
827
  checkGraphIncEdgeList(adaptor, n1, 2);
828
  checkGraphIncEdgeList(adaptor, n2, 2);
829
  checkGraphIncEdgeList(adaptor, n3, 3);
830
  checkGraphIncEdgeList(adaptor, n4, 1);
1142
  checkGraphIncEdgeArcLists(adaptor, n1, 2);
1143
  checkGraphIncEdgeArcLists(adaptor, n2, 2);
1144
  checkGraphIncEdgeArcLists(adaptor, n3, 3);
1145
  checkGraphIncEdgeArcLists(adaptor, n4, 1);
831 1146

	
832 1147
  checkNodeIds(adaptor);
833 1148
  checkArcIds(adaptor);
834 1149
  checkEdgeIds(adaptor);
835 1150

	
836 1151
  checkGraphNodeMap(adaptor);
837 1152
  checkGraphArcMap(adaptor);
838 1153
  checkGraphEdgeMap(adaptor);
839 1154

	
840
  edge_filter[e2] = false;
1155
  // Hide an edge
1156
  adaptor.status(e2, false);
1157
  adaptor.disable(e3);
1158
  if (!adaptor.status(e3)) adaptor.enable(e3);
841 1159

	
842 1160
  checkGraphNodeList(adaptor, 4);
843 1161
  checkGraphArcList(adaptor, 6);
844 1162
  checkGraphEdgeList(adaptor, 3);
845 1163
  checkGraphConArcList(adaptor, 6);
846 1164
  checkGraphConEdgeList(adaptor, 3);
847 1165

	
848
  checkGraphOutArcList(adaptor, n1, 1);
849
  checkGraphOutArcList(adaptor, n2, 2);
850
  checkGraphOutArcList(adaptor, n3, 2);
851
  checkGraphOutArcList(adaptor, n4, 1);
852

	
853
  checkGraphInArcList(adaptor, n1, 1);
854
  checkGraphInArcList(adaptor, n2, 2);
855
  checkGraphInArcList(adaptor, n3, 2);
856
  checkGraphInArcList(adaptor, n4, 1);
857

	
858
  checkGraphIncEdgeList(adaptor, n1, 1);
859
  checkGraphIncEdgeList(adaptor, n2, 2);
860
  checkGraphIncEdgeList(adaptor, n3, 2);
861
  checkGraphIncEdgeList(adaptor, n4, 1);
1166
  checkGraphIncEdgeArcLists(adaptor, n1, 1);
1167
  checkGraphIncEdgeArcLists(adaptor, n2, 2);
1168
  checkGraphIncEdgeArcLists(adaptor, n3, 2);
1169
  checkGraphIncEdgeArcLists(adaptor, n4, 1);
862 1170

	
863 1171
  checkNodeIds(adaptor);
864 1172
  checkArcIds(adaptor);
865 1173
  checkEdgeIds(adaptor);
866 1174

	
867 1175
  checkGraphNodeMap(adaptor);
868 1176
  checkGraphArcMap(adaptor);
869 1177
  checkGraphEdgeMap(adaptor);
870 1178

	
1179
  // Hide all edges
871 1180
  edge_filter[e1] = edge_filter[e2] = edge_filter[e3] = edge_filter[e4] = false;
872 1181

	
873 1182
  checkGraphNodeList(adaptor, 4);
874 1183
  checkGraphArcList(adaptor, 0);
875 1184
  checkGraphEdgeList(adaptor, 0);
876 1185
  checkGraphConArcList(adaptor, 0);
877 1186
  checkGraphConEdgeList(adaptor, 0);
878 1187

	
879 1188
  checkNodeIds(adaptor);
880 1189
  checkArcIds(adaptor);
881 1190
  checkEdgeIds(adaptor);
882 1191

	
883 1192
  checkGraphNodeMap(adaptor);
884 1193
  checkGraphArcMap(adaptor);
885 1194
  checkGraphEdgeMap(adaptor);
1195

	
1196
  // Check the conversion of nodes and edges
1197
  Graph::Node ng = n3;
1198
  ng = n4;
1199
  Adaptor::Node na = n1;
1200
  na = n2;
1201
  Graph::Edge eg = e3;
1202
  eg = e4;
1203
  Adaptor::Edge ea = e1;
1204
  ea = e2;
886 1205
}
887 1206

	
888 1207
void checkOrienter() {
889
  checkConcept<concepts::Digraph,
890
    Orienter<concepts::Graph, concepts::Graph::EdgeMap<bool> > >();
1208
  // Check concepts
1209
  checkConcept<concepts::Digraph, Orienter<concepts::Graph> >();
1210
  checkConcept<concepts::Digraph, Orienter<ListGraph> >();
1211
  checkConcept<concepts::AlterableDigraphComponent<>,
1212
               Orienter<ListGraph> >();
1213
  checkConcept<concepts::ExtendableDigraphComponent<>,
1214
               Orienter<ListGraph> >();
1215
  checkConcept<concepts::ErasableDigraphComponent<>,
1216
               Orienter<ListGraph> >();
1217
  checkConcept<concepts::ClearableDigraphComponent<>,
1218
               Orienter<ListGraph> >();
891 1219

	
1220
  // Create a graph and an adaptor
892 1221
  typedef ListGraph Graph;
893 1222
  typedef ListGraph::EdgeMap<bool> DirMap;
894 1223
  typedef Orienter<Graph> Adaptor;
895 1224

	
896 1225
  Graph graph;
897
  DirMap dir(graph, true);
1226
  DirMap dir(graph);
898 1227
  Adaptor adaptor(graph, dir);
899 1228

	
1229
  // Add nodes and edges to the original graph and the adaptor
900 1230
  Graph::Node n1 = graph.addNode();
901 1231
  Graph::Node n2 = graph.addNode();
902
  Graph::Node n3 = graph.addNode();
1232
  Adaptor::Node n3 = adaptor.addNode();
903 1233

	
904 1234
  Graph::Edge e1 = graph.addEdge(n1, n2);
905 1235
  Graph::Edge e2 = graph.addEdge(n1, n3);
906
  Graph::Edge e3 = graph.addEdge(n2, n3);
1236
  Adaptor::Arc e3 = adaptor.addArc(n2, n3);
907 1237

	
1238
  dir[e1] = dir[e2] = dir[e3] = true;
1239

	
1240
  // Check the original graph
1241
  checkGraphNodeList(graph, 3);
1242
  checkGraphArcList(graph, 6);
1243
  checkGraphConArcList(graph, 6);
1244
  checkGraphEdgeList(graph, 3);
1245
  checkGraphConEdgeList(graph, 3);
1246

	
1247
  checkGraphIncEdgeArcLists(graph, n1, 2);
1248
  checkGraphIncEdgeArcLists(graph, n2, 2);
1249
  checkGraphIncEdgeArcLists(graph, n3, 2);
1250

	
1251
  checkNodeIds(graph);
1252
  checkArcIds(graph);
1253
  checkEdgeIds(graph);
1254

	
1255
  checkGraphNodeMap(graph);
1256
  checkGraphArcMap(graph);
1257
  checkGraphEdgeMap(graph);
1258

	
1259
  // Check the adaptor
908 1260
  checkGraphNodeList(adaptor, 3);
909 1261
  checkGraphArcList(adaptor, 3);
910 1262
  checkGraphConArcList(adaptor, 3);
911 1263

	
1264
  checkGraphOutArcList(adaptor, n1, 2);
1265
  checkGraphOutArcList(adaptor, n2, 1);
1266
  checkGraphOutArcList(adaptor, n3, 0);
1267

	
1268
  checkGraphInArcList(adaptor, n1, 0);
1269
  checkGraphInArcList(adaptor, n2, 1);
1270
  checkGraphInArcList(adaptor, n3, 2);
1271

	
1272
  checkNodeIds(adaptor);
1273
  checkArcIds(adaptor);
1274

	
1275
  checkGraphNodeMap(adaptor);
1276
  checkGraphArcMap(adaptor);
1277

	
1278
  // Check direction changing
912 1279
  {
913 1280
    dir[e1] = true;
914 1281
    Adaptor::Node u = adaptor.source(e1);
915 1282
    Adaptor::Node v = adaptor.target(e1);
916 1283

	
917 1284
    dir[e1] = false;
918 1285
    check (u == adaptor.target(e1), "Wrong dir");
919 1286
    check (v == adaptor.source(e1), "Wrong dir");
920 1287

	
921 1288
    check ((u == n1 && v == n2) || (u == n2 && v == n1), "Wrong dir");
922 1289
    dir[e1] = n1 == u;
923 1290
  }
924 1291

	
925 1292
  {
926 1293
    dir[e2] = true;
927 1294
    Adaptor::Node u = adaptor.source(e2);
928 1295
    Adaptor::Node v = adaptor.target(e2);
929 1296

	
930 1297
    dir[e2] = false;
931 1298
    check (u == adaptor.target(e2), "Wrong dir");
932 1299
    check (v == adaptor.source(e2), "Wrong dir");
933 1300

	
934 1301
    check ((u == n1 && v == n3) || (u == n3 && v == n1), "Wrong dir");
935 1302
    dir[e2] = n3 == u;
936 1303
  }
937 1304

	
938 1305
  {
939 1306
    dir[e3] = true;
940 1307
    Adaptor::Node u = adaptor.source(e3);
941 1308
    Adaptor::Node v = adaptor.target(e3);
942 1309

	
943 1310
    dir[e3] = false;
944 1311
    check (u == adaptor.target(e3), "Wrong dir");
945 1312
    check (v == adaptor.source(e3), "Wrong dir");
946 1313

	
947 1314
    check ((u == n2 && v == n3) || (u == n3 && v == n2), "Wrong dir");
948 1315
    dir[e3] = n2 == u;
949 1316
  }
950 1317

	
1318
  // Check the adaptor again
1319
  checkGraphNodeList(adaptor, 3);
1320
  checkGraphArcList(adaptor, 3);
1321
  checkGraphConArcList(adaptor, 3);
1322

	
951 1323
  checkGraphOutArcList(adaptor, n1, 1);
952 1324
  checkGraphOutArcList(adaptor, n2, 1);
953 1325
  checkGraphOutArcList(adaptor, n3, 1);
954 1326

	
955 1327
  checkGraphInArcList(adaptor, n1, 1);
956 1328
  checkGraphInArcList(adaptor, n2, 1);
957 1329
  checkGraphInArcList(adaptor, n3, 1);
958 1330

	
959 1331
  checkNodeIds(adaptor);
960 1332
  checkArcIds(adaptor);
961 1333

	
962 1334
  checkGraphNodeMap(adaptor);
963 1335
  checkGraphArcMap(adaptor);
964 1336

	
1337
  // Check reverseArc()
1338
  adaptor.reverseArc(e2);
1339
  adaptor.reverseArc(e3);
1340
  adaptor.reverseArc(e2);
1341

	
1342
  checkGraphNodeList(adaptor, 3);
1343
  checkGraphArcList(adaptor, 3);
1344
  checkGraphConArcList(adaptor, 3);
1345

	
1346
  checkGraphOutArcList(adaptor, n1, 1);
1347
  checkGraphOutArcList(adaptor, n2, 0);
1348
  checkGraphOutArcList(adaptor, n3, 2);
1349

	
1350
  checkGraphInArcList(adaptor, n1, 1);
1351
  checkGraphInArcList(adaptor, n2, 2);
1352
  checkGraphInArcList(adaptor, n3, 0);
1353

	
1354
  // Check the conversion of nodes and arcs/edges
1355
  Graph::Node ng = n3;
1356
  ng = n3;
1357
  Adaptor::Node na = n1;
1358
  na = n2;
1359
  Graph::Edge eg = e3;
1360
  eg = e3;
1361
  Adaptor::Arc aa = e1;
1362
  aa = e2;
965 1363
}
966 1364

	
1365
void checkCombiningAdaptors() {
1366
  // Create a grid graph
1367
  GridGraph graph(2,2);
1368
  GridGraph::Node n1 = graph(0,0);
1369
  GridGraph::Node n2 = graph(0,1);
1370
  GridGraph::Node n3 = graph(1,0);
1371
  GridGraph::Node n4 = graph(1,1);
1372

	
1373
  GridGraph::EdgeMap<bool> dir_map(graph);
1374
  dir_map[graph.right(n1)] = graph.u(graph.right(n1)) == n1;
1375
  dir_map[graph.up(n1)] = graph.u(graph.up(n1)) != n1;
1376
  dir_map[graph.left(n4)] = graph.u(graph.left(n4)) != n4;
1377
  dir_map[graph.down(n4)] = graph.u(graph.down(n4)) != n4;
1378

	
1379
  // Apply several adaptors on the grid graph
1380
  typedef SplitNodes< ReverseDigraph< const Orienter<
1381
            const GridGraph, GridGraph::EdgeMap<bool> > > >
1382
    RevSplitGridGraph;
1383
  typedef ReverseDigraph<const RevSplitGridGraph> SplitGridGraph;
1384
  typedef Undirector<const SplitGridGraph> USplitGridGraph;
1385
  typedef Undirector<const USplitGridGraph> UUSplitGridGraph;
1386
  checkConcept<concepts::Digraph, RevSplitGridGraph>();
1387
  checkConcept<concepts::Digraph, SplitGridGraph>();
1388
  checkConcept<concepts::Graph, USplitGridGraph>();
1389
  checkConcept<concepts::Graph, UUSplitGridGraph>();
1390

	
1391
  RevSplitGridGraph rev_adaptor =
1392
    splitNodes(reverseDigraph(orienter(graph, dir_map)));
1393
  SplitGridGraph adaptor = reverseDigraph(rev_adaptor);
1394
  USplitGridGraph uadaptor = undirector(adaptor);
1395
  UUSplitGridGraph uuadaptor = undirector(uadaptor);
1396

	
1397
  // Check adaptor
1398
  checkGraphNodeList(adaptor, 8);
1399
  checkGraphArcList(adaptor, 8);
1400
  checkGraphConArcList(adaptor, 8);
1401

	
1402
  checkGraphOutArcList(adaptor, rev_adaptor.inNode(n1), 1);
1403
  checkGraphOutArcList(adaptor, rev_adaptor.outNode(n1), 1);
1404
  checkGraphOutArcList(adaptor, rev_adaptor.inNode(n2), 2);
1405
  checkGraphOutArcList(adaptor, rev_adaptor.outNode(n2), 1);
1406
  checkGraphOutArcList(adaptor, rev_adaptor.inNode(n3), 1);
1407
  checkGraphOutArcList(adaptor, rev_adaptor.outNode(n3), 1);
1408
  checkGraphOutArcList(adaptor, rev_adaptor.inNode(n4), 0);
1409
  checkGraphOutArcList(adaptor, rev_adaptor.outNode(n4), 1);
1410

	
1411
  checkGraphInArcList(adaptor, rev_adaptor.inNode(n1), 1);
1412
  checkGraphInArcList(adaptor, rev_adaptor.outNode(n1), 1);
1413
  checkGraphInArcList(adaptor, rev_adaptor.inNode(n2), 1);
1414
  checkGraphInArcList(adaptor, rev_adaptor.outNode(n2), 0);
1415
  checkGraphInArcList(adaptor, rev_adaptor.inNode(n3), 1);
1416
  checkGraphInArcList(adaptor, rev_adaptor.outNode(n3), 1);
1417
  checkGraphInArcList(adaptor, rev_adaptor.inNode(n4), 1);
1418
  checkGraphInArcList(adaptor, rev_adaptor.outNode(n4), 2);
1419

	
1420
  checkNodeIds(adaptor);
1421
  checkArcIds(adaptor);
1422

	
1423
  checkGraphNodeMap(adaptor);
1424
  checkGraphArcMap(adaptor);
1425

	
1426
  // Check uadaptor
1427
  checkGraphNodeList(uadaptor, 8);
1428
  checkGraphEdgeList(uadaptor, 8);
1429
  checkGraphArcList(uadaptor, 16);
1430
  checkGraphConEdgeList(uadaptor, 8);
1431
  checkGraphConArcList(uadaptor, 16);
1432

	
1433
  checkNodeIds(uadaptor);
1434
  checkEdgeIds(uadaptor);
1435
  checkArcIds(uadaptor);
1436

	
1437
  checkGraphNodeMap(uadaptor);
1438
  checkGraphEdgeMap(uadaptor);
1439
  checkGraphArcMap(uadaptor);
1440

	
1441
  checkGraphIncEdgeArcLists(uadaptor, rev_adaptor.inNode(n1), 2);
1442
  checkGraphIncEdgeArcLists(uadaptor, rev_adaptor.outNode(n1), 2);
1443
  checkGraphIncEdgeArcLists(uadaptor, rev_adaptor.inNode(n2), 3);
1444
  checkGraphIncEdgeArcLists(uadaptor, rev_adaptor.outNode(n2), 1);
1445
  checkGraphIncEdgeArcLists(uadaptor, rev_adaptor.inNode(n3), 2);
1446
  checkGraphIncEdgeArcLists(uadaptor, rev_adaptor.outNode(n3), 2);
1447
  checkGraphIncEdgeArcLists(uadaptor, rev_adaptor.inNode(n4), 1);
1448
  checkGraphIncEdgeArcLists(uadaptor, rev_adaptor.outNode(n4), 3);
1449

	
1450
  // Check uuadaptor
1451
  checkGraphNodeList(uuadaptor, 8);
1452
  checkGraphEdgeList(uuadaptor, 16);
1453
  checkGraphArcList(uuadaptor, 32);
1454
  checkGraphConEdgeList(uuadaptor, 16);
1455
  checkGraphConArcList(uuadaptor, 32);
1456

	
1457
  checkNodeIds(uuadaptor);
1458
  checkEdgeIds(uuadaptor);
1459
  checkArcIds(uuadaptor);
1460

	
1461
  checkGraphNodeMap(uuadaptor);
1462
  checkGraphEdgeMap(uuadaptor);
1463
  checkGraphArcMap(uuadaptor);
1464
}
967 1465

	
968 1466
int main(int, const char **) {
969

	
1467
  // Check the digraph adaptors (using ListDigraph)
970 1468
  checkReverseDigraph();
971 1469
  checkSubDigraph();
972 1470
  checkFilterNodes1();
973 1471
  checkFilterArcs();
974 1472
  checkUndirector();
975
  checkResidual();
1473
  checkResidualDigraph();
976 1474
  checkSplitNodes();
977 1475

	
1476
  // Check the graph adaptors (using ListGraph)
978 1477
  checkSubGraph();
979 1478
  checkFilterNodes2();
980 1479
  checkFilterEdges();
981 1480
  checkOrienter();
982 1481

	
1482
  // Combine adaptors (using GridGraph)
1483
  checkCombiningAdaptors();
1484

	
983 1485
  return 0;
984 1486
}
Ignore white space 6 line context
1 1
#!/bin/bash
2 2

	
3 3
set -e
4 4

	
5 5
if [ $# -eq 0 -o x$1 = "x-h" -o x$1 = "x-help" -o x$1 = "x--help" ]; then
6 6
    echo "Usage:"
7 7
    echo "  $0 source-file(s)"
8 8
    exit
9 9
fi
10 10

	
11 11
for i in $@
12 12
do
13 13
    echo Update $i...
14 14
    TMP=`mktemp`
15 15
    sed -e "s/\<undirected graph\>/_gr_aph_label_/g"\
16 16
        -e "s/\<undirected graphs\>/_gr_aph_label_s/g"\
17 17
        -e "s/\<undirected edge\>/_ed_ge_label_/g"\
18 18
        -e "s/\<undirected edges\>/_ed_ge_label_s/g"\
19 19
        -e "s/\<directed graph\>/_digr_aph_label_/g"\
20 20
        -e "s/\<directed graphs\>/_digr_aph_label_s/g"\
21 21
        -e "s/\<directed edge\>/_ar_c_label_/g"\
22 22
        -e "s/\<directed edges\>/_ar_c_label_s/g"\
23 23
        -e "s/UGraph/_Gr_aph_label_/g"\
24 24
        -e "s/u[Gg]raph/_gr_aph_label_/g"\
25 25
        -e "s/\<Graph\>/_Digr_aph_label_/g"\
26 26
        -e "s/\<graph\>/_digr_aph_label_/g"\
27 27
        -e "s/\<Graphs\>/_Digr_aph_label_s/g"\
28 28
        -e "s/\<graphs\>/_digr_aph_label_s/g"\
29 29
        -e "s/_Graph/__Gr_aph_label_/g"\
30 30
        -e "s/\([Gg]\)raph\([a-z_]\)/_\1r_aph_label_\2/g"\
31 31
        -e "s/\([a-z_]\)graph/\1_gr_aph_label_/g"\
32 32
        -e "s/Graph/_Digr_aph_label_/g"\
33 33
        -e "s/graph/_digr_aph_label_/g"\
34 34
        -e "s/UEdge/_Ed_ge_label_/g"\
35 35
        -e "s/u[Ee]dge/_ed_ge_label_/g"\
36 36
        -e "s/IncEdgeIt/_In_cEd_geIt_label_/g"\
37 37
        -e "s/\<Edge\>/_Ar_c_label_/g"\
38 38
        -e "s/\<edge\>/_ar_c_label_/g"\
39 39
        -e "s/\<Edges\>/_Ar_c_label_s/g"\
40 40
        -e "s/\<edges\>/_ar_c_label_s/g"\
41 41
        -e "s/_Edge/__Ed_ge_label_/g"\
42 42
        -e "s/Edge\([a-z_]\)/_Ed_ge_label_\1/g"\
43 43
        -e "s/edge\([a-z_]\)/_ed_ge_label_\1/g"\
44 44
        -e "s/\([a-z_]\)edge/\1_ed_ge_label_/g"\
45 45
        -e "s/Edge/_Ar_c_label_/g"\
46 46
        -e "s/edge/_ar_c_label_/g"\
47 47
        -e "s/A[Nn]ode/_Re_d_label_/g"\
48 48
        -e "s/B[Nn]ode/_Blu_e_label_/g"\
49 49
        -e "s/A-[Nn]ode/_Re_d_label_/g"\
50 50
        -e "s/B-[Nn]ode/_Blu_e_label_/g"\
51 51
        -e "s/a[Nn]ode/_re_d_label_/g"\
52 52
        -e "s/b[Nn]ode/_blu_e_label_/g"\
53 53
        -e "s/\<UGRAPH_TYPEDEFS\([ \t]*([ \t]*\)typename[ \t]/TEMPLATE__GR_APH_TY_PEDE_FS_label_\1/g"\
54 54
        -e "s/\<GRAPH_TYPEDEFS\([ \t]*([ \t]*\)typename[ \t]/TEMPLATE__DIGR_APH_TY_PEDE_FS_label_\1/g"\
55 55
        -e "s/\<UGRAPH_TYPEDEFS\>/_GR_APH_TY_PEDE_FS_label_/g"\
56 56
        -e "s/\<GRAPH_TYPEDEFS\>/_DIGR_APH_TY_PEDE_FS_label_/g"\
57 57
        -e "s/_Digr_aph_label_/Digraph/g"\
58 58
        -e "s/_digr_aph_label_/digraph/g"\
59 59
        -e "s/_Gr_aph_label_/Graph/g"\
60 60
        -e "s/_gr_aph_label_/graph/g"\
61 61
        -e "s/_Ar_c_label_/Arc/g"\
62 62
        -e "s/_ar_c_label_/arc/g"\
63 63
        -e "s/_Ed_ge_label_/Edge/g"\
64 64
        -e "s/_ed_ge_label_/edge/g"\
65 65
        -e "s/_In_cEd_geIt_label_/IncEdgeIt/g"\
66 66
        -e "s/_Re_d_label_/Red/g"\
67 67
        -e "s/_Blu_e_label_/Blue/g"\
68 68
        -e "s/_re_d_label_/red/g"\
69 69
        -e "s/_blu_e_label_/blue/g"\
70 70
        -e "s/_GR_APH_TY_PEDE_FS_label_/GRAPH_TYPEDEFS/g"\
71 71
        -e "s/_DIGR_APH_TY_PEDE_FS_label_/DIGRAPH_TYPEDEFS/g"\
72 72
        -e "s/DigraphToEps/GraphToEps/g"\
73 73
        -e "s/digraphToEps/graphToEps/g"\
74 74
        -e "s/\<DefPredMap\>/SetPredMap/g"\
75 75
        -e "s/\<DefDistMap\>/SetDistMap/g"\
76 76
        -e "s/\<DefReachedMap\>/SetReachedMap/g"\
77 77
        -e "s/\<DefProcessedMap\>/SetProcessedMap/g"\
78 78
        -e "s/\<DefHeap\>/SetHeap/g"\
79 79
        -e "s/\<DefStandardHeap\>/SetStandradHeap/g"\
80 80
        -e "s/\<DefOperationTraits\>/SetOperationTraits/g"\
81 81
        -e "s/\<DefProcessedMapToBeDefaultMap\>/SetStandardProcessedMap/g"\
82 82
        -e "s/\<copyGraph\>/graphCopy/g"\
83 83
        -e "s/\<copyDigraph\>/digraphCopy/g"\
84 84
        -e "s/\<HyperCubeDigraph\>/HypercubeGraph/g"\
85 85
        -e "s/\<IntegerMap\>/RangeMap/g"\
86 86
        -e "s/\<integerMap\>/rangeMap/g"\
87 87
        -e "s/\<\([sS]\)tdMap\>/\1parseMap/g"\
88 88
        -e "s/\<\([Ff]\)unctorMap\>/\1unctorToMap/g"\
89 89
        -e "s/\<\([Mm]\)apFunctor\>/\1apToFunctor/g"\
90 90
        -e "s/\<\([Ff]\)orkWriteMap\>/\1orkMap/g"\
91 91
        -e "s/\<StoreBoolMap\>/LoggerBoolMap/g"\
92 92
        -e "s/\<storeBoolMap\>/loggerBoolMap/g"\
93 93
        -e "s/\<BoundingBox\>/Box/g"\
94 94
        -e "s/\<readNauty\>/readNautyGraph/g"\
95
        -e "s/\<RevDigraphAdaptor\>/ReverseDigraph/g"\
96
        -e "s/\<revDigraphAdaptor\>/reverseDigraph/g"\
97
        -e "s/\<SubDigraphAdaptor\>/SubDigraph/g"\
98
        -e "s/\<subDigraphAdaptor\>/subDigraph/g"\
99
        -e "s/\<SubGraphAdaptor\>/SubGraph/g"\
100
        -e "s/\<subGraphAdaptor\>/subGraph/g"\
101
        -e "s/\<NodeSubDigraphAdaptor\>/FilterNodes/g"\
102
        -e "s/\<nodeSubDigraphAdaptor\>/filterNodes/g"\
103
        -e "s/\<ArcSubDigraphAdaptor\>/FilterArcs/g"\
104
        -e "s/\<arcSubDigraphAdaptor\>/filterArcs/g"\
105
        -e "s/\<UndirDigraphAdaptor\>/Undirector/g"\
106
        -e "s/\<undirDigraphAdaptor\>/undirector/g"\
107
        -e "s/\<ResDigraphAdaptor\>/ResidualDigraph/g"\
108
        -e "s/\<resDigraphAdaptor\>/residualDigraph/g"\
109
        -e "s/\<SplitDigraphAdaptor\>/SplitNodes/g"\
110
        -e "s/\<splitDigraphAdaptor\>/splitNodes/g"\
111
        -e "s/\<SubGraphAdaptor\>/SubGraph/g"\
112
        -e "s/\<subGraphAdaptor\>/subGraph/g"\
113
        -e "s/\<NodeSubGraphAdaptor\>/FilterNodes/g"\
114
        -e "s/\<nodeSubGraphAdaptor\>/filterNodes/g"\
115
        -e "s/\<ArcSubGraphAdaptor\>/FilterEdges/g"\
116
        -e "s/\<arcSubGraphAdaptor\>/filterEdges/g"\
117
        -e "s/\<DirGraphAdaptor\>/Orienter/g"\
118
        -e "s/\<dirGraphAdaptor\>/orienter/g"\
95 119
    <$i > $TMP
96 120
    mv $TMP $i
97 121
done
0 comments (0 inline)