... |
... |
@@ -1886,49 +1886,49 @@
|
1886 |
1886 |
|
1887 |
1887 |
/// \brief Gives back an item by its id.
|
1888 |
1888 |
///
|
1889 |
1889 |
/// Gives back an item by its id.
|
1890 |
1890 |
Item operator[](int id) const { return _graph->fromId(id, Item());}
|
1891 |
1891 |
|
1892 |
1892 |
private:
|
1893 |
1893 |
const Graph* _graph;
|
1894 |
1894 |
};
|
1895 |
1895 |
|
1896 |
1896 |
/// \brief Gives back the inverse of the map.
|
1897 |
1897 |
///
|
1898 |
1898 |
/// Gives back the inverse of the IdMap.
|
1899 |
1899 |
InverseMap inverse() const { return InverseMap(*_graph);}
|
1900 |
1900 |
};
|
1901 |
1901 |
|
1902 |
1902 |
|
1903 |
1903 |
/// \brief General cross reference graph map type.
|
1904 |
1904 |
|
1905 |
1905 |
/// This class provides simple invertable graph maps.
|
1906 |
1906 |
/// It wraps a standard graph map (\c NodeMap, \c ArcMap or \c EdgeMap)
|
1907 |
1907 |
/// and if a key is set to a new value, then stores it in the inverse map.
|
1908 |
1908 |
/// The graph items can be accessed by their values either using
|
1909 |
1909 |
/// \c InverseMap or \c operator()(), and the values of the map can be
|
1910 |
|
/// accessed with an STL compatible forward iterator (\c ValueIterator).
|
|
1910 |
/// accessed with an STL compatible forward iterator (\c ValueIt).
|
1911 |
1911 |
///
|
1912 |
1912 |
/// This map is intended to be used when all associated values are
|
1913 |
1913 |
/// different (the map is actually invertable) or there are only a few
|
1914 |
1914 |
/// items with the same value.
|
1915 |
1915 |
/// Otherwise consider to use \c IterableValueMap, which is more
|
1916 |
1916 |
/// suitable and more efficient for such cases. It provides iterators
|
1917 |
1917 |
/// to traverse the items with the same associated value, however
|
1918 |
1918 |
/// it does not have \c InverseMap.
|
1919 |
1919 |
///
|
1920 |
1920 |
/// This type is not reference map, so it cannot be modified with
|
1921 |
1921 |
/// the subscript operator.
|
1922 |
1922 |
///
|
1923 |
1923 |
/// \tparam GR The graph type.
|
1924 |
1924 |
/// \tparam K The key type of the map (\c GR::Node, \c GR::Arc or
|
1925 |
1925 |
/// \c GR::Edge).
|
1926 |
1926 |
/// \tparam V The value type of the map.
|
1927 |
1927 |
///
|
1928 |
1928 |
/// \see IterableValueMap
|
1929 |
1929 |
template <typename GR, typename K, typename V>
|
1930 |
1930 |
class CrossRefMap
|
1931 |
1931 |
: protected ItemSetTraits<GR, K>::template Map<V>::Type {
|
1932 |
1932 |
private:
|
1933 |
1933 |
|
1934 |
1934 |
typedef typename ItemSetTraits<GR, K>::
|
... |
... |
@@ -1940,100 +1940,103 @@
|
1940 |
1940 |
public:
|
1941 |
1941 |
|
1942 |
1942 |
/// The graph type of CrossRefMap.
|
1943 |
1943 |
typedef GR Graph;
|
1944 |
1944 |
typedef GR Digraph;
|
1945 |
1945 |
/// The key type of CrossRefMap (\c Node, \c Arc or \c Edge).
|
1946 |
1946 |
typedef K Item;
|
1947 |
1947 |
/// The key type of CrossRefMap (\c Node, \c Arc or \c Edge).
|
1948 |
1948 |
typedef K Key;
|
1949 |
1949 |
/// The value type of CrossRefMap.
|
1950 |
1950 |
typedef V Value;
|
1951 |
1951 |
|
1952 |
1952 |
/// \brief Constructor.
|
1953 |
1953 |
///
|
1954 |
1954 |
/// Construct a new CrossRefMap for the given graph.
|
1955 |
1955 |
explicit CrossRefMap(const Graph& graph) : Map(graph) {}
|
1956 |
1956 |
|
1957 |
1957 |
/// \brief Forward iterator for values.
|
1958 |
1958 |
///
|
1959 |
1959 |
/// This iterator is an STL compatible forward
|
1960 |
1960 |
/// iterator on the values of the map. The values can
|
1961 |
1961 |
/// be accessed in the <tt>[beginValue, endValue)</tt> range.
|
1962 |
1962 |
/// They are considered with multiplicity, so each value is
|
1963 |
1963 |
/// traversed for each item it is assigned to.
|
1964 |
|
class ValueIterator
|
|
1964 |
class ValueIt
|
1965 |
1965 |
: public std::iterator<std::forward_iterator_tag, Value> {
|
1966 |
1966 |
friend class CrossRefMap;
|
1967 |
1967 |
private:
|
1968 |
|
ValueIterator(typename Container::const_iterator _it)
|
|
1968 |
ValueIt(typename Container::const_iterator _it)
|
1969 |
1969 |
: it(_it) {}
|
1970 |
1970 |
public:
|
1971 |
1971 |
|
1972 |
1972 |
/// Constructor
|
1973 |
|
ValueIterator() {}
|
|
1973 |
ValueIt() {}
|
1974 |
1974 |
|
1975 |
1975 |
/// \e
|
1976 |
|
ValueIterator& operator++() { ++it; return *this; }
|
|
1976 |
ValueIt& operator++() { ++it; return *this; }
|
1977 |
1977 |
/// \e
|
1978 |
|
ValueIterator operator++(int) {
|
1979 |
|
ValueIterator tmp(*this);
|
|
1978 |
ValueIt operator++(int) {
|
|
1979 |
ValueIt tmp(*this);
|
1980 |
1980 |
operator++();
|
1981 |
1981 |
return tmp;
|
1982 |
1982 |
}
|
1983 |
1983 |
|
1984 |
1984 |
/// \e
|
1985 |
1985 |
const Value& operator*() const { return it->first; }
|
1986 |
1986 |
/// \e
|
1987 |
1987 |
const Value* operator->() const { return &(it->first); }
|
1988 |
1988 |
|
1989 |
1989 |
/// \e
|
1990 |
|
bool operator==(ValueIterator jt) const { return it == jt.it; }
|
|
1990 |
bool operator==(ValueIt jt) const { return it == jt.it; }
|
1991 |
1991 |
/// \e
|
1992 |
|
bool operator!=(ValueIterator jt) const { return it != jt.it; }
|
|
1992 |
bool operator!=(ValueIt jt) const { return it != jt.it; }
|
1993 |
1993 |
|
1994 |
1994 |
private:
|
1995 |
1995 |
typename Container::const_iterator it;
|
1996 |
1996 |
};
|
1997 |
1997 |
|
|
1998 |
/// Alias for \c ValueIt
|
|
1999 |
typedef ValueIt ValueIterator;
|
|
2000 |
|
1998 |
2001 |
/// \brief Returns an iterator to the first value.
|
1999 |
2002 |
///
|
2000 |
2003 |
/// Returns an STL compatible iterator to the
|
2001 |
2004 |
/// first value of the map. The values of the
|
2002 |
2005 |
/// map can be accessed in the <tt>[beginValue, endValue)</tt>
|
2003 |
2006 |
/// range.
|
2004 |
|
ValueIterator beginValue() const {
|
2005 |
|
return ValueIterator(_inv_map.begin());
|
|
2007 |
ValueIt beginValue() const {
|
|
2008 |
return ValueIt(_inv_map.begin());
|
2006 |
2009 |
}
|
2007 |
2010 |
|
2008 |
2011 |
/// \brief Returns an iterator after the last value.
|
2009 |
2012 |
///
|
2010 |
2013 |
/// Returns an STL compatible iterator after the
|
2011 |
2014 |
/// last value of the map. The values of the
|
2012 |
2015 |
/// map can be accessed in the <tt>[beginValue, endValue)</tt>
|
2013 |
2016 |
/// range.
|
2014 |
|
ValueIterator endValue() const {
|
2015 |
|
return ValueIterator(_inv_map.end());
|
|
2017 |
ValueIt endValue() const {
|
|
2018 |
return ValueIt(_inv_map.end());
|
2016 |
2019 |
}
|
2017 |
2020 |
|
2018 |
2021 |
/// \brief Sets the value associated with the given key.
|
2019 |
2022 |
///
|
2020 |
2023 |
/// Sets the value associated with the given key.
|
2021 |
2024 |
void set(const Key& key, const Value& val) {
|
2022 |
2025 |
Value oldval = Map::operator[](key);
|
2023 |
2026 |
typename Container::iterator it;
|
2024 |
2027 |
for (it = _inv_map.equal_range(oldval).first;
|
2025 |
2028 |
it != _inv_map.equal_range(oldval).second; ++it) {
|
2026 |
2029 |
if (it->second == key) {
|
2027 |
2030 |
_inv_map.erase(it);
|
2028 |
2031 |
break;
|
2029 |
2032 |
}
|
2030 |
2033 |
}
|
2031 |
2034 |
_inv_map.insert(std::make_pair(val, key));
|
2032 |
2035 |
Map::set(key, val);
|
2033 |
2036 |
}
|
2034 |
2037 |
|
2035 |
2038 |
/// \brief Returns the value associated with the given key.
|
2036 |
2039 |
///
|
2037 |
2040 |
/// Returns the value associated with the given key.
|
2038 |
2041 |
typename MapTraits<Map>::ConstReturnValue
|
2039 |
2042 |
operator[](const Key& key) const {
|
... |
... |
@@ -3002,49 +3005,49 @@
|
3002 |
3005 |
virtual void clear() {
|
3003 |
3006 |
_first.clear();
|
3004 |
3007 |
Parent::clear();
|
3005 |
3008 |
}
|
3006 |
3009 |
|
3007 |
3010 |
private:
|
3008 |
3011 |
std::vector<Key> _first;
|
3009 |
3012 |
};
|
3010 |
3013 |
|
3011 |
3014 |
namespace _maps_bits {
|
3012 |
3015 |
template <typename Item, typename Value>
|
3013 |
3016 |
struct IterableValueMapNode {
|
3014 |
3017 |
IterableValueMapNode(Value _value = Value()) : value(_value) {}
|
3015 |
3018 |
Item prev, next;
|
3016 |
3019 |
Value value;
|
3017 |
3020 |
};
|
3018 |
3021 |
}
|
3019 |
3022 |
|
3020 |
3023 |
/// \brief Dynamic iterable map for comparable values.
|
3021 |
3024 |
///
|
3022 |
3025 |
/// This class provides a special graph map type which can store a
|
3023 |
3026 |
/// comparable value for graph items (\c Node, \c Arc or \c Edge).
|
3024 |
3027 |
/// For each value it is possible to iterate on the keys mapped to
|
3025 |
3028 |
/// the value (\c ItemIt), and the values of the map can be accessed
|
3026 |
|
/// with an STL compatible forward iterator (\c ValueIterator).
|
|
3029 |
/// with an STL compatible forward iterator (\c ValueIt).
|
3027 |
3030 |
/// The map stores a linked list for each value, which contains
|
3028 |
3031 |
/// the items mapped to the value, and the used values are stored
|
3029 |
3032 |
/// in balanced binary tree (\c std::map).
|
3030 |
3033 |
///
|
3031 |
3034 |
/// \ref IterableBoolMap and \ref IterableIntMap are similar classes
|
3032 |
3035 |
/// specialized for \c bool and \c int values, respectively.
|
3033 |
3036 |
///
|
3034 |
3037 |
/// This type is not reference map, so it cannot be modified with
|
3035 |
3038 |
/// the subscript operator.
|
3036 |
3039 |
///
|
3037 |
3040 |
/// \tparam GR The graph type.
|
3038 |
3041 |
/// \tparam K The key type of the map (\c GR::Node, \c GR::Arc or
|
3039 |
3042 |
/// \c GR::Edge).
|
3040 |
3043 |
/// \tparam V The value type of the map. It can be any comparable
|
3041 |
3044 |
/// value type.
|
3042 |
3045 |
///
|
3043 |
3046 |
/// \see IterableBoolMap, IterableIntMap
|
3044 |
3047 |
/// \see CrossRefMap
|
3045 |
3048 |
template <typename GR, typename K, typename V>
|
3046 |
3049 |
class IterableValueMap
|
3047 |
3050 |
: protected ItemSetTraits<GR, K>::
|
3048 |
3051 |
template Map<_maps_bits::IterableValueMapNode<K, V> >::Type {
|
3049 |
3052 |
public:
|
3050 |
3053 |
typedef typename ItemSetTraits<GR, K>::
|
... |
... |
@@ -3090,100 +3093,100 @@
|
3090 |
3093 |
|
3091 |
3094 |
void lace(const Key& key) {
|
3092 |
3095 |
typename Parent::Value& node = Parent::operator[](key);
|
3093 |
3096 |
typename std::map<Value, Key>::iterator it = _first.find(node.value);
|
3094 |
3097 |
if (it == _first.end()) {
|
3095 |
3098 |
node.prev = node.next = INVALID;
|
3096 |
3099 |
_first.insert(std::make_pair(node.value, key));
|
3097 |
3100 |
} else {
|
3098 |
3101 |
node.prev = INVALID;
|
3099 |
3102 |
node.next = it->second;
|
3100 |
3103 |
if (node.next != INVALID) {
|
3101 |
3104 |
Parent::operator[](node.next).prev = key;
|
3102 |
3105 |
}
|
3103 |
3106 |
it->second = key;
|
3104 |
3107 |
}
|
3105 |
3108 |
}
|
3106 |
3109 |
|
3107 |
3110 |
public:
|
3108 |
3111 |
|
3109 |
3112 |
/// \brief Forward iterator for values.
|
3110 |
3113 |
///
|
3111 |
3114 |
/// This iterator is an STL compatible forward
|
3112 |
3115 |
/// iterator on the values of the map. The values can
|
3113 |
3116 |
/// be accessed in the <tt>[beginValue, endValue)</tt> range.
|
3114 |
|
class ValueIterator
|
|
3117 |
class ValueIt
|
3115 |
3118 |
: public std::iterator<std::forward_iterator_tag, Value> {
|
3116 |
3119 |
friend class IterableValueMap;
|
3117 |
3120 |
private:
|
3118 |
|
ValueIterator(typename std::map<Value, Key>::const_iterator _it)
|
|
3121 |
ValueIt(typename std::map<Value, Key>::const_iterator _it)
|
3119 |
3122 |
: it(_it) {}
|
3120 |
3123 |
public:
|
3121 |
3124 |
|
3122 |
3125 |
/// Constructor
|
3123 |
|
ValueIterator() {}
|
|
3126 |
ValueIt() {}
|
3124 |
3127 |
|
3125 |
3128 |
/// \e
|
3126 |
|
ValueIterator& operator++() { ++it; return *this; }
|
|
3129 |
ValueIt& operator++() { ++it; return *this; }
|
3127 |
3130 |
/// \e
|
3128 |
|
ValueIterator operator++(int) {
|
3129 |
|
ValueIterator tmp(*this);
|
|
3131 |
ValueIt operator++(int) {
|
|
3132 |
ValueIt tmp(*this);
|
3130 |
3133 |
operator++();
|
3131 |
3134 |
return tmp;
|
3132 |
3135 |
}
|
3133 |
3136 |
|
3134 |
3137 |
/// \e
|
3135 |
3138 |
const Value& operator*() const { return it->first; }
|
3136 |
3139 |
/// \e
|
3137 |
3140 |
const Value* operator->() const { return &(it->first); }
|
3138 |
3141 |
|
3139 |
3142 |
/// \e
|
3140 |
|
bool operator==(ValueIterator jt) const { return it == jt.it; }
|
|
3143 |
bool operator==(ValueIt jt) const { return it == jt.it; }
|
3141 |
3144 |
/// \e
|
3142 |
|
bool operator!=(ValueIterator jt) const { return it != jt.it; }
|
|
3145 |
bool operator!=(ValueIt jt) const { return it != jt.it; }
|
3143 |
3146 |
|
3144 |
3147 |
private:
|
3145 |
3148 |
typename std::map<Value, Key>::const_iterator it;
|
3146 |
3149 |
};
|
3147 |
3150 |
|
3148 |
3151 |
/// \brief Returns an iterator to the first value.
|
3149 |
3152 |
///
|
3150 |
3153 |
/// Returns an STL compatible iterator to the
|
3151 |
3154 |
/// first value of the map. The values of the
|
3152 |
3155 |
/// map can be accessed in the <tt>[beginValue, endValue)</tt>
|
3153 |
3156 |
/// range.
|
3154 |
|
ValueIterator beginValue() const {
|
3155 |
|
return ValueIterator(_first.begin());
|
|
3157 |
ValueIt beginValue() const {
|
|
3158 |
return ValueIt(_first.begin());
|
3156 |
3159 |
}
|
3157 |
3160 |
|
3158 |
3161 |
/// \brief Returns an iterator after the last value.
|
3159 |
3162 |
///
|
3160 |
3163 |
/// Returns an STL compatible iterator after the
|
3161 |
3164 |
/// last value of the map. The values of the
|
3162 |
3165 |
/// map can be accessed in the <tt>[beginValue, endValue)</tt>
|
3163 |
3166 |
/// range.
|
3164 |
|
ValueIterator endValue() const {
|
3165 |
|
return ValueIterator(_first.end());
|
|
3167 |
ValueIt endValue() const {
|
|
3168 |
return ValueIt(_first.end());
|
3166 |
3169 |
}
|
3167 |
3170 |
|
3168 |
3171 |
/// \brief Set operation of the map.
|
3169 |
3172 |
///
|
3170 |
3173 |
/// Set operation of the map.
|
3171 |
3174 |
void set(const Key& key, const Value& value) {
|
3172 |
3175 |
unlace(key);
|
3173 |
3176 |
Parent::operator[](key).value = value;
|
3174 |
3177 |
lace(key);
|
3175 |
3178 |
}
|
3176 |
3179 |
|
3177 |
3180 |
/// \brief Const subscript operator of the map.
|
3178 |
3181 |
///
|
3179 |
3182 |
/// Const subscript operator of the map.
|
3180 |
3183 |
const Value& operator[](const Key& key) const {
|
3181 |
3184 |
return Parent::operator[](key).value;
|
3182 |
3185 |
}
|
3183 |
3186 |
|
3184 |
3187 |
/// \brief Iterator for the keys with the same value.
|
3185 |
3188 |
///
|
3186 |
3189 |
/// Iterator for the keys with the same value. It works
|
3187 |
3190 |
/// like a graph item iterator, it can be converted to
|
3188 |
3191 |
/// the item type of the map, incremented with \c ++ operator, and
|
3189 |
3192 |
/// if the iterator leaves the last valid item, it will be equal to
|
... |
... |
@@ -3259,173 +3262,177 @@
|
3259 |
3262 |
for (typename Parent::ItemIt it(*this); it != INVALID; ++it) {
|
3260 |
3263 |
lace(it);
|
3261 |
3264 |
}
|
3262 |
3265 |
}
|
3263 |
3266 |
|
3264 |
3267 |
virtual void clear() {
|
3265 |
3268 |
_first.clear();
|
3266 |
3269 |
Parent::clear();
|
3267 |
3270 |
}
|
3268 |
3271 |
|
3269 |
3272 |
private:
|
3270 |
3273 |
std::map<Value, Key> _first;
|
3271 |
3274 |
};
|
3272 |
3275 |
|
3273 |
3276 |
/// \brief Map of the source nodes of arcs in a digraph.
|
3274 |
3277 |
///
|
3275 |
3278 |
/// SourceMap provides access for the source node of each arc in a digraph,
|
3276 |
3279 |
/// which is returned by the \c source() function of the digraph.
|
3277 |
3280 |
/// \tparam GR The digraph type.
|
3278 |
3281 |
/// \see TargetMap
|
3279 |
3282 |
template <typename GR>
|
3280 |
3283 |
class SourceMap {
|
3281 |
3284 |
public:
|
3282 |
3285 |
|
3283 |
|
///\e
|
|
3286 |
/// The key type (the \c Arc type of the digraph).
|
3284 |
3287 |
typedef typename GR::Arc Key;
|
3285 |
|
///\e
|
|
3288 |
/// The value type (the \c Node type of the digraph).
|
3286 |
3289 |
typedef typename GR::Node Value;
|
3287 |
3290 |
|
3288 |
3291 |
/// \brief Constructor
|
3289 |
3292 |
///
|
3290 |
3293 |
/// Constructor.
|
3291 |
3294 |
/// \param digraph The digraph that the map belongs to.
|
3292 |
3295 |
explicit SourceMap(const GR& digraph) : _graph(digraph) {}
|
3293 |
3296 |
|
3294 |
3297 |
/// \brief Returns the source node of the given arc.
|
3295 |
3298 |
///
|
3296 |
3299 |
/// Returns the source node of the given arc.
|
3297 |
3300 |
Value operator[](const Key& arc) const {
|
3298 |
3301 |
return _graph.source(arc);
|
3299 |
3302 |
}
|
3300 |
3303 |
|
3301 |
3304 |
private:
|
3302 |
3305 |
const GR& _graph;
|
3303 |
3306 |
};
|
3304 |
3307 |
|
3305 |
3308 |
/// \brief Returns a \c SourceMap class.
|
3306 |
3309 |
///
|
3307 |
3310 |
/// This function just returns an \c SourceMap class.
|
3308 |
3311 |
/// \relates SourceMap
|
3309 |
3312 |
template <typename GR>
|
3310 |
3313 |
inline SourceMap<GR> sourceMap(const GR& graph) {
|
3311 |
3314 |
return SourceMap<GR>(graph);
|
3312 |
3315 |
}
|
3313 |
3316 |
|
3314 |
3317 |
/// \brief Map of the target nodes of arcs in a digraph.
|
3315 |
3318 |
///
|
3316 |
3319 |
/// TargetMap provides access for the target node of each arc in a digraph,
|
3317 |
3320 |
/// which is returned by the \c target() function of the digraph.
|
3318 |
3321 |
/// \tparam GR The digraph type.
|
3319 |
3322 |
/// \see SourceMap
|
3320 |
3323 |
template <typename GR>
|
3321 |
3324 |
class TargetMap {
|
3322 |
3325 |
public:
|
3323 |
3326 |
|
3324 |
|
///\e
|
|
3327 |
/// The key type (the \c Arc type of the digraph).
|
3325 |
3328 |
typedef typename GR::Arc Key;
|
3326 |
|
///\e
|
|
3329 |
/// The value type (the \c Node type of the digraph).
|
3327 |
3330 |
typedef typename GR::Node Value;
|
3328 |
3331 |
|
3329 |
3332 |
/// \brief Constructor
|
3330 |
3333 |
///
|
3331 |
3334 |
/// Constructor.
|
3332 |
3335 |
/// \param digraph The digraph that the map belongs to.
|
3333 |
3336 |
explicit TargetMap(const GR& digraph) : _graph(digraph) {}
|
3334 |
3337 |
|
3335 |
3338 |
/// \brief Returns the target node of the given arc.
|
3336 |
3339 |
///
|
3337 |
3340 |
/// Returns the target node of the given arc.
|
3338 |
3341 |
Value operator[](const Key& e) const {
|
3339 |
3342 |
return _graph.target(e);
|
3340 |
3343 |
}
|
3341 |
3344 |
|
3342 |
3345 |
private:
|
3343 |
3346 |
const GR& _graph;
|
3344 |
3347 |
};
|
3345 |
3348 |
|
3346 |
3349 |
/// \brief Returns a \c TargetMap class.
|
3347 |
3350 |
///
|
3348 |
3351 |
/// This function just returns a \c TargetMap class.
|
3349 |
3352 |
/// \relates TargetMap
|
3350 |
3353 |
template <typename GR>
|
3351 |
3354 |
inline TargetMap<GR> targetMap(const GR& graph) {
|
3352 |
3355 |
return TargetMap<GR>(graph);
|
3353 |
3356 |
}
|
3354 |
3357 |
|
3355 |
3358 |
/// \brief Map of the "forward" directed arc view of edges in a graph.
|
3356 |
3359 |
///
|
3357 |
3360 |
/// ForwardMap provides access for the "forward" directed arc view of
|
3358 |
3361 |
/// each edge in a graph, which is returned by the \c direct() function
|
3359 |
3362 |
/// of the graph with \c true parameter.
|
3360 |
3363 |
/// \tparam GR The graph type.
|
3361 |
3364 |
/// \see BackwardMap
|
3362 |
3365 |
template <typename GR>
|
3363 |
3366 |
class ForwardMap {
|
3364 |
3367 |
public:
|
3365 |
3368 |
|
|
3369 |
/// The key type (the \c Edge type of the digraph).
|
|
3370 |
typedef typename GR::Edge Key;
|
|
3371 |
/// The value type (the \c Arc type of the digraph).
|
3366 |
3372 |
typedef typename GR::Arc Value;
|
3367 |
|
typedef typename GR::Edge Key;
|
3368 |
3373 |
|
3369 |
3374 |
/// \brief Constructor
|
3370 |
3375 |
///
|
3371 |
3376 |
/// Constructor.
|
3372 |
3377 |
/// \param graph The graph that the map belongs to.
|
3373 |
3378 |
explicit ForwardMap(const GR& graph) : _graph(graph) {}
|
3374 |
3379 |
|
3375 |
3380 |
/// \brief Returns the "forward" directed arc view of the given edge.
|
3376 |
3381 |
///
|
3377 |
3382 |
/// Returns the "forward" directed arc view of the given edge.
|
3378 |
3383 |
Value operator[](const Key& key) const {
|
3379 |
3384 |
return _graph.direct(key, true);
|
3380 |
3385 |
}
|
3381 |
3386 |
|
3382 |
3387 |
private:
|
3383 |
3388 |
const GR& _graph;
|
3384 |
3389 |
};
|
3385 |
3390 |
|
3386 |
3391 |
/// \brief Returns a \c ForwardMap class.
|
3387 |
3392 |
///
|
3388 |
3393 |
/// This function just returns an \c ForwardMap class.
|
3389 |
3394 |
/// \relates ForwardMap
|
3390 |
3395 |
template <typename GR>
|
3391 |
3396 |
inline ForwardMap<GR> forwardMap(const GR& graph) {
|
3392 |
3397 |
return ForwardMap<GR>(graph);
|
3393 |
3398 |
}
|
3394 |
3399 |
|
3395 |
3400 |
/// \brief Map of the "backward" directed arc view of edges in a graph.
|
3396 |
3401 |
///
|
3397 |
3402 |
/// BackwardMap provides access for the "backward" directed arc view of
|
3398 |
3403 |
/// each edge in a graph, which is returned by the \c direct() function
|
3399 |
3404 |
/// of the graph with \c false parameter.
|
3400 |
3405 |
/// \tparam GR The graph type.
|
3401 |
3406 |
/// \see ForwardMap
|
3402 |
3407 |
template <typename GR>
|
3403 |
3408 |
class BackwardMap {
|
3404 |
3409 |
public:
|
3405 |
3410 |
|
|
3411 |
/// The key type (the \c Edge type of the digraph).
|
|
3412 |
typedef typename GR::Edge Key;
|
|
3413 |
/// The value type (the \c Arc type of the digraph).
|
3406 |
3414 |
typedef typename GR::Arc Value;
|
3407 |
|
typedef typename GR::Edge Key;
|
3408 |
3415 |
|
3409 |
3416 |
/// \brief Constructor
|
3410 |
3417 |
///
|
3411 |
3418 |
/// Constructor.
|
3412 |
3419 |
/// \param graph The graph that the map belongs to.
|
3413 |
3420 |
explicit BackwardMap(const GR& graph) : _graph(graph) {}
|
3414 |
3421 |
|
3415 |
3422 |
/// \brief Returns the "backward" directed arc view of the given edge.
|
3416 |
3423 |
///
|
3417 |
3424 |
/// Returns the "backward" directed arc view of the given edge.
|
3418 |
3425 |
Value operator[](const Key& key) const {
|
3419 |
3426 |
return _graph.direct(key, false);
|
3420 |
3427 |
}
|
3421 |
3428 |
|
3422 |
3429 |
private:
|
3423 |
3430 |
const GR& _graph;
|
3424 |
3431 |
};
|
3425 |
3432 |
|
3426 |
3433 |
/// \brief Returns a \c BackwardMap class
|
3427 |
3434 |
|
3428 |
3435 |
/// This function just returns a \c BackwardMap class.
|
3429 |
3436 |
/// \relates BackwardMap
|
3430 |
3437 |
template <typename GR>
|
3431 |
3438 |
inline BackwardMap<GR> backwardMap(const GR& graph) {
|