COIN-OR::LEMON - Graph Library

Ticket #302: 302-628519c21586.patch

File 302-628519c21586.patch, 23.0 KB (added by Peter Kovacs, 15 years ago)
  • lemon/maps.h

    # HG changeset patch
    # User Peter Kovacs <kpeter@inf.elte.hu>
    # Date 1249234315 -7200
    # Node ID 628519c21586cd33d77c0fd4483771d06067acc8
    # Parent  b52189c479fb3b19a4757d246b140d7220250b90
    Rearrange the doc of graph maps (#302)
    
    diff --git a/lemon/maps.h b/lemon/maps.h
    a b  
    18991899    InverseMap inverse() const { return InverseMap(*_graph);}
    19001900  };
    19011901
     1902  /// \brief Returns an \c IdMap class.
     1903  ///
     1904  /// This function just returns an \c IdMap class.
     1905  /// \relates IdMap
     1906  template <typename K, typename GR>
     1907  inline IdMap<GR, K> idMap(const GR& graph) {
     1908    return IdMap<GR, K>(graph);
     1909  }
     1910
     1911  /// \brief Provides continuous and unique id for the
     1912  /// items of a graph.
     1913  ///
     1914  /// RangeIdMap provides a unique and continuous
     1915  /// id for each item of a given type (\c Node, \c Arc or
     1916  /// \c Edge) in a graph. This id is
     1917  ///  - \b unique: different items get different ids,
     1918  ///  - \b continuous: the range of the ids is the set of integers
     1919  ///    between 0 and \c n-1, where \c n is the number of the items of
     1920  ///    this type (\c Node, \c Arc or \c Edge).
     1921  ///  - So, the ids can change when deleting an item of the same type.
     1922  ///
     1923  /// Thus this id is not (necessarily) the same as what can get using
     1924  /// the \c id() function of the graph or \ref IdMap.
     1925  /// This map can be inverted with its member class \c InverseMap,
     1926  /// or with the \c operator()() member.
     1927  ///
     1928  /// \tparam GR The graph type.
     1929  /// \tparam K The key type of the map (\c GR::Node, \c GR::Arc or
     1930  /// \c GR::Edge).
     1931  ///
     1932  /// \see IdMap
     1933  template <typename GR, typename K>
     1934  class RangeIdMap
     1935    : protected ItemSetTraits<GR, K>::template Map<int>::Type {
     1936
     1937    typedef typename ItemSetTraits<GR, K>::template Map<int>::Type Map;
     1938
     1939  public:
     1940    /// The graph type of RangeIdMap.
     1941    typedef GR Graph;
     1942    typedef GR Digraph;
     1943    /// The key type of RangeIdMap (\c Node, \c Arc or \c Edge).
     1944    typedef K Item;
     1945    /// The key type of RangeIdMap (\c Node, \c Arc or \c Edge).
     1946    typedef K Key;
     1947    /// The value type of RangeIdMap.
     1948    typedef int Value;
     1949
     1950    /// \brief Constructor.
     1951    ///
     1952    /// Constructor.
     1953    explicit RangeIdMap(const Graph& gr) : Map(gr) {
     1954      Item it;
     1955      const typename Map::Notifier* nf = Map::notifier();
     1956      for (nf->first(it); it != INVALID; nf->next(it)) {
     1957        Map::set(it, _inv_map.size());
     1958        _inv_map.push_back(it);
     1959      }
     1960    }
     1961
     1962  protected:
     1963
     1964    /// \brief Adds a new key to the map.
     1965    ///
     1966    /// Add a new key to the map. It is called by the
     1967    /// \c AlterationNotifier.
     1968    virtual void add(const Item& item) {
     1969      Map::add(item);
     1970      Map::set(item, _inv_map.size());
     1971      _inv_map.push_back(item);
     1972    }
     1973
     1974    /// \brief Add more new keys to the map.
     1975    ///
     1976    /// Add more new keys to the map. It is called by the
     1977    /// \c AlterationNotifier.
     1978    virtual void add(const std::vector<Item>& items) {
     1979      Map::add(items);
     1980      for (int i = 0; i < int(items.size()); ++i) {
     1981        Map::set(items[i], _inv_map.size());
     1982        _inv_map.push_back(items[i]);
     1983      }
     1984    }
     1985
     1986    /// \brief Erase the key from the map.
     1987    ///
     1988    /// Erase the key from the map. It is called by the
     1989    /// \c AlterationNotifier.
     1990    virtual void erase(const Item& item) {
     1991      Map::set(_inv_map.back(), Map::operator[](item));
     1992      _inv_map[Map::operator[](item)] = _inv_map.back();
     1993      _inv_map.pop_back();
     1994      Map::erase(item);
     1995    }
     1996
     1997    /// \brief Erase more keys from the map.
     1998    ///
     1999    /// Erase more keys from the map. It is called by the
     2000    /// \c AlterationNotifier.
     2001    virtual void erase(const std::vector<Item>& items) {
     2002      for (int i = 0; i < int(items.size()); ++i) {
     2003        Map::set(_inv_map.back(), Map::operator[](items[i]));
     2004        _inv_map[Map::operator[](items[i])] = _inv_map.back();
     2005        _inv_map.pop_back();
     2006      }
     2007      Map::erase(items);
     2008    }
     2009
     2010    /// \brief Build the unique map.
     2011    ///
     2012    /// Build the unique map. It is called by the
     2013    /// \c AlterationNotifier.
     2014    virtual void build() {
     2015      Map::build();
     2016      Item it;
     2017      const typename Map::Notifier* nf = Map::notifier();
     2018      for (nf->first(it); it != INVALID; nf->next(it)) {
     2019        Map::set(it, _inv_map.size());
     2020        _inv_map.push_back(it);
     2021      }
     2022    }
     2023
     2024    /// \brief Clear the keys from the map.
     2025    ///
     2026    /// Clear the keys from the map. It is called by the
     2027    /// \c AlterationNotifier.
     2028    virtual void clear() {
     2029      _inv_map.clear();
     2030      Map::clear();
     2031    }
     2032
     2033  public:
     2034
     2035    /// \brief Returns the maximal value plus one.
     2036    ///
     2037    /// Returns the maximal value plus one in the map.
     2038    unsigned int size() const {
     2039      return _inv_map.size();
     2040    }
     2041
     2042    /// \brief Swaps the position of the two items in the map.
     2043    ///
     2044    /// Swaps the position of the two items in the map.
     2045    void swap(const Item& p, const Item& q) {
     2046      int pi = Map::operator[](p);
     2047      int qi = Map::operator[](q);
     2048      Map::set(p, qi);
     2049      _inv_map[qi] = p;
     2050      Map::set(q, pi);
     2051      _inv_map[pi] = q;
     2052    }
     2053
     2054    /// \brief Gives back the \e range \e id of the item
     2055    ///
     2056    /// Gives back the \e range \e id of the item.
     2057    int operator[](const Item& item) const {
     2058      return Map::operator[](item);
     2059    }
     2060
     2061    /// \brief Gives back the item belonging to a \e range \e id
     2062    ///
     2063    /// Gives back the item belonging to the given \e range \e id.
     2064    Item operator()(int id) const {
     2065      return _inv_map[id];
     2066    }
     2067
     2068  private:
     2069
     2070    typedef std::vector<Item> Container;
     2071    Container _inv_map;
     2072
     2073  public:
     2074
     2075    /// \brief The inverse map type of RangeIdMap.
     2076    ///
     2077    /// The inverse map type of RangeIdMap. The subscript operator gives
     2078    /// back an item by its \e range \e id.
     2079    /// This type conforms to the \ref concepts::ReadMap "ReadMap" concept.
     2080    class InverseMap {
     2081    public:
     2082      /// \brief Constructor
     2083      ///
     2084      /// Constructor of the InverseMap.
     2085      explicit InverseMap(const RangeIdMap& inverted)
     2086        : _inverted(inverted) {}
     2087
     2088
     2089      /// The value type of the InverseMap.
     2090      typedef typename RangeIdMap::Key Value;
     2091      /// The key type of the InverseMap.
     2092      typedef typename RangeIdMap::Value Key;
     2093
     2094      /// \brief Subscript operator.
     2095      ///
     2096      /// Subscript operator. It gives back the item
     2097      /// that the given \e range \e id currently belongs to.
     2098      Value operator[](const Key& key) const {
     2099        return _inverted(key);
     2100      }
     2101
     2102      /// \brief Size of the map.
     2103      ///
     2104      /// Returns the size of the map.
     2105      unsigned int size() const {
     2106        return _inverted.size();
     2107      }
     2108
     2109    private:
     2110      const RangeIdMap& _inverted;
     2111    };
     2112
     2113    /// \brief Gives back the inverse of the map.
     2114    ///
     2115    /// Gives back the inverse of the RangeIdMap.
     2116    const InverseMap inverse() const {
     2117      return InverseMap(*this);
     2118    }
     2119  };
     2120
     2121  /// \brief Map of the source nodes of arcs in a digraph.
     2122  ///
     2123  /// SourceMap provides access for the source node of each arc in a digraph,
     2124  /// which is returned by the \c source() function of the digraph.
     2125  /// \tparam GR The digraph type.
     2126  /// \see TargetMap
     2127  template <typename GR>
     2128  class SourceMap {
     2129  public:
     2130
     2131    /// The key type (the \c Arc type of the digraph).
     2132    typedef typename GR::Arc Key;
     2133    /// The value type (the \c Node type of the digraph).
     2134    typedef typename GR::Node Value;
     2135
     2136    /// \brief Constructor
     2137    ///
     2138    /// Constructor.
     2139    /// \param digraph The digraph that the map belongs to.
     2140    explicit SourceMap(const GR& digraph) : _graph(digraph) {}
     2141
     2142    /// \brief Returns the source node of the given arc.
     2143    ///
     2144    /// Returns the source node of the given arc.
     2145    Value operator[](const Key& arc) const {
     2146      return _graph.source(arc);
     2147    }
     2148
     2149  private:
     2150    const GR& _graph;
     2151  };
     2152
     2153  /// \brief Returns a \c SourceMap class.
     2154  ///
     2155  /// This function just returns an \c SourceMap class.
     2156  /// \relates SourceMap
     2157  template <typename GR>
     2158  inline SourceMap<GR> sourceMap(const GR& graph) {
     2159    return SourceMap<GR>(graph);
     2160  }
     2161
     2162  /// \brief Map of the target nodes of arcs in a digraph.
     2163  ///
     2164  /// TargetMap provides access for the target node of each arc in a digraph,
     2165  /// which is returned by the \c target() function of the digraph.
     2166  /// \tparam GR The digraph type.
     2167  /// \see SourceMap
     2168  template <typename GR>
     2169  class TargetMap {
     2170  public:
     2171
     2172    /// The key type (the \c Arc type of the digraph).
     2173    typedef typename GR::Arc Key;
     2174    /// The value type (the \c Node type of the digraph).
     2175    typedef typename GR::Node Value;
     2176
     2177    /// \brief Constructor
     2178    ///
     2179    /// Constructor.
     2180    /// \param digraph The digraph that the map belongs to.
     2181    explicit TargetMap(const GR& digraph) : _graph(digraph) {}
     2182
     2183    /// \brief Returns the target node of the given arc.
     2184    ///
     2185    /// Returns the target node of the given arc.
     2186    Value operator[](const Key& e) const {
     2187      return _graph.target(e);
     2188    }
     2189
     2190  private:
     2191    const GR& _graph;
     2192  };
     2193
     2194  /// \brief Returns a \c TargetMap class.
     2195  ///
     2196  /// This function just returns a \c TargetMap class.
     2197  /// \relates TargetMap
     2198  template <typename GR>
     2199  inline TargetMap<GR> targetMap(const GR& graph) {
     2200    return TargetMap<GR>(graph);
     2201  }
     2202
     2203  /// \brief Map of the "forward" directed arc view of edges in a graph.
     2204  ///
     2205  /// ForwardMap provides access for the "forward" directed arc view of
     2206  /// each edge in a graph, which is returned by the \c direct() function
     2207  /// of the graph with \c true parameter.
     2208  /// \tparam GR The graph type.
     2209  /// \see BackwardMap
     2210  template <typename GR>
     2211  class ForwardMap {
     2212  public:
     2213
     2214    /// The key type (the \c Edge type of the digraph).
     2215    typedef typename GR::Edge Key;
     2216    /// The value type (the \c Arc type of the digraph).
     2217    typedef typename GR::Arc Value;
     2218
     2219    /// \brief Constructor
     2220    ///
     2221    /// Constructor.
     2222    /// \param graph The graph that the map belongs to.
     2223    explicit ForwardMap(const GR& graph) : _graph(graph) {}
     2224
     2225    /// \brief Returns the "forward" directed arc view of the given edge.
     2226    ///
     2227    /// Returns the "forward" directed arc view of the given edge.
     2228    Value operator[](const Key& key) const {
     2229      return _graph.direct(key, true);
     2230    }
     2231
     2232  private:
     2233    const GR& _graph;
     2234  };
     2235
     2236  /// \brief Returns a \c ForwardMap class.
     2237  ///
     2238  /// This function just returns an \c ForwardMap class.
     2239  /// \relates ForwardMap
     2240  template <typename GR>
     2241  inline ForwardMap<GR> forwardMap(const GR& graph) {
     2242    return ForwardMap<GR>(graph);
     2243  }
     2244
     2245  /// \brief Map of the "backward" directed arc view of edges in a graph.
     2246  ///
     2247  /// BackwardMap provides access for the "backward" directed arc view of
     2248  /// each edge in a graph, which is returned by the \c direct() function
     2249  /// of the graph with \c false parameter.
     2250  /// \tparam GR The graph type.
     2251  /// \see ForwardMap
     2252  template <typename GR>
     2253  class BackwardMap {
     2254  public:
     2255
     2256    /// The key type (the \c Edge type of the digraph).
     2257    typedef typename GR::Edge Key;
     2258    /// The value type (the \c Arc type of the digraph).
     2259    typedef typename GR::Arc Value;
     2260
     2261    /// \brief Constructor
     2262    ///
     2263    /// Constructor.
     2264    /// \param graph The graph that the map belongs to.
     2265    explicit BackwardMap(const GR& graph) : _graph(graph) {}
     2266
     2267    /// \brief Returns the "backward" directed arc view of the given edge.
     2268    ///
     2269    /// Returns the "backward" directed arc view of the given edge.
     2270    Value operator[](const Key& key) const {
     2271      return _graph.direct(key, false);
     2272    }
     2273
     2274  private:
     2275    const GR& _graph;
     2276  };
     2277
     2278  /// \brief Returns a \c BackwardMap class
     2279
     2280  /// This function just returns a \c BackwardMap class.
     2281  /// \relates BackwardMap
     2282  template <typename GR>
     2283  inline BackwardMap<GR> backwardMap(const GR& graph) {
     2284    return BackwardMap<GR>(graph);
     2285  }
    19022286
    19032287  /// \brief General cross reference graph map type.
    19042288
     
    21492533
    21502534  };
    21512535
    2152   /// \brief Provides continuous and unique id for the
    2153   /// items of a graph.
    2154   ///
    2155   /// RangeIdMap provides a unique and continuous
    2156   /// id for each item of a given type (\c Node, \c Arc or
    2157   /// \c Edge) in a graph. This id is
    2158   ///  - \b unique: different items get different ids,
    2159   ///  - \b continuous: the range of the ids is the set of integers
    2160   ///    between 0 and \c n-1, where \c n is the number of the items of
    2161   ///    this type (\c Node, \c Arc or \c Edge).
    2162   ///  - So, the ids can change when deleting an item of the same type.
    2163   ///
    2164   /// Thus this id is not (necessarily) the same as what can get using
    2165   /// the \c id() function of the graph or \ref IdMap.
    2166   /// This map can be inverted with its member class \c InverseMap,
    2167   /// or with the \c operator()() member.
    2168   ///
    2169   /// \tparam GR The graph type.
    2170   /// \tparam K The key type of the map (\c GR::Node, \c GR::Arc or
    2171   /// \c GR::Edge).
    2172   ///
    2173   /// \see IdMap
    2174   template <typename GR, typename K>
    2175   class RangeIdMap
    2176     : protected ItemSetTraits<GR, K>::template Map<int>::Type {
    2177 
    2178     typedef typename ItemSetTraits<GR, K>::template Map<int>::Type Map;
    2179 
    2180   public:
    2181     /// The graph type of RangeIdMap.
    2182     typedef GR Graph;
    2183     typedef GR Digraph;
    2184     /// The key type of RangeIdMap (\c Node, \c Arc or \c Edge).
    2185     typedef K Item;
    2186     /// The key type of RangeIdMap (\c Node, \c Arc or \c Edge).
    2187     typedef K Key;
    2188     /// The value type of RangeIdMap.
    2189     typedef int Value;
    2190 
    2191     /// \brief Constructor.
    2192     ///
    2193     /// Constructor.
    2194     explicit RangeIdMap(const Graph& gr) : Map(gr) {
    2195       Item it;
    2196       const typename Map::Notifier* nf = Map::notifier();
    2197       for (nf->first(it); it != INVALID; nf->next(it)) {
    2198         Map::set(it, _inv_map.size());
    2199         _inv_map.push_back(it);
    2200       }
    2201     }
    2202 
    2203   protected:
    2204 
    2205     /// \brief Adds a new key to the map.
    2206     ///
    2207     /// Add a new key to the map. It is called by the
    2208     /// \c AlterationNotifier.
    2209     virtual void add(const Item& item) {
    2210       Map::add(item);
    2211       Map::set(item, _inv_map.size());
    2212       _inv_map.push_back(item);
    2213     }
    2214 
    2215     /// \brief Add more new keys to the map.
    2216     ///
    2217     /// Add more new keys to the map. It is called by the
    2218     /// \c AlterationNotifier.
    2219     virtual void add(const std::vector<Item>& items) {
    2220       Map::add(items);
    2221       for (int i = 0; i < int(items.size()); ++i) {
    2222         Map::set(items[i], _inv_map.size());
    2223         _inv_map.push_back(items[i]);
    2224       }
    2225     }
    2226 
    2227     /// \brief Erase the key from the map.
    2228     ///
    2229     /// Erase the key from the map. It is called by the
    2230     /// \c AlterationNotifier.
    2231     virtual void erase(const Item& item) {
    2232       Map::set(_inv_map.back(), Map::operator[](item));
    2233       _inv_map[Map::operator[](item)] = _inv_map.back();
    2234       _inv_map.pop_back();
    2235       Map::erase(item);
    2236     }
    2237 
    2238     /// \brief Erase more keys from the map.
    2239     ///
    2240     /// Erase more keys from the map. It is called by the
    2241     /// \c AlterationNotifier.
    2242     virtual void erase(const std::vector<Item>& items) {
    2243       for (int i = 0; i < int(items.size()); ++i) {
    2244         Map::set(_inv_map.back(), Map::operator[](items[i]));
    2245         _inv_map[Map::operator[](items[i])] = _inv_map.back();
    2246         _inv_map.pop_back();
    2247       }
    2248       Map::erase(items);
    2249     }
    2250 
    2251     /// \brief Build the unique map.
    2252     ///
    2253     /// Build the unique map. It is called by the
    2254     /// \c AlterationNotifier.
    2255     virtual void build() {
    2256       Map::build();
    2257       Item it;
    2258       const typename Map::Notifier* nf = Map::notifier();
    2259       for (nf->first(it); it != INVALID; nf->next(it)) {
    2260         Map::set(it, _inv_map.size());
    2261         _inv_map.push_back(it);
    2262       }
    2263     }
    2264 
    2265     /// \brief Clear the keys from the map.
    2266     ///
    2267     /// Clear the keys from the map. It is called by the
    2268     /// \c AlterationNotifier.
    2269     virtual void clear() {
    2270       _inv_map.clear();
    2271       Map::clear();
    2272     }
    2273 
    2274   public:
    2275 
    2276     /// \brief Returns the maximal value plus one.
    2277     ///
    2278     /// Returns the maximal value plus one in the map.
    2279     unsigned int size() const {
    2280       return _inv_map.size();
    2281     }
    2282 
    2283     /// \brief Swaps the position of the two items in the map.
    2284     ///
    2285     /// Swaps the position of the two items in the map.
    2286     void swap(const Item& p, const Item& q) {
    2287       int pi = Map::operator[](p);
    2288       int qi = Map::operator[](q);
    2289       Map::set(p, qi);
    2290       _inv_map[qi] = p;
    2291       Map::set(q, pi);
    2292       _inv_map[pi] = q;
    2293     }
    2294 
    2295     /// \brief Gives back the \e range \e id of the item
    2296     ///
    2297     /// Gives back the \e range \e id of the item.
    2298     int operator[](const Item& item) const {
    2299       return Map::operator[](item);
    2300     }
    2301 
    2302     /// \brief Gives back the item belonging to a \e range \e id
    2303     ///
    2304     /// Gives back the item belonging to the given \e range \e id.
    2305     Item operator()(int id) const {
    2306       return _inv_map[id];
    2307     }
    2308 
    2309   private:
    2310 
    2311     typedef std::vector<Item> Container;
    2312     Container _inv_map;
    2313 
    2314   public:
    2315 
    2316     /// \brief The inverse map type of RangeIdMap.
    2317     ///
    2318     /// The inverse map type of RangeIdMap. The subscript operator gives
    2319     /// back an item by its \e range \e id.
    2320     /// This type conforms to the \ref concepts::ReadMap "ReadMap" concept.
    2321     class InverseMap {
    2322     public:
    2323       /// \brief Constructor
    2324       ///
    2325       /// Constructor of the InverseMap.
    2326       explicit InverseMap(const RangeIdMap& inverted)
    2327         : _inverted(inverted) {}
    2328 
    2329 
    2330       /// The value type of the InverseMap.
    2331       typedef typename RangeIdMap::Key Value;
    2332       /// The key type of the InverseMap.
    2333       typedef typename RangeIdMap::Value Key;
    2334 
    2335       /// \brief Subscript operator.
    2336       ///
    2337       /// Subscript operator. It gives back the item
    2338       /// that the given \e range \e id currently belongs to.
    2339       Value operator[](const Key& key) const {
    2340         return _inverted(key);
    2341       }
    2342 
    2343       /// \brief Size of the map.
    2344       ///
    2345       /// Returns the size of the map.
    2346       unsigned int size() const {
    2347         return _inverted.size();
    2348       }
    2349 
    2350     private:
    2351       const RangeIdMap& _inverted;
    2352     };
    2353 
    2354     /// \brief Gives back the inverse of the map.
    2355     ///
    2356     /// Gives back the inverse of the RangeIdMap.
    2357     const InverseMap inverse() const {
    2358       return InverseMap(*this);
    2359     }
    2360   };
    2361 
    23622536  /// \brief Dynamic iterable \c bool map.
    23632537  ///
    23642538  /// This class provides a special graph map type which can store a
     
    32703444    std::map<Value, Key> _first;
    32713445  };
    32723446
    3273   /// \brief Map of the source nodes of arcs in a digraph.
    3274   ///
    3275   /// SourceMap provides access for the source node of each arc in a digraph,
    3276   /// which is returned by the \c source() function of the digraph.
    3277   /// \tparam GR The digraph type.
    3278   /// \see TargetMap
    3279   template <typename GR>
    3280   class SourceMap {
    3281   public:
    3282 
    3283     ///\e
    3284     typedef typename GR::Arc Key;
    3285     ///\e
    3286     typedef typename GR::Node Value;
    3287 
    3288     /// \brief Constructor
    3289     ///
    3290     /// Constructor.
    3291     /// \param digraph The digraph that the map belongs to.
    3292     explicit SourceMap(const GR& digraph) : _graph(digraph) {}
    3293 
    3294     /// \brief Returns the source node of the given arc.
    3295     ///
    3296     /// Returns the source node of the given arc.
    3297     Value operator[](const Key& arc) const {
    3298       return _graph.source(arc);
    3299     }
    3300 
    3301   private:
    3302     const GR& _graph;
    3303   };
    3304 
    3305   /// \brief Returns a \c SourceMap class.
    3306   ///
    3307   /// This function just returns an \c SourceMap class.
    3308   /// \relates SourceMap
    3309   template <typename GR>
    3310   inline SourceMap<GR> sourceMap(const GR& graph) {
    3311     return SourceMap<GR>(graph);
    3312   }
    3313 
    3314   /// \brief Map of the target nodes of arcs in a digraph.
    3315   ///
    3316   /// TargetMap provides access for the target node of each arc in a digraph,
    3317   /// which is returned by the \c target() function of the digraph.
    3318   /// \tparam GR The digraph type.
    3319   /// \see SourceMap
    3320   template <typename GR>
    3321   class TargetMap {
    3322   public:
    3323 
    3324     ///\e
    3325     typedef typename GR::Arc Key;
    3326     ///\e
    3327     typedef typename GR::Node Value;
    3328 
    3329     /// \brief Constructor
    3330     ///
    3331     /// Constructor.
    3332     /// \param digraph The digraph that the map belongs to.
    3333     explicit TargetMap(const GR& digraph) : _graph(digraph) {}
    3334 
    3335     /// \brief Returns the target node of the given arc.
    3336     ///
    3337     /// Returns the target node of the given arc.
    3338     Value operator[](const Key& e) const {
    3339       return _graph.target(e);
    3340     }
    3341 
    3342   private:
    3343     const GR& _graph;
    3344   };
    3345 
    3346   /// \brief Returns a \c TargetMap class.
    3347   ///
    3348   /// This function just returns a \c TargetMap class.
    3349   /// \relates TargetMap
    3350   template <typename GR>
    3351   inline TargetMap<GR> targetMap(const GR& graph) {
    3352     return TargetMap<GR>(graph);
    3353   }
    3354 
    3355   /// \brief Map of the "forward" directed arc view of edges in a graph.
    3356   ///
    3357   /// ForwardMap provides access for the "forward" directed arc view of
    3358   /// each edge in a graph, which is returned by the \c direct() function
    3359   /// of the graph with \c true parameter.
    3360   /// \tparam GR The graph type.
    3361   /// \see BackwardMap
    3362   template <typename GR>
    3363   class ForwardMap {
    3364   public:
    3365 
    3366     typedef typename GR::Arc Value;
    3367     typedef typename GR::Edge Key;
    3368 
    3369     /// \brief Constructor
    3370     ///
    3371     /// Constructor.
    3372     /// \param graph The graph that the map belongs to.
    3373     explicit ForwardMap(const GR& graph) : _graph(graph) {}
    3374 
    3375     /// \brief Returns the "forward" directed arc view of the given edge.
    3376     ///
    3377     /// Returns the "forward" directed arc view of the given edge.
    3378     Value operator[](const Key& key) const {
    3379       return _graph.direct(key, true);
    3380     }
    3381 
    3382   private:
    3383     const GR& _graph;
    3384   };
    3385 
    3386   /// \brief Returns a \c ForwardMap class.
    3387   ///
    3388   /// This function just returns an \c ForwardMap class.
    3389   /// \relates ForwardMap
    3390   template <typename GR>
    3391   inline ForwardMap<GR> forwardMap(const GR& graph) {
    3392     return ForwardMap<GR>(graph);
    3393   }
    3394 
    3395   /// \brief Map of the "backward" directed arc view of edges in a graph.
    3396   ///
    3397   /// BackwardMap provides access for the "backward" directed arc view of
    3398   /// each edge in a graph, which is returned by the \c direct() function
    3399   /// of the graph with \c false parameter.
    3400   /// \tparam GR The graph type.
    3401   /// \see ForwardMap
    3402   template <typename GR>
    3403   class BackwardMap {
    3404   public:
    3405 
    3406     typedef typename GR::Arc Value;
    3407     typedef typename GR::Edge Key;
    3408 
    3409     /// \brief Constructor
    3410     ///
    3411     /// Constructor.
    3412     /// \param graph The graph that the map belongs to.
    3413     explicit BackwardMap(const GR& graph) : _graph(graph) {}
    3414 
    3415     /// \brief Returns the "backward" directed arc view of the given edge.
    3416     ///
    3417     /// Returns the "backward" directed arc view of the given edge.
    3418     Value operator[](const Key& key) const {
    3419       return _graph.direct(key, false);
    3420     }
    3421 
    3422   private:
    3423     const GR& _graph;
    3424   };
    3425 
    3426   /// \brief Returns a \c BackwardMap class
    3427 
    3428   /// This function just returns a \c BackwardMap class.
    3429   /// \relates BackwardMap
    3430   template <typename GR>
    3431   inline BackwardMap<GR> backwardMap(const GR& graph) {
    3432     return BackwardMap<GR>(graph);
    3433   }
    3434 
    34353447  /// \brief Map of the in-degrees of nodes in a digraph.
    34363448  ///
    34373449  /// This map returns the in-degree of a node. Once it is constructed,