Changes in / [692:33f417de9e70:691:9e54e3b27db0] in lemon-main
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/Makefile.am
r686 r681 93 93 lemon/lp_base.h \ 94 94 lemon/lp_skeleton.h \ 95 lemon/list_graph.h \ 95 96 lemon/maps.h \ 96 97 lemon/matching.h \ -
lemon/bits/edge_set_extender.h
r685 r617 538 538 539 539 public: 540 explicitArcMap(const Graph& _g)540 ArcMap(const Graph& _g) 541 541 : Parent(_g) {} 542 542 ArcMap(const Graph& _g, const _Value& _v) … … 562 562 563 563 public: 564 explicitEdgeMap(const Graph& _g)564 EdgeMap(const Graph& _g) 565 565 : Parent(_g) {} 566 566 -
lemon/bits/graph_extender.h
r685 r617 605 605 606 606 public: 607 explicitNodeMap(const Graph& graph)607 NodeMap(const Graph& graph) 608 608 : Parent(graph) {} 609 609 NodeMap(const Graph& graph, const _Value& value) … … 629 629 630 630 public: 631 explicitArcMap(const Graph& graph)631 ArcMap(const Graph& graph) 632 632 : Parent(graph) {} 633 633 ArcMap(const Graph& graph, const _Value& value) … … 653 653 654 654 public: 655 explicitEdgeMap(const Graph& graph)655 EdgeMap(const Graph& graph) 656 656 : Parent(graph) {} 657 657 -
lemon/circulation.h
r689 r641 451 451 } 452 452 453 /// \brief Sets the tolerance used by the algorithm. 454 /// 455 /// Sets the tolerance object used by the algorithm. 456 /// \return <tt>(*this)</tt> 457 Circulation& tolerance(const Tolerance& tolerance) { 453 /// \brief Sets the tolerance used by algorithm. 454 /// 455 /// Sets the tolerance used by algorithm. 456 Circulation& tolerance(const Tolerance& tolerance) const { 458 457 _tol = tolerance; 459 458 return *this; … … 462 461 /// \brief Returns a const reference to the tolerance. 463 462 /// 464 /// Returns a const reference to the tolerance object used by 465 /// the algorithm. 463 /// Returns a const reference to the tolerance. 466 464 const Tolerance& tolerance() const { 467 return _tol;465 return tolerance; 468 466 } 469 467 -
lemon/maps.h
r684 r617 1903 1903 1904 1904 /// 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 /// 1907 1909 /// The values of the map can be accessed 1908 1910 /// with stl compatible forward iterator. 1909 ///1910 /// This type is not reference map, so it cannot be modified with1911 /// the subscript operator.1912 1911 /// 1913 1912 /// \tparam GR The graph type. … … 1925 1924 template Map<V>::Type Map; 1926 1925 1927 typedef std::m ultimap<V, K> Container;1926 typedef std::map<V, K> Container; 1928 1927 Container _inv_map; 1929 1928 … … 1950 1949 /// iterator on the values of the map. The values can 1951 1950 /// be accessed in the <tt>[beginValue, endValue)</tt> range. 1952 /// They are considered with multiplicity, so each value is1953 /// traversed for each item it is assigned to.1954 1951 class ValueIterator 1955 1952 : public std::iterator<std::forward_iterator_tag, Value> { … … 2004 2001 void set(const Key& key, const Value& val) { 2005 2002 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); 2013 2006 } 2014 _inv_map.insert( std::make_pair(val, key));2007 _inv_map.insert(make_pair(val, key)); 2015 2008 Map::set(key, val); 2016 2009 } … … 2024 2017 } 2025 2018 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); 2034 2024 return it != _inv_map.end() ? it->second : INVALID; 2035 2025 } … … 2043 2033 virtual void erase(const Key& key) { 2044 2034 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); 2052 2038 } 2053 2039 Map::erase(key); … … 2061 2047 for (int i = 0; i < int(keys.size()); ++i) { 2062 2048 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); 2070 2052 } 2071 2053 } … … 2103 2085 /// \brief Subscript operator. 2104 2086 /// 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. 2108 2089 Value operator[](const Key& key) const { 2109 2090 return _inverted(key); -
lemon/preflow.h
r689 r641 98 98 /// "flow of maximum value" in a digraph. 99 99 /// The preflow algorithms are the fastest known maximum 100 /// flow algorithms. The current implementation use sa mixture of the100 /// flow algorithms. The current implementation use a mixture of the 101 101 /// \e "highest label" and the \e "bound decrease" heuristics. 102 102 /// The worst case time complexity of the algorithm is \f$O(n^2\sqrt{e})\f$. … … 372 372 } 373 373 374 /// \brief Sets the tolerance used by the algorithm. 375 /// 376 /// Sets the tolerance object used by the algorithm. 377 /// \return <tt>(*this)</tt> 378 Preflow& tolerance(const Tolerance& tolerance) { 374 /// \brief Sets the tolerance used by algorithm. 375 /// 376 /// Sets the tolerance used by algorithm. 377 Preflow& tolerance(const Tolerance& tolerance) const { 379 378 _tolerance = tolerance; 380 379 return *this; … … 383 382 /// \brief Returns a const reference to the tolerance. 384 383 /// 385 /// Returns a const reference to the tolerance object used by 386 /// the algorithm. 384 /// Returns a const reference to the tolerance. 387 385 const Tolerance& tolerance() const { 388 return _tolerance;386 return tolerance; 389 387 } 390 388 -
test/circulation_test.cc
r689 r611 88 88 .supplyMap(supply) 89 89 .flowMap(flow); 90 91 const CirculationType::Elevator& elev = const_circ_test.elevator();92 circ_test.elevator(const_cast<CirculationType::Elevator&>(elev));93 CirculationType::Tolerance tol = const_circ_test.tolerance();94 circ_test.tolerance(tol);95 90 96 91 circ_test.init(); -
test/maps_test.cc
r684 r477 23 23 #include <lemon/concepts/maps.h> 24 24 #include <lemon/maps.h> 25 #include <lemon/list_graph.h>26 25 27 26 #include "test_tools.h" … … 350 349 check(v1[i++] == *it, "Something is wrong with LoggerBoolMap"); 351 350 } 352 353 // CrossRefMap354 {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 }386 351 387 352 return 0; -
test/preflow_test.cc
r689 r585 95 95 PreflowType preflow_test(g, cap, n, n); 96 96 const PreflowType& const_preflow_test = preflow_test; 97 98 const PreflowType::Elevator& elev = const_preflow_test.elevator();99 preflow_test.elevator(const_cast<PreflowType::Elevator&>(elev));100 PreflowType::Tolerance tol = const_preflow_test.tolerance();101 preflow_test.tolerance(tol);102 97 103 98 preflow_test
Note: See TracChangeset
for help on using the changeset viewer.