COIN-OR::LEMON - Graph Library

Changes in / [690:5795e130402e:689:86c49553fea5] in lemon-1.2


Ignore:
Files:
3 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • lemon/Makefile.am

    r686 r667  
    6060        lemon/bfs.h \
    6161        lemon/bin_heap.h \
    62         lemon/bucket_heap.h \
    6362        lemon/cbc.h \
    6463        lemon/circulation.h \
     
    7877        lemon/error.h \
    7978        lemon/euler.h \
    80         lemon/fib_heap.h \
    8179        lemon/full_graph.h \
    8280        lemon/glpk.h \
     
    9391        lemon/lp_base.h \
    9492        lemon/lp_skeleton.h \
     93        lemon/list_graph.h \
    9594        lemon/maps.h \
    9695        lemon/matching.h \
     
    101100        lemon/path.h \
    102101        lemon/preflow.h \
    103         lemon/radix_heap.h \
    104102        lemon/radix_sort.h \
    105103        lemon/random.h \
  • lemon/bin_heap.h

    r683 r584  
    3434  ///\brief A Binary Heap implementation.
    3535  ///
    36   ///This class implements the \e binary \e heap data structure.
    37   ///
     36  ///This class implements the \e binary \e heap data structure. 
     37  /// 
    3838  ///A \e heap is a data structure for storing items with specified values
    3939  ///called \e priorities in such a way that finding the item with minimum
    40   ///priority is efficient. \c CMP specifies the ordering of the priorities.
     40  ///priority is efficient. \c Comp specifies the ordering of the priorities.
    4141  ///In a heap one can change the priority of an item, add or erase an
    4242  ///item, etc.
     
    4545  ///\tparam IM A read and writable item map with int values, used internally
    4646  ///to handle the cross references.
    47   ///\tparam CMP A functor class for the ordering of the priorities.
     47  ///\tparam Comp A functor class for the ordering of the priorities.
    4848  ///The default is \c std::less<PR>.
    4949  ///
    5050  ///\sa FibHeap
    5151  ///\sa Dijkstra
    52   template <typename PR, typename IM, typename CMP = std::less<PR> >
     52  template <typename PR, typename IM, typename Comp = std::less<PR> >
    5353  class BinHeap {
    5454
     
    6363    typedef std::pair<Item,Prio> Pair;
    6464    ///\e
    65     typedef CMP Compare;
     65    typedef Comp Compare;
    6666
    6767    /// \brief Type to represent the items states.
  • lemon/bits/edge_set_extender.h

    r685 r617  
    538538
    539539    public:
    540       explicit ArcMap(const Graph& _g)
     540      ArcMap(const Graph& _g)
    541541        : Parent(_g) {}
    542542      ArcMap(const Graph& _g, const _Value& _v)
     
    562562
    563563    public:
    564       explicit EdgeMap(const Graph& _g)
     564      EdgeMap(const Graph& _g)
    565565        : Parent(_g) {}
    566566
  • lemon/bits/graph_extender.h

    r685 r617  
    605605
    606606    public:
    607       explicit NodeMap(const Graph& graph)
     607      NodeMap(const Graph& graph)
    608608        : Parent(graph) {}
    609609      NodeMap(const Graph& graph, const _Value& value)
     
    629629
    630630    public:
    631       explicit ArcMap(const Graph& graph)
     631      ArcMap(const Graph& graph)
    632632        : Parent(graph) {}
    633633      ArcMap(const Graph& graph, const _Value& value)
     
    653653
    654654    public:
    655       explicit EdgeMap(const Graph& graph)
     655      EdgeMap(const Graph& graph)
    656656        : Parent(graph) {}
    657657
  • lemon/maps.h

    r684 r617  
    19031903
    19041904  /// This class provides simple invertable graph maps.
    1905   /// It wraps a standard graph map (\c NodeMap, \c ArcMap or \c EdgeMap)
    1906   /// and if a key is set to a new value, then stores it in the inverse map.
     1905  /// It wraps an arbitrary \ref concepts::ReadWriteMap "ReadWriteMap"
     1906  /// and if a key is set to a new value then store it
     1907  /// in the inverse map.
     1908  ///
    19071909  /// The values of the map can be accessed
    19081910  /// with stl compatible forward iterator.
    1909   ///
    1910   /// This type is not reference map, so it cannot be modified with
    1911   /// the subscript operator.
    19121911  ///
    19131912  /// \tparam GR The graph type.
     
    19251924      template Map<V>::Type Map;
    19261925
    1927     typedef std::multimap<V, K> Container;
     1926    typedef std::map<V, K> Container;
    19281927    Container _inv_map;
    19291928
     
    19501949    /// iterator on the values of the map. The values can
    19511950    /// be accessed in the <tt>[beginValue, endValue)</tt> range.
    1952     /// They are considered with multiplicity, so each value is
    1953     /// traversed for each item it is assigned to.
    19541951    class ValueIterator
    19551952      : public std::iterator<std::forward_iterator_tag, Value> {
     
    20042001    void set(const Key& key, const Value& val) {
    20052002      Value oldval = Map::operator[](key);
    2006       typename Container::iterator it;
    2007       for (it = _inv_map.equal_range(oldval).first;
    2008            it != _inv_map.equal_range(oldval).second; ++it) {
    2009         if (it->second == key) {
    2010           _inv_map.erase(it);
    2011           break;
    2012         }
     2003      typename Container::iterator it = _inv_map.find(oldval);
     2004      if (it != _inv_map.end() && it->second == key) {
     2005        _inv_map.erase(it);
    20132006      }
    2014       _inv_map.insert(std::make_pair(val, key));
     2007      _inv_map.insert(make_pair(val, key));
    20152008      Map::set(key, val);
    20162009    }
     
    20242017    }
    20252018
    2026     /// \brief Gives back an item by its value.
    2027     ///
    2028     /// This function gives back an item that is assigned to
    2029     /// the given value or \c INVALID if no such item exists.
    2030     /// If there are more items with the same associated value,
    2031     /// only one of them is returned.
    2032     Key operator()(const Value& val) const {
    2033       typename Container::const_iterator it = _inv_map.find(val);
     2019    /// \brief Gives back the item by its value.
     2020    ///
     2021    /// Gives back the item by its value.
     2022    Key operator()(const Value& key) const {
     2023      typename Container::const_iterator it = _inv_map.find(key);
    20342024      return it != _inv_map.end() ? it->second : INVALID;
    20352025    }
     
    20432033    virtual void erase(const Key& key) {
    20442034      Value val = Map::operator[](key);
    2045       typename Container::iterator it;
    2046       for (it = _inv_map.equal_range(val).first;
    2047            it != _inv_map.equal_range(val).second; ++it) {
    2048         if (it->second == key) {
    2049           _inv_map.erase(it);
    2050           break;
    2051         }
     2035      typename Container::iterator it = _inv_map.find(val);
     2036      if (it != _inv_map.end() && it->second == key) {
     2037        _inv_map.erase(it);
    20522038      }
    20532039      Map::erase(key);
     
    20612047      for (int i = 0; i < int(keys.size()); ++i) {
    20622048        Value val = Map::operator[](keys[i]);
    2063         typename Container::iterator it;
    2064         for (it = _inv_map.equal_range(val).first;
    2065              it != _inv_map.equal_range(val).second; ++it) {
    2066           if (it->second == keys[i]) {
    2067             _inv_map.erase(it);
    2068             break;
    2069           }
     2049        typename Container::iterator it = _inv_map.find(val);
     2050        if (it != _inv_map.end() && it->second == keys[i]) {
     2051          _inv_map.erase(it);
    20702052        }
    20712053      }
     
    21032085      /// \brief Subscript operator.
    21042086      ///
    2105       /// Subscript operator. It gives back an item
    2106       /// that is assigned to the given value or \c INVALID
    2107       /// if no such item exists.
     2087      /// Subscript operator. It gives back the item
     2088      /// that was last assigned to the given value.
    21082089      Value operator[](const Key& key) const {
    21092090        return _inverted(key);
  • test/heap_test.cc

    r681 r440  
    3232
    3333#include <lemon/bin_heap.h>
    34 #include <lemon/fib_heap.h>
    35 #include <lemon/radix_heap.h>
    36 #include <lemon/bucket_heap.h>
    3734
    3835#include "test_tools.h"
     
    187184  }
    188185
    189   {
    190     typedef FibHeap<Prio, ItemIntMap> IntHeap;
    191     checkConcept<Heap<Prio, ItemIntMap>, IntHeap>();
    192     heapSortTest<IntHeap>();
    193     heapIncreaseTest<IntHeap>();
    194 
    195     typedef FibHeap<Prio, IntNodeMap > NodeHeap;
    196     checkConcept<Heap<Prio, IntNodeMap >, NodeHeap>();
    197     dijkstraHeapTest<NodeHeap>(digraph, length, source);
    198   }
    199 
    200   {
    201     typedef RadixHeap<ItemIntMap> IntHeap;
    202     checkConcept<Heap<Prio, ItemIntMap>, IntHeap>();
    203     heapSortTest<IntHeap>();
    204     heapIncreaseTest<IntHeap>();
    205 
    206     typedef RadixHeap<IntNodeMap > NodeHeap;
    207     checkConcept<Heap<Prio, IntNodeMap >, NodeHeap>();
    208     dijkstraHeapTest<NodeHeap>(digraph, length, source);
    209   }
    210 
    211   {
    212     typedef BucketHeap<ItemIntMap> IntHeap;
    213     checkConcept<Heap<Prio, ItemIntMap>, IntHeap>();
    214     heapSortTest<IntHeap>();
    215     heapIncreaseTest<IntHeap>();
    216 
    217     typedef BucketHeap<IntNodeMap > NodeHeap;
    218     checkConcept<Heap<Prio, IntNodeMap >, NodeHeap>();
    219     dijkstraHeapTest<NodeHeap>(digraph, length, source);
    220   }
    221 
    222 
    223186  return 0;
    224187}
  • test/maps_test.cc

    r684 r507  
    2323#include <lemon/concepts/maps.h>
    2424#include <lemon/maps.h>
    25 #include <lemon/list_graph.h>
    2625
    2726#include "test_tools.h"
     
    350349      check(v1[i++] == *it, "Something is wrong with LoggerBoolMap");
    351350  }
    352  
    353   // CrossRefMap
    354   {
    355     typedef ListDigraph Graph;
    356     DIGRAPH_TYPEDEFS(Graph);
    357 
    358     checkConcept<ReadWriteMap<Node, int>,
    359                  CrossRefMap<Graph, Node, int> >();
    360    
    361     Graph gr;
    362     typedef CrossRefMap<Graph, Node, char> CRMap;
    363     typedef CRMap::ValueIterator ValueIt;
    364     CRMap map(gr);
    365    
    366     Node n0 = gr.addNode();
    367     Node n1 = gr.addNode();
    368     Node n2 = gr.addNode();
    369    
    370     map.set(n0, 'A');
    371     map.set(n1, 'B');
    372     map.set(n2, 'C');
    373     map.set(n2, 'A');
    374     map.set(n0, 'C');
    375 
    376     check(map[n0] == 'C' && map[n1] == 'B' && map[n2] == 'A',
    377           "Wrong CrossRefMap");
    378     check(map('A') == n2 && map.inverse()['A'] == n2, "Wrong CrossRefMap");
    379     check(map('B') == n1 && map.inverse()['B'] == n1, "Wrong CrossRefMap");
    380     check(map('C') == n0 && map.inverse()['C'] == n0, "Wrong CrossRefMap");
    381 
    382     ValueIt it = map.beginValue();
    383     check(*it++ == 'A' && *it++ == 'B' && *it++ == 'C' &&
    384           it == map.endValue(), "Wrong value iterator");
    385   }
    386351
    387352  return 0;
Note: See TracChangeset for help on using the changeset viewer.