Changeset 1159:7fdaa05a69a1 in lemon
- Timestamp:
- 09/13/12 11:56:19 (12 years ago)
- Branch:
- default
- Children:
- 1160:00f8d9f9920d, 1401:cd72eae05bdf
- Parents:
- 1153:4bb9e72e1a41 (diff), 1157:761fe0846f49 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Phase:
- public
- Files:
-
- 54 edited
Legend:
- Unmodified
- Added
- Removed
-
CMakeLists.txt
r1107 r1159 67 67 # C4996: 'function': was declared deprecated 68 68 ELSE() 69 SET(CXX_WARNING "-Wall -W")69 SET(CXX_WARNING "-Wall") 70 70 ENDIF() 71 71 ENDIF() … … 74 74 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LEMON_CXX_WARNING_FLAGS}") 75 75 76 SET( CMAKE_CXX_FLAGS_MAINTAINER "-Werror -ggdb " CACHE STRING76 SET( CMAKE_CXX_FLAGS_MAINTAINER "-Werror -ggdb -O0" CACHE STRING 77 77 "Flags used by the C++ compiler during maintainer builds." 78 78 FORCE ) 79 SET( CMAKE_C_FLAGS_MAINTAINER "-Werror " CACHE STRING79 SET( CMAKE_C_FLAGS_MAINTAINER "-Werror -O0" CACHE STRING 80 80 "Flags used by the C compiler during maintainer builds." 81 81 FORCE ) -
CMakeLists.txt
r1125 r1159 115 115 SET(LEMON_HAVE_LONG_LONG ${HAVE_LONG_LONG}) 116 116 117 INCLUDE(FindPythonInterp) 118 117 119 ENABLE_TESTING() 118 120 -
lemon/adaptors.h
r956 r1159 1372 1372 /// and edge filter maps. 1373 1373 SubGraph(GR& graph, NF& node_filter, EF& edge_filter) { 1374 initialize(graph, node_filter, edge_filter);1374 this->initialize(graph, node_filter, edge_filter); 1375 1375 } 1376 1376 … … 2278 2278 /// Creates an undirected graph from the given digraph. 2279 2279 Undirector(DGR& digraph) { 2280 initialize(digraph);2280 this->initialize(digraph); 2281 2281 } 2282 2282 -
lemon/adaptors.h
r1157 r1159 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-20 095 * Copyright (C) 2003-2010 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 361 361 /// parameter is set to be \c const. 362 362 /// 363 /// This class provides item counting in the same time as the adapted 364 /// digraph structure. 365 /// 363 366 /// \tparam DGR The type of the adapted digraph. 364 367 /// It must conform to the \ref concepts::Digraph "Digraph" concept. … … 419 422 Parent::initialize(digraph); 420 423 _node_filter = &node_filter; 421 _arc_filter = &arc_filter; 424 _arc_filter = &arc_filter; 422 425 } 423 426 … … 506 509 507 510 template <typename V> 508 class NodeMap 509 : public SubMapExtender<SubDigraphBase<DGR, NF, AF, ch>, 510 511 class NodeMap 512 : public SubMapExtender<SubDigraphBase<DGR, NF, AF, ch>, 513 LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, NodeMap<V>)> { 511 514 typedef SubMapExtender<SubDigraphBase<DGR, NF, AF, ch>, 512 515 LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, NodeMap<V>)> Parent; 513 516 514 517 public: … … 533 536 534 537 template <typename V> 535 class ArcMap 538 class ArcMap 536 539 : public SubMapExtender<SubDigraphBase<DGR, NF, AF, ch>, 537 540 LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, ArcMap<V>)> { 538 541 typedef SubMapExtender<SubDigraphBase<DGR, NF, AF, ch>, 539 542 LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, ArcMap<V>)> Parent; … … 580 583 Parent::initialize(digraph); 581 584 _node_filter = &node_filter; 582 _arc_filter = &arc_filter; 585 _arc_filter = &arc_filter; 583 586 } 584 587 … … 649 652 650 653 template <typename V> 651 class NodeMap 654 class NodeMap 652 655 : public SubMapExtender<SubDigraphBase<DGR, NF, AF, false>, 653 656 LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, NodeMap<V>)> { 654 typedef SubMapExtender<SubDigraphBase<DGR, NF, AF, false>, 657 typedef SubMapExtender<SubDigraphBase<DGR, NF, AF, false>, 655 658 LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, NodeMap<V>)> Parent; 656 659 … … 676 679 677 680 template <typename V> 678 class ArcMap 681 class ArcMap 679 682 : public SubMapExtender<SubDigraphBase<DGR, NF, AF, false>, 680 683 LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, ArcMap<V>)> { … … 719 722 /// by adding or removing nodes or arcs, unless the \c GR template 720 723 /// parameter is set to be \c const. 724 /// 725 /// This class provides only linear time counting for nodes and arcs. 721 726 /// 722 727 /// \tparam DGR The type of the adapted digraph. … … 1017 1022 1018 1023 template <typename V> 1019 class NodeMap 1024 class NodeMap 1020 1025 : public SubMapExtender<SubGraphBase<GR, NF, EF, ch>, 1021 1026 LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, NodeMap<V>)> { 1022 typedef SubMapExtender<SubGraphBase<GR, NF, EF, ch>, 1027 typedef SubMapExtender<SubGraphBase<GR, NF, EF, ch>, 1023 1028 LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, NodeMap<V>)> Parent; 1024 1029 … … 1044 1049 1045 1050 template <typename V> 1046 class ArcMap 1051 class ArcMap 1047 1052 : public SubMapExtender<SubGraphBase<GR, NF, EF, ch>, 1048 1053 LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, ArcMap<V>)> { 1049 typedef SubMapExtender<SubGraphBase<GR, NF, EF, ch>, 1054 typedef SubMapExtender<SubGraphBase<GR, NF, EF, ch>, 1050 1055 LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, ArcMap<V>)> Parent; 1051 1056 … … 1071 1076 1072 1077 template <typename V> 1073 class EdgeMap 1078 class EdgeMap 1074 1079 : public SubMapExtender<SubGraphBase<GR, NF, EF, ch>, 1075 1080 LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, EdgeMap<V>)> { 1076 typedef SubMapExtender<SubGraphBase<GR, NF, EF, ch>, 1081 typedef SubMapExtender<SubGraphBase<GR, NF, EF, ch>, 1077 1082 LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, EdgeMap<V>)> Parent; 1078 1083 … … 1113 1118 NF* _node_filter; 1114 1119 EF* _edge_filter; 1115 SubGraphBase() 1116 1120 SubGraphBase() 1121 : Parent(), _node_filter(0), _edge_filter(0) { } 1117 1122 1118 1123 void initialize(GR& graph, NF& node_filter, EF& edge_filter) { … … 1215 1220 1216 1221 template <typename V> 1217 class NodeMap 1222 class NodeMap 1218 1223 : public SubMapExtender<SubGraphBase<GR, NF, EF, false>, 1219 1224 LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, NodeMap<V>)> { 1220 typedef SubMapExtender<SubGraphBase<GR, NF, EF, false>, 1225 typedef SubMapExtender<SubGraphBase<GR, NF, EF, false>, 1221 1226 LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, NodeMap<V>)> Parent; 1222 1227 … … 1242 1247 1243 1248 template <typename V> 1244 class ArcMap 1249 class ArcMap 1245 1250 : public SubMapExtender<SubGraphBase<GR, NF, EF, false>, 1246 1251 LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, ArcMap<V>)> { 1247 typedef SubMapExtender<SubGraphBase<GR, NF, EF, false>, 1252 typedef SubMapExtender<SubGraphBase<GR, NF, EF, false>, 1248 1253 LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, ArcMap<V>)> Parent; 1249 1254 … … 1269 1274 1270 1275 template <typename V> 1271 class EdgeMap 1276 class EdgeMap 1272 1277 : public SubMapExtender<SubGraphBase<GR, NF, EF, false>, 1273 1278 LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, EdgeMap<V>)> { 1274 typedef SubMapExtender<SubGraphBase<GR, NF, EF, false>, 1275 1279 typedef SubMapExtender<SubGraphBase<GR, NF, EF, false>, 1280 LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, EdgeMap<V>)> Parent; 1276 1281 1277 1282 public: … … 1314 1319 /// by adding or removing nodes or edges, unless the \c GR template 1315 1320 /// parameter is set to be \c const. 1321 /// 1322 /// This class provides only linear time counting for nodes, edges and arcs. 1316 1323 /// 1317 1324 /// \tparam GR The type of the adapted graph. … … 1471 1478 /// by adding or removing nodes or arcs/edges, unless the \c GR template 1472 1479 /// parameter is set to be \c const. 1480 /// 1481 /// This class provides only linear time item counting. 1473 1482 /// 1474 1483 /// \tparam GR The type of the adapted digraph or graph. … … 1496 1505 #endif 1497 1506 typedef DigraphAdaptorExtender< 1498 SubDigraphBase<GR, NF, ConstMap<typename GR::Arc, Const<bool, true> >, 1507 SubDigraphBase<GR, NF, ConstMap<typename GR::Arc, Const<bool, true> >, 1499 1508 true> > Parent; 1500 1509 … … 1517 1526 /// Creates a subgraph for the given digraph or graph with the 1518 1527 /// given node filter map. 1519 FilterNodes(GR& graph, NF& node_filter) 1528 FilterNodes(GR& graph, NF& node_filter) 1520 1529 : Parent(), const_true_map() 1521 1530 { … … 1555 1564 typename enable_if<UndirectedTagIndicator<GR> >::type> : 1556 1565 public GraphAdaptorExtender< 1557 SubGraphBase<GR, NF, ConstMap<typename GR::Edge, Const<bool, true> >, 1566 SubGraphBase<GR, NF, ConstMap<typename GR::Edge, Const<bool, true> >, 1558 1567 true> > { 1559 1568 1560 1569 typedef GraphAdaptorExtender< 1561 SubGraphBase<GR, NF, ConstMap<typename GR::Edge, Const<bool, true> >, 1570 SubGraphBase<GR, NF, ConstMap<typename GR::Edge, Const<bool, true> >, 1562 1571 true> > Parent; 1563 1572 … … 1619 1628 /// by adding or removing nodes or arcs, unless the \c GR template 1620 1629 /// parameter is set to be \c const. 1630 /// 1631 /// This class provides only linear time counting for nodes and arcs. 1621 1632 /// 1622 1633 /// \tparam DGR The type of the adapted digraph. … … 1643 1654 #endif 1644 1655 typedef DigraphAdaptorExtender< 1645 SubDigraphBase<DGR, ConstMap<typename DGR::Node, Const<bool, true> >, 1656 SubDigraphBase<DGR, ConstMap<typename DGR::Node, Const<bool, true> >, 1646 1657 AF, false> > Parent; 1647 1658 … … 1729 1740 /// by adding or removing nodes or edges, unless the \c GR template 1730 1741 /// parameter is set to be \c const. 1742 /// 1743 /// This class provides only linear time counting for nodes, edges and arcs. 1731 1744 /// 1732 1745 /// \tparam GR The type of the adapted graph. … … 1749 1762 class FilterEdges : 1750 1763 public GraphAdaptorExtender< 1751 SubGraphBase<GR, ConstMap<typename GR::Node, Const<bool, true> >, 1764 SubGraphBase<GR, ConstMap<typename GR::Node, Const<bool, true> >, 1752 1765 EF, false> > { 1753 1766 #endif 1754 1767 typedef GraphAdaptorExtender< 1755 SubGraphBase<GR, ConstMap<typename GR::Node, Const<bool, true > >, 1768 SubGraphBase<GR, ConstMap<typename GR::Node, Const<bool, true > >, 1756 1769 EF, false> > Parent; 1757 1770 … … 1778 1791 /// Creates a subgraph for the given graph with the given edge 1779 1792 /// filter map. 1780 FilterEdges(GR& graph, EF& edge_filter) 1793 FilterEdges(GR& graph, EF& edge_filter) 1781 1794 : Parent(), const_true_map() { 1782 1795 Parent::initialize(graph, const_true_map, edge_filter); … … 1846 1859 bool _forward; 1847 1860 1848 Arc(const Edge& edge, bool forward) 1861 Arc(const Edge& edge, bool forward) 1849 1862 : _edge(edge), _forward(forward) {} 1850 1863 … … 2086 2099 2087 2100 ArcMapBase(const UndirectorBase<DGR>& adaptor, const V& value) 2088 : _forward(*adaptor._digraph, value), 2101 : _forward(*adaptor._digraph, value), 2089 2102 _backward(*adaptor._digraph, value) {} 2090 2103 … … 2204 2217 typedef typename ItemSetTraits<DGR, Edge>::ItemNotifier EdgeNotifier; 2205 2218 EdgeNotifier& notifier(Edge) const { return _digraph->notifier(Edge()); } 2206 2219 2207 2220 typedef EdgeNotifier ArcNotifier; 2208 2221 ArcNotifier& notifier(Arc) const { return _digraph->notifier(Edge()); } … … 2232 2245 /// by adding or removing nodes or edges, unless the \c GR template 2233 2246 /// parameter is set to be \c const. 2247 /// 2248 /// This class provides item counting in the same time as the adapted 2249 /// digraph structure. 2234 2250 /// 2235 2251 /// \tparam DGR The type of the adapted digraph. … … 2535 2551 /// by adding or removing nodes or arcs, unless the \c GR template 2536 2552 /// parameter is set to be \c const. 2553 /// 2554 /// This class provides item counting in the same time as the adapted 2555 /// graph structure. 2537 2556 /// 2538 2557 /// \tparam GR The type of the adapted graph. … … 2679 2698 /// This class conforms to the \ref concepts::Digraph "Digraph" concept. 2680 2699 /// 2700 /// This class provides only linear time counting for nodes and arcs. 2701 /// 2681 2702 /// \tparam DGR The type of the adapted digraph. 2682 2703 /// It must conform to the \ref concepts::Digraph "Digraph" concept. … … 2708 2729 typename FM = CM, 2709 2730 typename TL = Tolerance<typename CM::Value> > 2710 class ResidualDigraph 2731 class ResidualDigraph 2711 2732 : public SubDigraph< 2712 2733 Undirector<const DGR>, … … 2765 2786 ResidualDigraph(const DGR& digraph, const CM& capacity, 2766 2787 FM& flow, const TL& tolerance = Tolerance()) 2767 : Parent(), _capacity(&capacity), _flow(&flow), 2788 : Parent(), _capacity(&capacity), _flow(&flow), 2768 2789 _graph(digraph), _node_filter(), 2769 2790 _forward_filter(capacity, flow, tolerance), … … 2847 2868 2848 2869 /// Constructor 2849 ResidualCapacity(const ResidualDigraph<DGR, CM, FM, TL>& adaptor) 2870 ResidualCapacity(const ResidualDigraph<DGR, CM, FM, TL>& adaptor) 2850 2871 : _adaptor(&adaptor) {} 2851 2872 … … 3326 3347 /// in the adaptor. 3327 3348 /// 3349 /// This class provides item counting in the same time as the adapted 3350 /// digraph structure. 3351 /// 3328 3352 /// \tparam DGR The type of the adapted digraph. 3329 3353 /// It must conform to the \ref concepts::Digraph "Digraph" concept. … … 3424 3448 /// to get a node map of the split digraph. 3425 3449 /// Its value type is inherited from the first node map type (\c IN). 3426 /// \tparam IN The type of the node map for the in-nodes. 3450 /// \tparam IN The type of the node map for the in-nodes. 3427 3451 /// \tparam OUT The type of the node map for the out-nodes. 3428 3452 template <typename IN, typename OUT> -
lemon/bfs.h
r956 r1127 1252 1252 } 1253 1253 _Visitor& visitor; 1254 Constraints() {} 1254 1255 }; 1255 1256 }; -
lemon/bfs.h
r1125 r1127 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-20 095 * Copyright (C) 2003-2010 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 48 48 ///The type of the map that stores the predecessor 49 49 ///arcs of the shortest paths. 50 ///It must meetthe \ref concepts::WriteMap "WriteMap" concept.50 ///It must conform to the \ref concepts::WriteMap "WriteMap" concept. 51 51 typedef typename Digraph::template NodeMap<typename Digraph::Arc> PredMap; 52 52 ///Instantiates a \c PredMap. … … 63 63 64 64 ///The type of the map that indicates which nodes are processed. 65 ///It must meet the \ref concepts::WriteMap "WriteMap" concept. 65 ///It must conform to the \ref concepts::WriteMap "WriteMap" concept. 66 ///By default, it is a NullMap. 66 67 typedef NullMap<typename Digraph::Node,bool> ProcessedMap; 67 68 ///Instantiates a \c ProcessedMap. … … 82 83 83 84 ///The type of the map that indicates which nodes are reached. 84 ///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept. 85 ///It must conform to 86 ///the \ref concepts::ReadWriteMap "ReadWriteMap" concept. 85 87 typedef typename Digraph::template NodeMap<bool> ReachedMap; 86 88 ///Instantiates a \c ReachedMap. … … 97 99 98 100 ///The type of the map that stores the distances of the nodes. 99 ///It must meetthe \ref concepts::WriteMap "WriteMap" concept.101 ///It must conform to the \ref concepts::WriteMap "WriteMap" concept. 100 102 typedef typename Digraph::template NodeMap<int> DistMap; 101 103 ///Instantiates a \c DistMap. … … 121 123 ///\tparam GR The type of the digraph the algorithm runs on. 122 124 ///The default type is \ref ListDigraph. 125 ///\tparam TR The traits class that defines various types used by the 126 ///algorithm. By default, it is \ref BfsDefaultTraits 127 ///"BfsDefaultTraits<GR>". 128 ///In most cases, this parameter should not be set directly, 129 ///consider to use the named template parameters instead. 123 130 #ifdef DOXYGEN 124 131 template <typename GR, … … 226 233 ///\ref named-templ-param "Named parameter" for setting 227 234 ///\c PredMap type. 228 ///It must meetthe \ref concepts::WriteMap "WriteMap" concept.235 ///It must conform to the \ref concepts::WriteMap "WriteMap" concept. 229 236 template <class T> 230 237 struct SetPredMap : public Bfs< Digraph, SetPredMapTraits<T> > { … … 246 253 ///\ref named-templ-param "Named parameter" for setting 247 254 ///\c DistMap type. 248 ///It must meetthe \ref concepts::WriteMap "WriteMap" concept.255 ///It must conform to the \ref concepts::WriteMap "WriteMap" concept. 249 256 template <class T> 250 257 struct SetDistMap : public Bfs< Digraph, SetDistMapTraits<T> > { … … 266 273 ///\ref named-templ-param "Named parameter" for setting 267 274 ///\c ReachedMap type. 268 ///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept. 275 ///It must conform to 276 ///the \ref concepts::ReadWriteMap "ReadWriteMap" concept. 269 277 template <class T> 270 278 struct SetReachedMap : public Bfs< Digraph, SetReachedMapTraits<T> > { … … 286 294 ///\ref named-templ-param "Named parameter" for setting 287 295 ///\c ProcessedMap type. 288 ///It must meetthe \ref concepts::WriteMap "WriteMap" concept.296 ///It must conform to the \ref concepts::WriteMap "WriteMap" concept. 289 297 template <class T> 290 298 struct SetProcessedMap : public Bfs< Digraph, SetProcessedMapTraits<T> > { … … 414 422 ///The simplest way to execute the BFS algorithm is to use one of the 415 423 ///member functions called \ref run(Node) "run()".\n 416 ///If you need more control on the execution, firstyou have to call417 ///\ref init() , then you can add several source nodes with424 ///If you need better control on the execution, you have to call 425 ///\ref init() first, then you can add several source nodes with 418 426 ///\ref addSource(). Finally the actual path computation can be 419 427 ///performed with one of the \ref start() functions. … … 701 709 ///Runs the algorithm to visit all nodes in the digraph. 702 710 703 ///This method runs the %BFS algorithm in order to 704 ///compute the shortest path to each node. 705 /// 706 ///The algorithm computes 707 ///- the shortest path tree (forest), 708 ///- the distance of each node from the root(s). 711 ///This method runs the %BFS algorithm in order to visit all nodes 712 ///in the digraph. 709 713 /// 710 714 ///\note <tt>b.run(s)</tt> is just a shortcut of the following code. … … 738 742 ///@{ 739 743 740 ///The shortest path to anode.741 742 ///Returns the shortest path to a node.744 ///The shortest path to the given node. 745 746 ///Returns the shortest path to the given node from the root(s). 743 747 /// 744 748 ///\warning \c t should be reached from the root(s). … … 748 752 Path path(Node t) const { return Path(*G, *_pred, t); } 749 753 750 ///The distance of anode from the root(s).751 752 ///Returns the distance of anode from the root(s).754 ///The distance of the given node from the root(s). 755 756 ///Returns the distance of the given node from the root(s). 753 757 /// 754 758 ///\warning If node \c v is not reached from the root(s), then … … 759 763 int dist(Node v) const { return (*_dist)[v]; } 760 764 761 ///Returns the 'previous arc' of the shortest path tree for a node. 762 765 ///\brief Returns the 'previous arc' of the shortest path tree for 766 ///the given node. 767 /// 763 768 ///This function returns the 'previous arc' of the shortest path 764 769 ///tree for the node \c v, i.e. it returns the last arc of a … … 767 772 /// 768 773 ///The shortest path tree used here is equal to the shortest path 769 ///tree used in \ref predNode() .774 ///tree used in \ref predNode() and \ref predMap(). 770 775 /// 771 776 ///\pre Either \ref run(Node) "run()" or \ref init() … … 773 778 Arc predArc(Node v) const { return (*_pred)[v];} 774 779 775 ///Returns the 'previous node' of the shortest path tree for a node. 776 780 ///\brief Returns the 'previous node' of the shortest path tree for 781 ///the given node. 782 /// 777 783 ///This function returns the 'previous node' of the shortest path 778 784 ///tree for the node \c v, i.e. it returns the last but one node 779 /// froma shortest path from a root to \c v. It is \c INVALID785 ///of a shortest path from a root to \c v. It is \c INVALID 780 786 ///if \c v is not reached from the root(s) or if \c v is a root. 781 787 /// 782 788 ///The shortest path tree used here is equal to the shortest path 783 ///tree used in \ref predArc() .789 ///tree used in \ref predArc() and \ref predMap(). 784 790 /// 785 791 ///\pre Either \ref run(Node) "run()" or \ref init() … … 802 808 /// 803 809 ///Returns a const reference to the node map that stores the predecessor 804 ///arcs, which form the shortest path tree .810 ///arcs, which form the shortest path tree (forest). 805 811 /// 806 812 ///\pre Either \ref run(Node) "run()" or \ref init() … … 808 814 const PredMap &predMap() const { return *_pred;} 809 815 810 ///Checks if anode is reached from the root(s).816 ///Checks if the given node is reached from the root(s). 811 817 812 818 ///Returns \c true if \c v is reached from the root(s). … … 834 840 ///The type of the map that stores the predecessor 835 841 ///arcs of the shortest paths. 836 ///It must meetthe \ref concepts::WriteMap "WriteMap" concept.842 ///It must conform to the \ref concepts::WriteMap "WriteMap" concept. 837 843 typedef typename Digraph::template NodeMap<typename Digraph::Arc> PredMap; 838 844 ///Instantiates a PredMap. … … 849 855 850 856 ///The type of the map that indicates which nodes are processed. 851 ///It must meetthe \ref concepts::WriteMap "WriteMap" concept.852 ///By default it is a NullMap.857 ///It must conform to the \ref concepts::WriteMap "WriteMap" concept. 858 ///By default, it is a NullMap. 853 859 typedef NullMap<typename Digraph::Node,bool> ProcessedMap; 854 860 ///Instantiates a ProcessedMap. … … 869 875 870 876 ///The type of the map that indicates which nodes are reached. 871 ///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept. 877 ///It must conform to 878 ///the \ref concepts::ReadWriteMap "ReadWriteMap" concept. 872 879 typedef typename Digraph::template NodeMap<bool> ReachedMap; 873 880 ///Instantiates a ReachedMap. … … 884 891 885 892 ///The type of the map that stores the distances of the nodes. 886 ///It must meetthe \ref concepts::WriteMap "WriteMap" concept.893 ///It must conform to the \ref concepts::WriteMap "WriteMap" concept. 887 894 typedef typename Digraph::template NodeMap<int> DistMap; 888 895 ///Instantiates a DistMap. … … 899 906 900 907 ///The type of the shortest paths. 901 ///It must meetthe \ref concepts::Path "Path" concept.908 ///It must conform to the \ref concepts::Path "Path" concept. 902 909 typedef lemon::Path<Digraph> Path; 903 910 }; … … 905 912 /// Default traits class used by BfsWizard 906 913 907 /// To make it easier to use Bfs algorithm 908 /// we have created a wizard class. 909 /// This \ref BfsWizard class needs default traits, 910 /// as well as the \ref Bfs class. 911 /// The \ref BfsWizardBase is a class to be the default traits of the 912 /// \ref BfsWizard class. 914 /// Default traits class used by BfsWizard. 915 /// \tparam GR The type of the digraph. 913 916 template<class GR> 914 917 class BfsWizardBase : public BfsWizardDefaultTraits<GR> … … 938 941 /// Constructor. 939 942 940 /// This constructor does not require parameters, thereforeit initiates943 /// This constructor does not require parameters, it initiates 941 944 /// all of the attributes to \c 0. 942 945 BfsWizardBase() : _g(0), _reached(0), _processed(0), _pred(0), … … 963 966 /// This class should only be used through the \ref bfs() function, 964 967 /// which makes it easier to use the algorithm. 968 /// 969 /// \tparam TR The traits class that defines various types used by the 970 /// algorithm. 965 971 template<class TR> 966 972 class BfsWizard : public TR … … 968 974 typedef TR Base; 969 975 970 ///The type of the digraph the algorithm runs on.971 976 typedef typename TR::Digraph Digraph; 972 977 … … 976 981 typedef typename Digraph::OutArcIt OutArcIt; 977 982 978 ///\brief The type of the map that stores the predecessor979 ///arcs of the shortest paths.980 983 typedef typename TR::PredMap PredMap; 981 ///\brief The type of the map that stores the distances of the nodes.982 984 typedef typename TR::DistMap DistMap; 983 ///\brief The type of the map that indicates which nodes are reached.984 985 typedef typename TR::ReachedMap ReachedMap; 985 ///\brief The type of the map that indicates which nodes are processed.986 986 typedef typename TR::ProcessedMap ProcessedMap; 987 ///The type of the shortest paths988 987 typedef typename TR::Path Path; 989 988 … … 1055 1054 ///Runs BFS algorithm to visit all nodes in the digraph. 1056 1055 1057 ///This method runs BFS algorithm in order to compute1058 /// the shortest path to each node.1056 ///This method runs BFS algorithm in order to visit all nodes 1057 ///in the digraph. 1059 1058 void run() 1060 1059 { … … 1068 1067 SetPredMapBase(const TR &b) : TR(b) {} 1069 1068 }; 1070 ///\brief \ref named-func-param "Named parameter" 1071 ///for setting PredMap object. 1072 /// 1073 ///\ref named-func-param "Named parameter" 1074 ///for setting PredMap object. 1069 1070 ///\brief \ref named-templ-param "Named parameter" for setting 1071 ///the predecessor map. 1072 /// 1073 ///\ref named-templ-param "Named parameter" function for setting 1074 ///the map that stores the predecessor arcs of the nodes. 1075 1075 template<class T> 1076 1076 BfsWizard<SetPredMapBase<T> > predMap(const T &t) … … 1086 1086 SetReachedMapBase(const TR &b) : TR(b) {} 1087 1087 }; 1088 ///\brief \ref named-func-param "Named parameter" 1089 ///for setting ReachedMap object. 1090 /// 1091 /// \ref named-func-param "Named parameter" 1092 ///for setting ReachedMap object. 1088 1089 ///\brief \ref named-templ-param "Named parameter" for setting 1090 ///the reached map. 1091 /// 1092 ///\ref named-templ-param "Named parameter" function for setting 1093 ///the map that indicates which nodes are reached. 1093 1094 template<class T> 1094 1095 BfsWizard<SetReachedMapBase<T> > reachedMap(const T &t) … … 1104 1105 SetDistMapBase(const TR &b) : TR(b) {} 1105 1106 }; 1106 ///\brief \ref named-func-param "Named parameter" 1107 ///for setting DistMap object. 1108 /// 1109 /// \ref named-func-param "Named parameter" 1110 ///for setting DistMap object. 1107 1108 ///\brief \ref named-templ-param "Named parameter" for setting 1109 ///the distance map. 1110 /// 1111 ///\ref named-templ-param "Named parameter" function for setting 1112 ///the map that stores the distances of the nodes calculated 1113 ///by the algorithm. 1111 1114 template<class T> 1112 1115 BfsWizard<SetDistMapBase<T> > distMap(const T &t) … … 1122 1125 SetProcessedMapBase(const TR &b) : TR(b) {} 1123 1126 }; 1124 ///\brief \ref named-func-param "Named parameter" 1125 ///for setting ProcessedMap object. 1126 /// 1127 /// \ref named-func-param "Named parameter" 1128 ///for setting ProcessedMap object. 1127 1128 ///\brief \ref named-func-param "Named parameter" for setting 1129 ///the processed map. 1130 /// 1131 ///\ref named-templ-param "Named parameter" function for setting 1132 ///the map that indicates which nodes are processed. 1129 1133 template<class T> 1130 1134 BfsWizard<SetProcessedMapBase<T> > processedMap(const T &t) … … 1266 1270 /// 1267 1271 /// The type of the map that indicates which nodes are reached. 1268 /// It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept. 1272 /// It must conform to 1273 ///the \ref concepts::ReadWriteMap "ReadWriteMap" concept. 1269 1274 typedef typename Digraph::template NodeMap<bool> ReachedMap; 1270 1275 … … 1304 1309 /// does not observe the BFS events. If you want to observe the BFS 1305 1310 /// events, you should implement your own visitor class. 1306 /// \tparam TR T raits class to set various datatypes used by the1307 /// algorithm. The default traits class is1308 /// \ref BfsVisitDefaultTraits"BfsVisitDefaultTraits<GR>".1309 /// See \ref BfsVisitDefaultTraits for the documentation of1310 /// a BFS visit traits class.1311 /// \tparam TR The traits class that defines various types used by the 1312 /// algorithm. By default, it is \ref BfsVisitDefaultTraits 1313 /// "BfsVisitDefaultTraits<GR>". 1314 /// In most cases, this parameter should not be set directly, 1315 /// consider to use the named template parameters instead. 1311 1316 #ifdef DOXYGEN 1312 1317 template <typename GR, typename VS, typename TR> … … 1427 1432 /// The simplest way to execute the BFS algorithm is to use one of the 1428 1433 /// member functions called \ref run(Node) "run()".\n 1429 /// If you need more control on the execution, firstyou have to call1430 /// \ref init() , then you can add several source nodes with1434 /// If you need better control on the execution, you have to call 1435 /// \ref init() first, then you can add several source nodes with 1431 1436 /// \ref addSource(). Finally the actual path computation can be 1432 1437 /// performed with one of the \ref start() functions. … … 1700 1705 /// \brief Runs the algorithm to visit all nodes in the digraph. 1701 1706 /// 1702 /// This method runs the %BFS algorithm in order to 1703 /// compute the shortest path to each node. 1704 /// 1705 /// The algorithm computes 1706 /// - the shortest path tree (forest), 1707 /// - the distance of each node from the root(s). 1707 /// This method runs the %BFS algorithm in order to visit all nodes 1708 /// in the digraph. 1708 1709 /// 1709 1710 /// \note <tt>b.run(s)</tt> is just a shortcut of the following code. … … 1737 1738 ///@{ 1738 1739 1739 /// \brief Checks if anode is reached from the root(s).1740 /// \brief Checks if the given node is reached from the root(s). 1740 1741 /// 1741 1742 /// Returns \c true if \c v is reached from the root(s). -
lemon/bits/edge_set_extender.h
r1107 r1159 524 524 // Returns the base node of the iterator 525 525 Node baseNode(const IncEdgeIt &e) const { 526 return e.direction ? u(e) :v(e);526 return e.direction ? this->u(e) : this->v(e); 527 527 } 528 528 // Running node of the iterator … … 530 530 // Returns the running node of the iterator 531 531 Node runningNode(const IncEdgeIt &e) const { 532 return e.direction ? v(e) :u(e);532 return e.direction ? this->v(e) : this->u(e); 533 533 } 534 534 -
lemon/bits/edge_set_extender.h
r1157 r1159 1 /* -*- C++-*-1 /* -*- mode: C++; indent-tabs-mode: nil; -*- 2 2 * 3 * This file is a part of LEMON, a generic C++ optimization library 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-20 085 * Copyright (C) 2003-2010 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 64 64 Node oppositeNode(const Node &n, const Arc &e) const { 65 65 if (n == Parent::source(e)) 66 66 return Parent::target(e); 67 67 else if(n==Parent::target(e)) 68 68 return Parent::source(e); 69 69 else 70 70 return INVALID; 71 71 } 72 72 … … 92 92 // Iterable extensions 93 93 94 class NodeIt : public Node { 94 class NodeIt : public Node { 95 95 const Digraph* digraph; 96 96 public: … … 101 101 102 102 explicit NodeIt(const Digraph& _graph) : digraph(&_graph) { 103 104 } 105 106 NodeIt(const Digraph& _graph, const Node& node) 107 108 109 NodeIt& operator++() { 110 111 return *this; 112 } 113 114 }; 115 116 117 class ArcIt : public Arc { 103 _graph.first(static_cast<Node&>(*this)); 104 } 105 106 NodeIt(const Digraph& _graph, const Node& node) 107 : Node(node), digraph(&_graph) {} 108 109 NodeIt& operator++() { 110 digraph->next(*this); 111 return *this; 112 } 113 114 }; 115 116 117 class ArcIt : public Arc { 118 118 const Digraph* digraph; 119 119 public: … … 124 124 125 125 explicit ArcIt(const Digraph& _graph) : digraph(&_graph) { 126 127 } 128 129 ArcIt(const Digraph& _graph, const Arc& e) : 130 131 132 ArcIt& operator++() { 133 134 return *this; 135 } 136 137 }; 138 139 140 class OutArcIt : public Arc { 126 _graph.first(static_cast<Arc&>(*this)); 127 } 128 129 ArcIt(const Digraph& _graph, const Arc& e) : 130 Arc(e), digraph(&_graph) { } 131 132 ArcIt& operator++() { 133 digraph->next(*this); 134 return *this; 135 } 136 137 }; 138 139 140 class OutArcIt : public Arc { 141 141 const Digraph* digraph; 142 142 public: … … 146 146 OutArcIt(Invalid i) : Arc(i) { } 147 147 148 OutArcIt(const Digraph& _graph, const Node& node) 149 150 151 } 152 153 OutArcIt(const Digraph& _graph, const Arc& arc) 154 155 156 OutArcIt& operator++() { 157 158 return *this; 159 } 160 161 }; 162 163 164 class InArcIt : public Arc { 148 OutArcIt(const Digraph& _graph, const Node& node) 149 : digraph(&_graph) { 150 _graph.firstOut(*this, node); 151 } 152 153 OutArcIt(const Digraph& _graph, const Arc& arc) 154 : Arc(arc), digraph(&_graph) {} 155 156 OutArcIt& operator++() { 157 digraph->nextOut(*this); 158 return *this; 159 } 160 161 }; 162 163 164 class InArcIt : public Arc { 165 165 const Digraph* digraph; 166 166 public: … … 170 170 InArcIt(Invalid i) : Arc(i) { } 171 171 172 InArcIt(const Digraph& _graph, const Node& node) 173 174 175 } 176 177 InArcIt(const Digraph& _graph, const Arc& arc) : 178 179 180 InArcIt& operator++() { 181 182 return *this; 172 InArcIt(const Digraph& _graph, const Node& node) 173 : digraph(&_graph) { 174 _graph.firstIn(*this, node); 175 } 176 177 InArcIt(const Digraph& _graph, const Arc& arc) : 178 Arc(arc), digraph(&_graph) {} 179 180 InArcIt& operator++() { 181 digraph->nextIn(*this); 182 return *this; 183 183 } 184 184 … … 216 216 217 217 // Mappable extension 218 218 219 219 template <typename _Value> 220 class ArcMap 220 class ArcMap 221 221 : public MapExtender<DefaultMap<Digraph, Arc, _Value> > { 222 222 typedef MapExtender<DefaultMap<Digraph, Arc, _Value> > Parent; 223 223 224 224 public: 225 explicit ArcMap(const Digraph& _g) 226 227 ArcMap(const Digraph& _g, const _Value& _v) 228 225 explicit ArcMap(const Digraph& _g) 226 : Parent(_g) {} 227 ArcMap(const Digraph& _g, const _Value& _v) 228 : Parent(_g, _v) {} 229 229 230 230 ArcMap& operator=(const ArcMap& cmap) { 231 231 return operator=<ArcMap>(cmap); 232 232 } 233 233 … … 235 235 ArcMap& operator=(const CMap& cmap) { 236 236 Parent::operator=(cmap); 237 237 return *this; 238 238 } 239 239 … … 248 248 return arc; 249 249 } 250 250 251 251 void clear() { 252 252 notifier(Arc()).clear(); … … 313 313 Node oppositeNode(const Node &n, const Edge &e) const { 314 314 if( n == Parent::u(e)) 315 315 return Parent::v(e); 316 316 else if( n == Parent::v(e)) 317 317 return Parent::u(e); 318 318 else 319 319 return INVALID; 320 320 } 321 321 … … 341 341 342 342 using Parent::notifier; 343 343 344 344 ArcNotifier& notifier(Arc) const { 345 345 return arc_notifier; … … 351 351 352 352 353 class NodeIt : public Node { 353 class NodeIt : public Node { 354 354 const Graph* graph; 355 355 public: … … 360 360 361 361 explicit NodeIt(const Graph& _graph) : graph(&_graph) { 362 363 } 364 365 NodeIt(const Graph& _graph, const Node& node) 366 367 368 NodeIt& operator++() { 369 370 return *this; 371 } 372 373 }; 374 375 376 class ArcIt : public Arc { 362 _graph.first(static_cast<Node&>(*this)); 363 } 364 365 NodeIt(const Graph& _graph, const Node& node) 366 : Node(node), graph(&_graph) {} 367 368 NodeIt& operator++() { 369 graph->next(*this); 370 return *this; 371 } 372 373 }; 374 375 376 class ArcIt : public Arc { 377 377 const Graph* graph; 378 378 public: … … 383 383 384 384 explicit ArcIt(const Graph& _graph) : graph(&_graph) { 385 386 } 387 388 ArcIt(const Graph& _graph, const Arc& e) : 389 390 391 ArcIt& operator++() { 392 393 return *this; 394 } 395 396 }; 397 398 399 class OutArcIt : public Arc { 385 _graph.first(static_cast<Arc&>(*this)); 386 } 387 388 ArcIt(const Graph& _graph, const Arc& e) : 389 Arc(e), graph(&_graph) { } 390 391 ArcIt& operator++() { 392 graph->next(*this); 393 return *this; 394 } 395 396 }; 397 398 399 class OutArcIt : public Arc { 400 400 const Graph* graph; 401 401 public: … … 405 405 OutArcIt(Invalid i) : Arc(i) { } 406 406 407 OutArcIt(const Graph& _graph, const Node& node) 408 409 410 } 411 412 OutArcIt(const Graph& _graph, const Arc& arc) 413 414 415 OutArcIt& operator++() { 416 417 return *this; 418 } 419 420 }; 421 422 423 class InArcIt : public Arc { 407 OutArcIt(const Graph& _graph, const Node& node) 408 : graph(&_graph) { 409 _graph.firstOut(*this, node); 410 } 411 412 OutArcIt(const Graph& _graph, const Arc& arc) 413 : Arc(arc), graph(&_graph) {} 414 415 OutArcIt& operator++() { 416 graph->nextOut(*this); 417 return *this; 418 } 419 420 }; 421 422 423 class InArcIt : public Arc { 424 424 const Graph* graph; 425 425 public: … … 429 429 InArcIt(Invalid i) : Arc(i) { } 430 430 431 InArcIt(const Graph& _graph, const Node& node) 432 433 434 } 435 436 InArcIt(const Graph& _graph, const Arc& arc) : 437 438 439 InArcIt& operator++() { 440 441 return *this; 442 } 443 444 }; 445 446 447 class EdgeIt : public Parent::Edge { 431 InArcIt(const Graph& _graph, const Node& node) 432 : graph(&_graph) { 433 _graph.firstIn(*this, node); 434 } 435 436 InArcIt(const Graph& _graph, const Arc& arc) : 437 Arc(arc), graph(&_graph) {} 438 439 InArcIt& operator++() { 440 graph->nextIn(*this); 441 return *this; 442 } 443 444 }; 445 446 447 class EdgeIt : public Parent::Edge { 448 448 const Graph* graph; 449 449 public: … … 454 454 455 455 explicit EdgeIt(const Graph& _graph) : graph(&_graph) { 456 457 } 458 459 EdgeIt(const Graph& _graph, const Edge& e) : 460 461 462 EdgeIt& operator++() { 463 464 return *this; 456 _graph.first(static_cast<Edge&>(*this)); 457 } 458 459 EdgeIt(const Graph& _graph, const Edge& e) : 460 Edge(e), graph(&_graph) { } 461 462 EdgeIt& operator++() { 463 graph->next(*this); 464 return *this; 465 465 } 466 466 … … 478 478 479 479 IncEdgeIt(const Graph& _graph, const Node &n) : graph(&_graph) { 480 480 _graph.firstInc(*this, direction, n); 481 481 } 482 482 483 483 IncEdgeIt(const Graph& _graph, const Edge &ue, const Node &n) 484 485 484 : graph(&_graph), Edge(ue) { 485 direction = (_graph.source(ue) == n); 486 486 } 487 487 488 488 IncEdgeIt& operator++() { 489 490 return *this; 489 graph->nextInc(*this, direction); 490 return *this; 491 491 } 492 492 }; … … 535 535 536 536 template <typename _Value> 537 class ArcMap 537 class ArcMap 538 538 : public MapExtender<DefaultMap<Graph, Arc, _Value> > { 539 539 typedef MapExtender<DefaultMap<Graph, Arc, _Value> > Parent; 540 540 541 541 public: 542 explicit ArcMap(const Graph& _g) 543 544 ArcMap(const Graph& _g, const _Value& _v) 545 542 explicit ArcMap(const Graph& _g) 543 : Parent(_g) {} 544 ArcMap(const Graph& _g, const _Value& _v) 545 : Parent(_g, _v) {} 546 546 547 547 ArcMap& operator=(const ArcMap& cmap) { 548 548 return operator=<ArcMap>(cmap); 549 549 } 550 550 … … 552 552 ArcMap& operator=(const CMap& cmap) { 553 553 Parent::operator=(cmap); 554 554 return *this; 555 555 } 556 556 … … 559 559 560 560 template <typename _Value> 561 class EdgeMap 561 class EdgeMap 562 562 : public MapExtender<DefaultMap<Graph, Edge, _Value> > { 563 563 typedef MapExtender<DefaultMap<Graph, Edge, _Value> > Parent; 564 564 565 565 public: 566 explicit EdgeMap(const Graph& _g) 567 568 569 EdgeMap(const Graph& _g, const _Value& _v) 570 566 explicit EdgeMap(const Graph& _g) 567 : Parent(_g) {} 568 569 EdgeMap(const Graph& _g, const _Value& _v) 570 : Parent(_g, _v) {} 571 571 572 572 EdgeMap& operator=(const EdgeMap& cmap) { 573 573 return operator=<EdgeMap>(cmap); 574 574 } 575 575 … … 577 577 EdgeMap& operator=(const CMap& cmap) { 578 578 Parent::operator=(cmap); 579 579 return *this; 580 580 } 581 581 … … 594 594 return edge; 595 595 } 596 596 597 597 void clear() { 598 598 notifier(Arc()).clear(); … … 620 620 arc_notifier.clear(); 621 621 } 622 622 623 623 }; 624 624 -
lemon/bits/graph_extender.h
r825 r1159 588 588 // Returns the base node of the iterator 589 589 Node baseNode(const IncEdgeIt &edge) const { 590 return edge._direction ? u(edge) :v(edge);590 return edge._direction ? this->u(edge) : this->v(edge); 591 591 } 592 592 // Running node of the iterator … … 594 594 // Returns the running node of the iterator 595 595 Node runningNode(const IncEdgeIt &edge) const { 596 return edge._direction ? v(edge) :u(edge);596 return edge._direction ? this->v(edge) : this->u(edge); 597 597 } 598 598 -
lemon/bits/graph_extender.h
r1157 r1159 57 57 } 58 58 59 Node fromId(int id, Node) const{59 static Node fromId(int id, Node) { 60 60 return Parent::nodeFromId(id); 61 61 } 62 62 63 Arc fromId(int id, Arc) const{63 static Arc fromId(int id, Arc) { 64 64 return Parent::arcFromId(id); 65 65 } … … 356 356 } 357 357 358 Node fromId(int id, Node) const{358 static Node fromId(int id, Node) { 359 359 return Parent::nodeFromId(id); 360 360 } 361 361 362 Arc fromId(int id, Arc) const{362 static Arc fromId(int id, Arc) { 363 363 return Parent::arcFromId(id); 364 364 } 365 365 366 Edge fromId(int id, Edge) const{366 static Edge fromId(int id, Edge) { 367 367 return Parent::edgeFromId(id); 368 368 } -
lemon/bits/solver_bits.h
r956 r1142 45 45 void clear() { 46 46 first_item = -1; 47 last_item = -1; 47 48 first_free_item = -1; 48 49 items.clear(); -
lemon/bits/solver_bits.h
r1140 r1142 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-20 085 * Copyright (C) 2003-2010 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). -
lemon/cbc.cc
r793 r1159 26 26 #include <coin/OsiSolverInterface.hpp> 27 27 28 #ifdef COIN_HAS_CLP29 28 #include "coin/OsiClpSolverInterface.hpp" 30 #endif31 #ifdef COIN_HAS_OSL32 #include "coin/OsiOslSolverInterface.hpp"33 #endif34 29 35 30 #include "coin/CbcCutGenerator.hpp" … … 271 266 delete _osi_solver; 272 267 } 273 #ifdef COIN_HAS_CLP274 268 _osi_solver = new OsiClpSolverInterface(); 275 #elif COIN_HAS_OSL276 _osi_solver = new OsiOslSolverInterface();277 #else278 #error Cannot instantiate Osi solver279 #endif280 269 281 270 _osi_solver->loadFromCoinModel(*_prob); … … 329 318 _cbc_model->addCutGenerator(&flowGen, -1, "FlowCover"); 330 319 331 #ifdef COIN_HAS_CLP332 320 OsiClpSolverInterface* osiclp = 333 321 dynamic_cast<OsiClpSolverInterface*>(_cbc_model->solver()); … … 335 323 osiclp->setupForRepeatedUse(2, 0); 336 324 } 337 #endif338 325 339 326 CbcRounding heuristic1(*_cbc_model); … … 449 436 450 437 _prob = new CoinModel(); 451 rows.clear();452 cols.clear();453 438 } 454 439 -
lemon/cbc.cc
r1140 r1159 90 90 } 91 91 92 int CbcMip::_addRow(Value l, ExprIterator b, ExprIterator e, Value u) { 93 std::vector<int> indexes; 94 std::vector<Value> values; 95 96 for(ExprIterator it = b; it != e; ++it) { 97 indexes.push_back(it->first); 98 values.push_back(it->second); 99 } 100 101 _prob->addRow(values.size(), &indexes.front(), &values.front(), l, u); 102 return _prob->numberRows() - 1; 103 } 92 104 93 105 void CbcMip::_eraseCol(int i) { -
lemon/circulation.h
r956 r1159 573 573 574 574 Node act; 575 Node bact=INVALID;576 Node last_activated=INVALID;577 575 while((act=_level->highestActive())!=INVALID) { 578 576 int actlevel=(*_level)[act]; -
lemon/circulation.h
r1157 r1159 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-20 095 * Copyright (C) 2003-2010 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 60 60 /// \brief The type of supply map. 61 61 /// 62 /// The type of the map that stores the signed supply values of the 63 /// nodes. 62 /// The type of the map that stores the signed supply values of the 63 /// nodes. 64 64 /// It must conform to the \ref concepts::ReadMap "ReadMap" concept. 65 65 typedef SM SupplyMap; … … 73 73 /// It must conform to the \ref concepts::ReadWriteMap "ReadWriteMap" 74 74 /// concept. 75 #ifdef DOXYGEN 76 typedef GR::ArcMap<Value> FlowMap; 77 #else 75 78 typedef typename Digraph::template ArcMap<Value> FlowMap; 79 #endif 76 80 77 81 /// \brief Instantiates a FlowMap. … … 88 92 /// The elevator type used by the algorithm. 89 93 /// 90 /// \sa Elevator 91 /// \sa LinkedElevator 94 /// \sa Elevator, LinkedElevator 95 #ifdef DOXYGEN 96 typedef lemon::Elevator<GR, GR::Node> Elevator; 97 #else 92 98 typedef lemon::Elevator<Digraph, typename Digraph::Node> Elevator; 99 #endif 93 100 94 101 /// \brief Instantiates an Elevator. … … 135 142 \geq sup(u) \quad \forall u\in V, \f] 136 143 \f[ lower(uv) \leq f(uv) \leq upper(uv) \quad \forall uv\in A. \f] 137 144 138 145 The sum of the supply values, i.e. \f$\sum_{u\in V} sup(u)\f$ must be 139 146 zero or negative in order to have a feasible solution (since the sum … … 145 152 constraints have to be satisfied with equality, i.e. all demands 146 153 have to be satisfied and all supplies have to be used. 147 154 148 155 If you need the opposite inequalities in the supply/demand constraints 149 156 (i.e. the total demand is less than the total supply and all the demands … … 167 174 \tparam SM The type of the supply map. The default map type is 168 175 \ref concepts::Digraph::NodeMap "GR::NodeMap<UM::Value>". 176 \tparam TR The traits class that defines various types used by the 177 algorithm. By default, it is \ref CirculationDefaultTraits 178 "CirculationDefaultTraits<GR, LM, UM, SM>". 179 In most cases, this parameter should not be set directly, 180 consider to use the named template parameters instead. 169 181 */ 170 182 #ifdef DOXYGEN … … 300 312 /// able to automatically created by the algorithm (i.e. the 301 313 /// digraph and the maximum level should be passed to it). 302 /// However an external elevator object could also be passed to the314 /// However, an external elevator object could also be passed to the 303 315 /// algorithm with the \ref elevator(Elevator&) "elevator()" function 304 316 /// before calling \ref run() or \ref init(). … … 326 338 /// \param graph The digraph the algorithm runs on. 327 339 /// \param lower The lower bounds for the flow values on the arcs. 328 /// \param upper The upper bounds (capacities) for the flow values 340 /// \param upper The upper bounds (capacities) for the flow values 329 341 /// on the arcs. 330 342 /// \param supply The signed supply values of the nodes. … … 451 463 } 452 464 453 /// \brief Sets the tolerance used by algorithm. 454 /// 455 /// Sets the tolerance used by algorithm. 465 /// \brief Sets the tolerance used by the algorithm. 466 /// 467 /// Sets the tolerance object used by the algorithm. 468 /// \return <tt>(*this)</tt> 456 469 Circulation& tolerance(const Tolerance& tolerance) { 457 470 _tol = tolerance; … … 461 474 /// \brief Returns a const reference to the tolerance. 462 475 /// 463 /// Returns a const reference to the tolerance. 476 /// Returns a const reference to the tolerance object used by 477 /// the algorithm. 464 478 const Tolerance& tolerance() const { 465 479 return _tol; … … 468 482 /// \name Execution Control 469 483 /// The simplest way to execute the algorithm is to call \ref run().\n 470 /// If you need morecontrol on the initial solution or the execution,471 /// first you have to call one of the \ref init() functions, then484 /// If you need better control on the initial solution or the execution, 485 /// you have to call one of the \ref init() functions first, then 472 486 /// the \ref start() function. 473 487 -
lemon/clp.cc
r956 r1142 438 438 delete _prob; 439 439 _prob = new ClpSimplex(); 440 rows.clear();441 cols.clear();442 440 _col_names_ref.clear(); 443 441 _clear_temporals(); -
lemon/clp.cc
r1140 r1142 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-20 085 * Copyright (C) 2003-2010 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 76 76 int ClpLp::_addRow() { 77 77 _prob->addRow(0, 0, 0, -COIN_DBL_MAX, COIN_DBL_MAX); 78 return _prob->numberRows() - 1; 79 } 80 81 int ClpLp::_addRow(Value l, ExprIterator b, ExprIterator e, Value u) { 82 std::vector<int> indexes; 83 std::vector<Value> values; 84 85 for(ExprIterator it = b; it != e; ++it) { 86 indexes.push_back(it->first); 87 values.push_back(it->second); 88 } 89 90 _prob->addRow(values.size(), &indexes.front(), &values.front(), l, u); 78 91 return _prob->numberRows() - 1; 79 92 } -
lemon/concepts/graph_components.h
r956 r1159 116 116 const _GraphItem &ia; 117 117 const _GraphItem &ib; 118 Constraints() {} 118 119 }; 119 120 }; … … 175 176 176 177 const _Digraph& digraph; 178 Constraints() {} 177 179 }; 178 180 }; … … 291 293 292 294 const _Graph& graph; 295 Constraints() {} 293 296 }; 294 297 … … 370 373 371 374 const _Digraph& digraph; 375 Constraints() {} 372 376 }; 373 377 }; … … 422 426 423 427 const _Graph& graph; 428 Constraints() {} 424 429 }; 425 430 }; … … 490 495 _GraphItemIt it3 = it1; 491 496 _GraphItemIt it4 = INVALID; 497 ignore_unused_variable_warning(it3); 498 ignore_unused_variable_warning(it4); 492 499 493 500 it2 = ++it1; … … 499 506 } 500 507 const GR& g; 508 Constraints() {} 501 509 }; 502 510 }; … … 578 586 _GraphIncIt it3 = it1; 579 587 _GraphIncIt it4 = INVALID; 588 ignore_unused_variable_warning(it3); 589 ignore_unused_variable_warning(it4); 580 590 581 591 it2 = ++it1; … … 587 597 const Base& node; 588 598 const GR& graph; 599 Constraints() {} 589 600 }; 590 601 }; … … 763 774 764 775 const _Digraph& digraph; 776 Constraints() {} 765 777 }; 766 778 }; … … 887 899 888 900 const _Graph& graph; 901 Constraints() {} 889 902 }; 890 903 }; … … 944 957 945 958 const _Digraph& digraph; 959 Constraints() {} 946 960 }; 947 961 }; … … 985 999 986 1000 const _Graph& graph; 1001 Constraints() {} 987 1002 }; 988 1003 }; … … 1062 1077 const GR &g; 1063 1078 const typename GraphMap::Value &t; 1079 Constraints() {} 1064 1080 }; 1065 1081 … … 1200 1216 1201 1217 const _Digraph& digraph; 1218 Constraints() {} 1202 1219 }; 1203 1220 }; … … 1285 1302 1286 1303 const _Graph& graph; 1304 Constraints() {} 1287 1305 }; 1288 1306 }; … … 1329 1347 1330 1348 _Digraph& digraph; 1349 Constraints() {} 1331 1350 }; 1332 1351 }; … … 1373 1392 1374 1393 _Graph& graph; 1394 Constraints() {} 1375 1395 }; 1376 1396 }; … … 1412 1432 1413 1433 _Digraph& digraph; 1434 Constraints() {} 1414 1435 }; 1415 1436 }; … … 1451 1472 1452 1473 _Graph& graph; 1474 Constraints() {} 1453 1475 }; 1454 1476 }; … … 1479 1501 1480 1502 _Digraph& digraph; 1503 Constraints() {} 1481 1504 }; 1482 1505 }; … … 1507 1530 1508 1531 _Graph& graph; 1532 Constraints() {} 1509 1533 }; 1510 1534 }; -
lemon/concepts/graph_components.h
r1157 r1159 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-20 095 * Copyright (C) 2003-2010 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 19 19 ///\ingroup graph_concepts 20 20 ///\file 21 ///\brief The concept of graph components.21 ///\brief The concepts of graph components. 22 22 23 23 #ifndef LEMON_CONCEPTS_GRAPH_COMPONENTS_H … … 39 39 /// \note This class is a template class so that we can use it to 40 40 /// create graph skeleton classes. The reason for this is that \c Node 41 /// and \c Arc (or \c Edge) types should \e not derive from the same 41 /// and \c Arc (or \c Edge) types should \e not derive from the same 42 42 /// base class. For \c Node you should instantiate it with character 43 43 /// \c 'n', for \c Arc with \c 'a' and for \c Edge with \c 'e'. … … 90 90 /// 91 91 /// This operator defines an ordering of the items. 92 /// It makes possible to use graph item types as key types in 92 /// It makes possible to use graph item types as key types in 93 93 /// associative containers (e.g. \c std::map). 94 94 /// 95 /// \note This operator only ha veto define some strict ordering of95 /// \note This operator only has to define some strict ordering of 96 96 /// the items; this order has nothing to do with the iteration 97 97 /// ordering of the items. … … 124 124 /// This class describes the base interface of directed graph types. 125 125 /// All digraph %concepts have to conform to this class. 126 /// It just provides types for nodes and arcs and functions 126 /// It just provides types for nodes and arcs and functions 127 127 /// to get the source and the target nodes of arcs. 128 128 class BaseDigraphComponent { … … 432 432 /// \brief Concept class for \c NodeIt, \c ArcIt and \c EdgeIt types. 433 433 /// 434 /// This class describes the concept of \c NodeIt, \c ArcIt and 434 /// This class describes the concept of \c NodeIt, \c ArcIt and 435 435 /// \c EdgeIt subtypes of digraph and graph types. 436 436 template <typename GR, typename Item> … … 472 472 /// next item. 473 473 GraphItemIt& operator++() { return *this; } 474 474 475 475 /// \brief Equality operator 476 476 /// … … 510 510 }; 511 511 512 /// \brief Concept class for \c InArcIt, \c OutArcIt and 512 /// \brief Concept class for \c InArcIt, \c OutArcIt and 513 513 /// \c IncEdgeIt types. 514 514 /// 515 /// This class describes the concept of \c InArcIt, \c OutArcIt 515 /// This class describes the concept of \c InArcIt, \c OutArcIt 516 516 /// and \c IncEdgeIt subtypes of digraph and graph types. 517 517 /// 518 518 /// \note Since these iterator classes do not inherit from the same 519 519 /// base class, there is an additional template parameter (selector) 520 /// \c sel. For \c InArcIt you should instantiate it with character 520 /// \c sel. For \c InArcIt you should instantiate it with character 521 521 /// \c 'i', for \c OutArcIt with \c 'o' and for \c IncEdgeIt with \c 'e'. 522 522 template <typename GR, … … 539 539 GraphIncIt(const GraphIncIt& it) : Item(it) {} 540 540 541 /// \brief Constructor that sets the iterator to the first 541 /// \brief Constructor that sets the iterator to the first 542 542 /// incoming or outgoing arc. 543 543 /// 544 /// Constructor that sets the iterator to the first arc 544 /// Constructor that sets the iterator to the first arc 545 545 /// incoming to or outgoing from the given node. 546 546 explicit GraphIncIt(const GR&, const Base&) {} … … 817 817 /// \brief Return the first edge incident to the given node. 818 818 /// 819 /// This function gives back the first edge incident to the given 819 /// This function gives back the first edge incident to the given 820 820 /// node. The bool parameter gives back the direction for which the 821 /// source node of the directed arc representing the edge is the 821 /// source node of the directed arc representing the edge is the 822 822 /// given node. 823 823 void firstInc(Edge&, bool&, const Node&) const {} … … 826 826 /// given node. 827 827 /// 828 /// This function gives back the next edge incident to the given 828 /// This function gives back the next edge incident to the given 829 829 /// node. The bool parameter should be used as \c firstInc() use it. 830 830 void nextInc(Edge&, bool&) const {} … … 1006 1006 /// 1007 1007 /// This class describes the concept of standard graph maps, i.e. 1008 /// the \c NodeMap, \c ArcMap and \c EdgeMap subtypes of digraph and 1008 /// the \c NodeMap, \c ArcMap and \c EdgeMap subtypes of digraph and 1009 1009 /// graph types, which can be used for associating data to graph items. 1010 1010 /// The standard graph maps must conform to the ReferenceMap concept. … … 1061 1061 _Map m1(g); 1062 1062 _Map m2(g,t); 1063 1063 1064 1064 // Copy constructor 1065 1065 // _Map m3(m); … … 1085 1085 /// 1086 1086 /// This class describes the interface of mappable directed graphs. 1087 /// It extends \ref BaseDigraphComponent with the standard digraph 1087 /// It extends \ref BaseDigraphComponent with the standard digraph 1088 1088 /// map classes, namely \c NodeMap and \c ArcMap. 1089 1089 /// This concept is part of the Digraph concept. … … 1223 1223 /// 1224 1224 /// This class describes the interface of mappable undirected graphs. 1225 /// It extends \ref MappableDigraphComponent with the standard graph 1225 /// It extends \ref MappableDigraphComponent with the standard graph 1226 1226 /// map class for edges (\c EdgeMap). 1227 1227 /// This concept is part of the Graph concept. … … 1309 1309 /// 1310 1310 /// This class describes the interface of extendable directed graphs. 1311 /// It extends \ref BaseDigraphComponent with functions for adding 1311 /// It extends \ref BaseDigraphComponent with functions for adding 1312 1312 /// nodes and arcs to the digraph. 1313 1313 /// This concept requires \ref AlterableDigraphComponent. … … 1354 1354 /// 1355 1355 /// This class describes the interface of extendable undirected graphs. 1356 /// It extends \ref BaseGraphComponent with functions for adding 1356 /// It extends \ref BaseGraphComponent with functions for adding 1357 1357 /// nodes and edges to the graph. 1358 1358 /// This concept requires \ref AlterableGraphComponent. … … 1399 1399 /// 1400 1400 /// This class describes the interface of erasable directed graphs. 1401 /// It extends \ref BaseDigraphComponent with functions for removing 1401 /// It extends \ref BaseDigraphComponent with functions for removing 1402 1402 /// nodes and arcs from the digraph. 1403 1403 /// This concept requires \ref AlterableDigraphComponent. … … 1412 1412 /// \brief Erase a node from the digraph. 1413 1413 /// 1414 /// This function erases the given node from the digraph and all arcs 1414 /// This function erases the given node from the digraph and all arcs 1415 1415 /// connected to the node. 1416 1416 void erase(const Node&) {} … … 1439 1439 /// 1440 1440 /// This class describes the interface of erasable undirected graphs. 1441 /// It extends \ref BaseGraphComponent with functions for removing 1441 /// It extends \ref BaseGraphComponent with functions for removing 1442 1442 /// nodes and edges from the graph. 1443 1443 /// This concept requires \ref AlterableGraphComponent. -
lemon/concepts/heap.h
r956 r1127 315 315 _Heap& heap; 316 316 ItemIntMap& map; 317 Constraints() {} 317 318 }; 318 319 }; -
lemon/concepts/heap.h
r1125 r1127 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-20 095 * Copyright (C) 2003-2010 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 17 17 */ 18 18 19 #ifndef LEMON_CONCEPTS_HEAP_H 20 #define LEMON_CONCEPTS_HEAP_H 21 19 22 ///\ingroup concept 20 23 ///\file 21 24 ///\brief The concept of heaps. 22 25 23 #ifndef LEMON_CONCEPTS_HEAP_H24 #define LEMON_CONCEPTS_HEAP_H25 26 26 #include <lemon/core.h> 27 27 #include <lemon/concept_check.h> … … 36 36 /// \brief The heap concept. 37 37 /// 38 /// Concept class describing the main interface of heaps. A \e heap 39 /// is a data structure for storing items with specified values called 40 /// \e priorities in such a way that finding the item with minimum 41 /// priority is efficient. In a heap one can change the priority of an 42 /// item, add or erase an item, etc. 38 /// This concept class describes the main interface of heaps. 39 /// The various \ref heaps "heap structures" are efficient 40 /// implementations of the abstract data type \e priority \e queue. 41 /// They store items with specified values called \e priorities 42 /// in such a way that finding and removing the item with minimum 43 /// priority are efficient. The basic operations are adding and 44 /// erasing items, changing the priority of an item, etc. 43 45 /// 44 /// \tparam PR Type of the priority of the items. 45 /// \tparam IM A read and writable item map with int values, used 46 /// Heaps are crucial in several algorithms, such as Dijkstra and Prim. 47 /// Any class that conforms to this concept can be used easily in such 48 /// algorithms. 49 /// 50 /// \tparam PR Type of the priorities of the items. 51 /// \tparam IM A read-writable item map with \c int values, used 46 52 /// internally to handle the cross references. 47 /// \tparam C omp A functor class for the ordering ofthe priorities.53 /// \tparam CMP A functor class for comparing the priorities. 48 54 /// The default is \c std::less<PR>. 49 55 #ifdef DOXYGEN 50 template <typename PR, typename IM, typename C omp = std::less<PR>>51 #else 52 template <typename PR, typename IM >56 template <typename PR, typename IM, typename CMP> 57 #else 58 template <typename PR, typename IM, typename CMP = std::less<PR> > 53 59 #endif 54 60 class Heap { … … 65 71 /// 66 72 /// Each item has a state associated to it. It can be "in heap", 67 /// "pre heap" or "post heap". The later two are indifferent 68 /// from the point of view of the heap, but may be useful for 69 /// the user. 73 /// "pre-heap" or "post-heap". The latter two are indifferent from the 74 /// heap's point of view, but may be useful to the user. 70 75 /// 71 76 /// The item-int map must be initialized in such way that it assigns … … 73 78 enum State { 74 79 IN_HEAP = 0, ///< = 0. The "in heap" state constant. 75 PRE_HEAP = -1, ///< = -1. The "pre 76 POST_HEAP = -2 ///< = -2. The "post 80 PRE_HEAP = -1, ///< = -1. The "pre-heap" state constant. 81 POST_HEAP = -2 ///< = -2. The "post-heap" state constant. 77 82 }; 78 83 79 /// \brief The constructor.80 /// 81 /// The constructor.84 /// \brief Constructor. 85 /// 86 /// Constructor. 82 87 /// \param map A map that assigns \c int values to keys of type 83 88 /// \c Item. It is used internally by the heap implementations to 84 89 /// handle the cross references. The assigned value must be 85 /// \c PRE_HEAP (<tt>-1</tt>) for every item. 90 /// \c PRE_HEAP (<tt>-1</tt>) for each item. 91 #ifdef DOXYGEN 86 92 explicit Heap(ItemIntMap &map) {} 93 #else 94 explicit Heap(ItemIntMap&) {} 95 #endif 96 97 /// \brief Constructor. 98 /// 99 /// Constructor. 100 /// \param map A map that assigns \c int values to keys of type 101 /// \c Item. It is used internally by the heap implementations to 102 /// handle the cross references. The assigned value must be 103 /// \c PRE_HEAP (<tt>-1</tt>) for each item. 104 /// \param comp The function object used for comparing the priorities. 105 #ifdef DOXYGEN 106 explicit Heap(ItemIntMap &map, const CMP &comp) {} 107 #else 108 explicit Heap(ItemIntMap&, const CMP&) {} 109 #endif 87 110 88 111 /// \brief The number of items stored in the heap. 89 112 /// 90 /// Returns the number of items stored in the heap.113 /// This function returns the number of items stored in the heap. 91 114 int size() const { return 0; } 92 115 93 /// \brief Check sif the heap is empty.94 /// 95 /// Returns \c true if the heap is empty.116 /// \brief Check if the heap is empty. 117 /// 118 /// This function returns \c true if the heap is empty. 96 119 bool empty() const { return false; } 97 120 98 /// \brief Makes the heap empty. 99 /// 100 /// Makes the heap empty. 101 void clear(); 102 103 /// \brief Inserts an item into the heap with the given priority. 104 /// 105 /// Inserts the given item into the heap with the given priority. 121 /// \brief Make the heap empty. 122 /// 123 /// This functon makes the heap empty. 124 /// It does not change the cross reference map. If you want to reuse 125 /// a heap that is not surely empty, you should first clear it and 126 /// then you should set the cross reference map to \c PRE_HEAP 127 /// for each item. 128 void clear() {} 129 130 /// \brief Insert an item into the heap with the given priority. 131 /// 132 /// This function inserts the given item into the heap with the 133 /// given priority. 106 134 /// \param i The item to insert. 107 135 /// \param p The priority of the item. 136 /// \pre \e i must not be stored in the heap. 137 #ifdef DOXYGEN 108 138 void push(const Item &i, const Prio &p) {} 109 110 /// \brief Returns the item having minimum priority. 111 /// 112 /// Returns the item having minimum priority. 139 #else 140 void push(const Item&, const Prio&) {} 141 #endif 142 143 /// \brief Return the item having minimum priority. 144 /// 145 /// This function returns the item having minimum priority. 113 146 /// \pre The heap must be non-empty. 114 Item top() const { }147 Item top() const { return Item(); } 115 148 116 149 /// \brief The minimum priority. 117 150 /// 118 /// Returns the minimum priority.151 /// This function returns the minimum priority. 119 152 /// \pre The heap must be non-empty. 120 Prio prio() const { }121 122 /// \brief Remove sthe item having minimum priority.123 /// 124 /// Removes the item having minimum priority.153 Prio prio() const { return Prio(); } 154 155 /// \brief Remove the item having minimum priority. 156 /// 157 /// This function removes the item having minimum priority. 125 158 /// \pre The heap must be non-empty. 126 159 void pop() {} 127 160 128 /// \brief Removes an item from the heap. 129 /// 130 /// Removes the given item from the heap if it is already stored. 161 /// \brief Remove the given item from the heap. 162 /// 163 /// This function removes the given item from the heap if it is 164 /// already stored. 131 165 /// \param i The item to delete. 166 /// \pre \e i must be in the heap. 167 #ifdef DOXYGEN 132 168 void erase(const Item &i) {} 133 134 /// \brief The priority of an item. 135 /// 136 /// Returns the priority of the given item. 137 /// \param i The item. 138 /// \pre \c i must be in the heap. 169 #else 170 void erase(const Item&) {} 171 #endif 172 173 /// \brief The priority of the given item. 174 /// 175 /// This function returns the priority of the given item. 176 /// \param i The item. 177 /// \pre \e i must be in the heap. 178 #ifdef DOXYGEN 139 179 Prio operator[](const Item &i) const {} 140 141 /// \brief Sets the priority of an item or inserts it, if it is 180 #else 181 Prio operator[](const Item&) const { return Prio(); } 182 #endif 183 184 /// \brief Set the priority of an item or insert it, if it is 142 185 /// not stored in the heap. 143 186 /// 144 187 /// This method sets the priority of the given item if it is 145 /// already stored in the heap. 146 /// Otherwise it inserts the given itemwith the given priority.188 /// already stored in the heap. Otherwise it inserts the given 189 /// item into the heap with the given priority. 147 190 /// 148 191 /// \param i The item. 149 192 /// \param p The priority. 193 #ifdef DOXYGEN 150 194 void set(const Item &i, const Prio &p) {} 151 152 /// \brief Decreases the priority of an item to the given value. 153 /// 154 /// Decreases the priority of an item to the given value. 195 #else 196 void set(const Item&, const Prio&) {} 197 #endif 198 199 /// \brief Decrease the priority of an item to the given value. 200 /// 201 /// This function decreases the priority of an item to the given value. 155 202 /// \param i The item. 156 203 /// \param p The priority. 157 /// \pre \c i must be stored in the heap with priority at least \c p. 204 /// \pre \e i must be stored in the heap with priority at least \e p. 205 #ifdef DOXYGEN 158 206 void decrease(const Item &i, const Prio &p) {} 159 160 /// \brief Increases the priority of an item to the given value. 161 /// 162 /// Increases the priority of an item to the given value. 207 #else 208 void decrease(const Item&, const Prio&) {} 209 #endif 210 211 /// \brief Increase the priority of an item to the given value. 212 /// 213 /// This function increases the priority of an item to the given value. 163 214 /// \param i The item. 164 215 /// \param p The priority. 165 /// \pre \c i must be stored in the heap with priority at most \c p. 216 /// \pre \e i must be stored in the heap with priority at most \e p. 217 #ifdef DOXYGEN 166 218 void increase(const Item &i, const Prio &p) {} 167 168 /// \brief Returns if an item is in, has already been in, or has 169 /// never been in the heap. 219 #else 220 void increase(const Item&, const Prio&) {} 221 #endif 222 223 /// \brief Return the state of an item. 170 224 /// 171 225 /// This method returns \c PRE_HEAP if the given item has never … … 175 229 /// to the heap again. 176 230 /// \param i The item. 231 #ifdef DOXYGEN 177 232 State state(const Item &i) const {} 178 179 /// \brief Sets the state of an item in the heap. 180 /// 181 /// Sets the state of the given item in the heap. It can be used 182 /// to manually clear the heap when it is important to achive the 183 /// better time complexity. 233 #else 234 State state(const Item&) const { return PRE_HEAP; } 235 #endif 236 237 /// \brief Set the state of an item in the heap. 238 /// 239 /// This function sets the state of the given item in the heap. 240 /// It can be used to manually clear the heap when it is important 241 /// to achive better time complexity. 184 242 /// \param i The item. 185 243 /// \param st The state. It should not be \c IN_HEAP. 244 #ifdef DOXYGEN 186 245 void state(const Item& i, State st) {} 246 #else 247 void state(const Item&, State) {} 248 #endif 187 249 188 250 -
lemon/concepts/path.h
r832 r1127 169 169 } 170 170 _Path& p; 171 PathDumperConstraints() {} 171 172 }; 172 173 … … 194 195 } 195 196 _Path& p; 197 PathDumperConstraints() {} 196 198 }; 197 199 -
lemon/concepts/path.h
r1125 r1127 19 19 ///\ingroup concept 20 20 ///\file 21 ///\brief Classes for representing paths in digraphs.21 ///\brief The concept of paths 22 22 /// 23 23 … … 39 39 /// A skeleton structure for representing directed paths in a 40 40 /// digraph. 41 /// In a sense, a path can be treated as a list of arcs. 42 /// LEMON path types just store this list. As a consequence, they cannot 43 /// enumerate the nodes on the path directly and a zero length path 44 /// cannot store its source node. 45 /// 46 /// The arcs of a path should be stored in the order of their directions, 47 /// i.e. the target node of each arc should be the same as the source 48 /// node of the next arc. This consistency could be checked using 49 /// \ref checkPath(). 50 /// The source and target nodes of a (consistent) path can be obtained 51 /// using \ref pathSource() and \ref pathTarget(). 52 /// 53 /// A path can be constructed from another path of any type using the 54 /// copy constructor or the assignment operator. 55 /// 41 56 /// \tparam GR The digraph type in which the path is. 42 ///43 /// In a sense, the path can be treated as a list of arcs. The44 /// lemon path type stores just this list. As a consequence it45 /// cannot enumerate the nodes in the path and the zero length46 /// paths cannot store the source.47 ///48 57 template <typename GR> 49 58 class Path { … … 60 69 Path() {} 61 70 62 /// \brief Template co nstructor71 /// \brief Template copy constructor 63 72 template <typename CPath> 64 73 Path(const CPath& cpath) {} 65 74 66 /// \brief Template assigment 75 /// \brief Template assigment operator 67 76 template <typename CPath> 68 77 Path& operator=(const CPath& cpath) { … … 71 80 } 72 81 73 /// Length of the path ie. the number of arcs in the path.82 /// Length of the path, i.e. the number of arcs on the path. 74 83 int length() const { return 0;} 75 84 … … 80 89 void clear() {} 81 90 82 /// \brief LEMON style iterator for path arcs91 /// \brief LEMON style iterator for enumerating the arcs of a path. 83 92 /// 84 /// This class is used to iterate on the arcs of the paths.93 /// LEMON style iterator class for enumerating the arcs of a path. 85 94 class ArcIt { 86 95 public: … … 89 98 /// Invalid constructor 90 99 ArcIt(Invalid) {} 91 /// Constructor for first arc100 /// Sets the iterator to the first arc of the given path 92 101 ArcIt(const Path &) {} 93 102 94 /// Conversion to Arc103 /// Conversion to \c Arc 95 104 operator Arc() const { return INVALID; } 96 105 … … 195 204 /// 196 205 /// A skeleton structure for path dumpers. The path dumpers are 197 /// the generalization of the paths. The path dumpers can 198 /// enumerate the arcs of the path wheter in forward or in 199 /// backward order. In most time these classes are not used 200 /// directly rather it used to assign a dumped class to a real 201 /// path type. 206 /// the generalization of the paths, they can enumerate the arcs 207 /// of the path either in forward or in backward order. 208 /// These classes are typically not used directly, they are rather 209 /// used to be assigned to a real path type. 202 210 /// 203 211 /// The main purpose of this concept is that the shortest path 204 /// algorithms can enumerate easily the arcs in reverse order. 205 /// If we would like to give back a real path from these 206 /// algorithms then we should create a temporarly path object. In 207 /// LEMON such algorithms gives back a path dumper what can 208 /// assigned to a real path and the dumpers can be implemented as 212 /// algorithms can enumerate the arcs easily in reverse order. 213 /// In LEMON, such algorithms give back a (reverse) path dumper that 214 /// can be assigned to a real path. The dumpers can be implemented as 209 215 /// an adaptor class to the predecessor map. 210 216 /// 211 217 /// \tparam GR The digraph type in which the path is. 212 ///213 /// The paths can be constructed from any path type by a214 /// template constructor or a template assignment operator.215 218 template <typename GR> 216 219 class PathDumper { … … 222 225 typedef typename Digraph::Arc Arc; 223 226 224 /// Length of the path ie. the number of arcs in the path.227 /// Length of the path, i.e. the number of arcs on the path. 225 228 int length() const { return 0;} 226 229 … … 230 233 /// \brief Forward or reverse dumping 231 234 /// 232 /// If the RevPathTag is defined and true then reverse dumping 233 /// is provided in the path dumper. In this case instead of the 234 /// ArcIt the RevArcIt iterator should be implemented in the 235 /// dumper. 235 /// If this tag is defined to be \c True, then reverse dumping 236 /// is provided in the path dumper. In this case, \c RevArcIt 237 /// iterator should be implemented instead of \c ArcIt iterator. 236 238 typedef False RevPathTag; 237 239 238 /// \brief LEMON style iterator for path arcs240 /// \brief LEMON style iterator for enumerating the arcs of a path. 239 241 /// 240 /// This class is used to iterate on the arcs of the paths.242 /// LEMON style iterator class for enumerating the arcs of a path. 241 243 class ArcIt { 242 244 public: … … 245 247 /// Invalid constructor 246 248 ArcIt(Invalid) {} 247 /// Constructor for first arc249 /// Sets the iterator to the first arc of the given path 248 250 ArcIt(const PathDumper&) {} 249 251 250 /// Conversion to Arc252 /// Conversion to \c Arc 251 253 operator Arc() const { return INVALID; } 252 254 … … 263 265 }; 264 266 265 /// \brief LEMON style iterator for path arcs 267 /// \brief LEMON style iterator for enumerating the arcs of a path 268 /// in reverse direction. 266 269 /// 267 /// This class is used to iterate on the arcs of the paths in268 /// reverse direction.270 /// LEMON style iterator class for enumerating the arcs of a path 271 /// in reverse direction. 269 272 class RevArcIt { 270 273 public: … … 273 276 /// Invalid constructor 274 277 RevArcIt(Invalid) {} 275 /// Constructor for first arc278 /// Sets the iterator to the last arc of the given path 276 279 RevArcIt(const PathDumper &) {} 277 280 278 /// Conversion to Arc281 /// Conversion to \c Arc 279 282 operator Arc() const { return INVALID; } 280 283 -
lemon/core.h
r1107 r1159 1850 1850 ///a single node \c n, then \ref refresh(Node) "refresh(n)" is enough. 1851 1851 /// 1852 #ifdef DOXYGEN 1853 Arc operator()(Node s, Node t, Arc prev=INVALID) const {} 1854 #else 1855 using ArcLookUp<GR>::operator() ; 1856 Arc operator()(Node s, Node t, Arc prev) const 1852 Arc operator()(Node s, Node t, Arc prev=INVALID) const 1857 1853 { 1858 return prev==INVALID?(*this)(s,t):_next[prev]; 1859 } 1854 if(prev==INVALID) 1855 { 1856 Arc f=INVALID; 1857 Arc e; 1858 for(e=_head[s]; 1859 e!=INVALID&&_g.target(e)!=t; 1860 e = t < _g.target(e)?_left[e]:_right[e]) ; 1861 while(e!=INVALID) 1862 if(_g.target(e)==t) 1863 { 1864 f = e; 1865 e = _left[e]; 1866 } 1867 else e = _right[e]; 1868 return f; 1869 } 1870 else return _next[prev]; 1871 } 1872 1873 }; 1874 1875 /// @} 1876 1877 } //namespace lemon 1878 1860 1879 #endif 1861 1862 };1863 1864 /// @}1865 1866 } //namespace lemon1867 1868 #endif -
lemon/core.h
r1149 r1159 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-20 095 * Copyright (C) 2003-2010 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 1242 1242 protected: 1243 1243 1244 class AutoNodeMap : public ItemSetTraits<GR, Node>::template Map<Arc>::Type { 1244 class AutoNodeMap : public ItemSetTraits<GR, Node>::template Map<Arc>::Type 1245 { 1245 1246 typedef typename ItemSetTraits<GR, Node>::template Map<Arc>::Type Parent; 1246 1247 … … 1281 1282 }; 1282 1283 1283 protected: 1284 protected: 1284 1285 1285 1286 const Digraph &_g; -
lemon/cplex.cc
r956 r1142 471 471 int status; 472 472 _prob = CPXcreateprob(cplexEnv(), &status, "Cplex problem"); 473 rows.clear();474 cols.clear();475 473 } 476 474 -
lemon/cplex.cc
r1140 r1142 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-20 095 * Copyright (C) 2003-2010 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 112 112 } 113 113 114 int CplexBase::_addRow(Value lb, ExprIterator b, 115 ExprIterator e, Value ub) { 116 int i = CPXgetnumrows(cplexEnv(), _prob); 117 if (lb == -INF) { 118 const char s = 'L'; 119 CPXnewrows(cplexEnv(), _prob, 1, &ub, &s, 0, 0); 120 } else if (ub == INF) { 121 const char s = 'G'; 122 CPXnewrows(cplexEnv(), _prob, 1, &lb, &s, 0, 0); 123 } else if (lb == ub){ 124 const char s = 'E'; 125 CPXnewrows(cplexEnv(), _prob, 1, &lb, &s, 0, 0); 126 } else { 127 const char s = 'R'; 128 double len = ub - lb; 129 CPXnewrows(cplexEnv(), _prob, 1, &lb, &s, &len, 0); 130 } 131 132 std::vector<int> indices; 133 std::vector<int> rowlist; 134 std::vector<Value> values; 135 136 for(ExprIterator it=b; it!=e; ++it) { 137 indices.push_back(it->first); 138 values.push_back(it->second); 139 rowlist.push_back(i); 140 } 141 142 CPXchgcoeflist(cplexEnv(), _prob, values.size(), 143 &rowlist.front(), &indices.front(), &values.front()); 144 145 return i; 146 } 114 147 115 148 void CplexBase::_eraseCol(int i) { … … 455 488 456 489 void CplexBase::_applyMessageLevel() { 457 CPXsetintparam(cplexEnv(), CPX_PARAM_SCRIND, 490 CPXsetintparam(cplexEnv(), CPX_PARAM_SCRIND, 458 491 _message_enabled ? CPX_ON : CPX_OFF); 459 492 } -
lemon/dfs.h
r1107 r1159 1194 1194 } 1195 1195 _Visitor& visitor; 1196 Constraints() {} 1196 1197 }; 1197 1198 }; -
lemon/dfs.h
r1125 r1159 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-20 095 * Copyright (C) 2003-2010 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 48 48 ///The type of the map that stores the predecessor 49 49 ///arcs of the %DFS paths. 50 ///It must meetthe \ref concepts::WriteMap "WriteMap" concept.50 ///It must conform to the \ref concepts::WriteMap "WriteMap" concept. 51 51 typedef typename Digraph::template NodeMap<typename Digraph::Arc> PredMap; 52 52 ///Instantiates a \c PredMap. … … 63 63 64 64 ///The type of the map that indicates which nodes are processed. 65 ///It must meet the \ref concepts::WriteMap "WriteMap" concept. 65 ///It must conform to the \ref concepts::WriteMap "WriteMap" concept. 66 ///By default, it is a NullMap. 66 67 typedef NullMap<typename Digraph::Node,bool> ProcessedMap; 67 68 ///Instantiates a \c ProcessedMap. … … 82 83 83 84 ///The type of the map that indicates which nodes are reached. 84 ///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept. 85 ///It must conform to 86 ///the \ref concepts::ReadWriteMap "ReadWriteMap" concept. 85 87 typedef typename Digraph::template NodeMap<bool> ReachedMap; 86 88 ///Instantiates a \c ReachedMap. … … 97 99 98 100 ///The type of the map that stores the distances of the nodes. 99 ///It must meetthe \ref concepts::WriteMap "WriteMap" concept.101 ///It must conform to the \ref concepts::WriteMap "WriteMap" concept. 100 102 typedef typename Digraph::template NodeMap<int> DistMap; 101 103 ///Instantiates a \c DistMap. … … 121 123 ///\tparam GR The type of the digraph the algorithm runs on. 122 124 ///The default type is \ref ListDigraph. 125 ///\tparam TR The traits class that defines various types used by the 126 ///algorithm. By default, it is \ref DfsDefaultTraits 127 ///"DfsDefaultTraits<GR>". 128 ///In most cases, this parameter should not be set directly, 129 ///consider to use the named template parameters instead. 123 130 #ifdef DOXYGEN 124 131 template <typename GR, … … 225 232 ///\ref named-templ-param "Named parameter" for setting 226 233 ///\c PredMap type. 227 ///It must meetthe \ref concepts::WriteMap "WriteMap" concept.234 ///It must conform to the \ref concepts::WriteMap "WriteMap" concept. 228 235 template <class T> 229 236 struct SetPredMap : public Dfs<Digraph, SetPredMapTraits<T> > { … … 245 252 ///\ref named-templ-param "Named parameter" for setting 246 253 ///\c DistMap type. 247 ///It must meetthe \ref concepts::WriteMap "WriteMap" concept.254 ///It must conform to the \ref concepts::WriteMap "WriteMap" concept. 248 255 template <class T> 249 256 struct SetDistMap : public Dfs< Digraph, SetDistMapTraits<T> > { … … 265 272 ///\ref named-templ-param "Named parameter" for setting 266 273 ///\c ReachedMap type. 267 ///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept. 274 ///It must conform to 275 ///the \ref concepts::ReadWriteMap "ReadWriteMap" concept. 268 276 template <class T> 269 277 struct SetReachedMap : public Dfs< Digraph, SetReachedMapTraits<T> > { … … 285 293 ///\ref named-templ-param "Named parameter" for setting 286 294 ///\c ProcessedMap type. 287 ///It must meetthe \ref concepts::WriteMap "WriteMap" concept.295 ///It must conform to the \ref concepts::WriteMap "WriteMap" concept. 288 296 template <class T> 289 297 struct SetProcessedMap : public Dfs< Digraph, SetProcessedMapTraits<T> > { … … 412 420 ///The simplest way to execute the DFS algorithm is to use one of the 413 421 ///member functions called \ref run(Node) "run()".\n 414 ///If you need more control on the execution, firstyou have to call415 ///\ref init() , then you can add a source node with \ref addSource()422 ///If you need better control on the execution, you have to call 423 ///\ref init() first, then you can add a source node with \ref addSource() 416 424 ///and perform the actual computation with \ref start(). 417 425 ///This procedure can be repeated if there are nodes that have not … … 633 641 ///Runs the algorithm to visit all nodes in the digraph. 634 642 635 ///This method runs the %DFS algorithm in order to compute the 636 ///%DFS path to each node. 637 /// 638 ///The algorithm computes 639 ///- the %DFS tree (forest), 640 ///- the distance of each node from the root(s) in the %DFS tree. 643 ///This method runs the %DFS algorithm in order to visit all nodes 644 ///in the digraph. 641 645 /// 642 646 ///\note <tt>d.run()</tt> is just a shortcut of the following code. … … 670 674 ///@{ 671 675 672 ///The DFS path to anode.673 674 ///Returns the DFS path to a node.676 ///The DFS path to the given node. 677 678 ///Returns the DFS path to the given node from the root(s). 675 679 /// 676 680 ///\warning \c t should be reached from the root(s). … … 680 684 Path path(Node t) const { return Path(*G, *_pred, t); } 681 685 682 ///The distance of anode from the root(s).683 684 ///Returns the distance of anode from the root(s).686 ///The distance of the given node from the root(s). 687 688 ///Returns the distance of the given node from the root(s). 685 689 /// 686 690 ///\warning If node \c v is not reached from the root(s), then … … 691 695 int dist(Node v) const { return (*_dist)[v]; } 692 696 693 ///Returns the 'previous arc' of the %DFS tree for anode.697 ///Returns the 'previous arc' of the %DFS tree for the given node. 694 698 695 699 ///This function returns the 'previous arc' of the %DFS tree for the … … 699 703 /// 700 704 ///The %DFS tree used here is equal to the %DFS tree used in 701 ///\ref predNode() .705 ///\ref predNode() and \ref predMap(). 702 706 /// 703 707 ///\pre Either \ref run(Node) "run()" or \ref init() … … 705 709 Arc predArc(Node v) const { return (*_pred)[v];} 706 710 707 ///Returns the 'previous node' of the %DFS tree .711 ///Returns the 'previous node' of the %DFS tree for the given node. 708 712 709 713 ///This function returns the 'previous node' of the %DFS 710 714 ///tree for the node \c v, i.e. it returns the last but one node 711 /// froma %DFS path from a root to \c v. It is \c INVALID715 ///of a %DFS path from a root to \c v. It is \c INVALID 712 716 ///if \c v is not reached from the root(s) or if \c v is a root. 713 717 /// 714 718 ///The %DFS tree used here is equal to the %DFS tree used in 715 ///\ref predArc() .719 ///\ref predArc() and \ref predMap(). 716 720 /// 717 721 ///\pre Either \ref run(Node) "run()" or \ref init() … … 734 738 /// 735 739 ///Returns a const reference to the node map that stores the predecessor 736 ///arcs, which form the DFS tree .740 ///arcs, which form the DFS tree (forest). 737 741 /// 738 742 ///\pre Either \ref run(Node) "run()" or \ref init() … … 740 744 const PredMap &predMap() const { return *_pred;} 741 745 742 ///Checks if anode is reached from the root(s).746 ///Checks if the given node. node is reached from the root(s). 743 747 744 748 ///Returns \c true if \c v is reached from the root(s). … … 766 770 ///The type of the map that stores the predecessor 767 771 ///arcs of the %DFS paths. 768 ///It must meetthe \ref concepts::WriteMap "WriteMap" concept.772 ///It must conform to the \ref concepts::WriteMap "WriteMap" concept. 769 773 typedef typename Digraph::template NodeMap<typename Digraph::Arc> PredMap; 770 774 ///Instantiates a PredMap. … … 781 785 782 786 ///The type of the map that indicates which nodes are processed. 783 ///It must meetthe \ref concepts::WriteMap "WriteMap" concept.784 ///By default it is a NullMap.787 ///It must conform to the \ref concepts::WriteMap "WriteMap" concept. 788 ///By default, it is a NullMap. 785 789 typedef NullMap<typename Digraph::Node,bool> ProcessedMap; 786 790 ///Instantiates a ProcessedMap. … … 801 805 802 806 ///The type of the map that indicates which nodes are reached. 803 ///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept. 807 ///It must conform to 808 ///the \ref concepts::ReadWriteMap "ReadWriteMap" concept. 804 809 typedef typename Digraph::template NodeMap<bool> ReachedMap; 805 810 ///Instantiates a ReachedMap. … … 816 821 817 822 ///The type of the map that stores the distances of the nodes. 818 ///It must meetthe \ref concepts::WriteMap "WriteMap" concept.823 ///It must conform to the \ref concepts::WriteMap "WriteMap" concept. 819 824 typedef typename Digraph::template NodeMap<int> DistMap; 820 825 ///Instantiates a DistMap. … … 831 836 832 837 ///The type of the DFS paths. 833 ///It must meetthe \ref concepts::Path "Path" concept.838 ///It must conform to the \ref concepts::Path "Path" concept. 834 839 typedef lemon::Path<Digraph> Path; 835 840 }; … … 837 842 /// Default traits class used by DfsWizard 838 843 839 /// To make it easier to use Dfs algorithm 840 /// we have created a wizard class. 841 /// This \ref DfsWizard class needs default traits, 842 /// as well as the \ref Dfs class. 843 /// The \ref DfsWizardBase is a class to be the default traits of the 844 /// \ref DfsWizard class. 844 /// Default traits class used by DfsWizard. 845 /// \tparam GR The type of the digraph. 845 846 template<class GR> 846 847 class DfsWizardBase : public DfsWizardDefaultTraits<GR> … … 870 871 /// Constructor. 871 872 872 /// This constructor does not require parameters, thereforeit initiates873 /// This constructor does not require parameters, it initiates 873 874 /// all of the attributes to \c 0. 874 875 DfsWizardBase() : _g(0), _reached(0), _processed(0), _pred(0), … … 895 896 /// This class should only be used through the \ref dfs() function, 896 897 /// which makes it easier to use the algorithm. 898 /// 899 /// \tparam TR The traits class that defines various types used by the 900 /// algorithm. 897 901 template<class TR> 898 902 class DfsWizard : public TR … … 900 904 typedef TR Base; 901 905 902 ///The type of the digraph the algorithm runs on.903 906 typedef typename TR::Digraph Digraph; 904 907 … … 908 911 typedef typename Digraph::OutArcIt OutArcIt; 909 912 910 ///\brief The type of the map that stores the predecessor911 ///arcs of the DFS paths.912 913 typedef typename TR::PredMap PredMap; 913 ///\brief The type of the map that stores the distances of the nodes.914 914 typedef typename TR::DistMap DistMap; 915 ///\brief The type of the map that indicates which nodes are reached.916 915 typedef typename TR::ReachedMap ReachedMap; 917 ///\brief The type of the map that indicates which nodes are processed.918 916 typedef typename TR::ProcessedMap ProcessedMap; 919 ///The type of the DFS paths920 917 typedef typename TR::Path Path; 921 918 … … 987 984 ///Runs DFS algorithm to visit all nodes in the digraph. 988 985 989 ///This method runs DFS algorithm in order to compute990 /// the DFS path to each node.986 ///This method runs DFS algorithm in order to visit all nodes 987 ///in the digraph. 991 988 void run() 992 989 { … … 1000 997 SetPredMapBase(const TR &b) : TR(b) {} 1001 998 }; 1002 ///\brief \ref named-func-param "Named parameter" 1003 ///for setting PredMap object. 1004 /// 1005 ///\ref named-func-param "Named parameter" 1006 ///for setting PredMap object. 999 1000 ///\brief \ref named-templ-param "Named parameter" for setting 1001 ///the predecessor map. 1002 /// 1003 ///\ref named-templ-param "Named parameter" function for setting 1004 ///the map that stores the predecessor arcs of the nodes. 1007 1005 template<class T> 1008 1006 DfsWizard<SetPredMapBase<T> > predMap(const T &t) … … 1018 1016 SetReachedMapBase(const TR &b) : TR(b) {} 1019 1017 }; 1020 ///\brief \ref named-func-param "Named parameter" 1021 ///for setting ReachedMap object. 1022 /// 1023 /// \ref named-func-param "Named parameter" 1024 ///for setting ReachedMap object. 1018 1019 ///\brief \ref named-templ-param "Named parameter" for setting 1020 ///the reached map. 1021 /// 1022 ///\ref named-templ-param "Named parameter" function for setting 1023 ///the map that indicates which nodes are reached. 1025 1024 template<class T> 1026 1025 DfsWizard<SetReachedMapBase<T> > reachedMap(const T &t) … … 1036 1035 SetDistMapBase(const TR &b) : TR(b) {} 1037 1036 }; 1038 ///\brief \ref named-func-param "Named parameter" 1039 ///for setting DistMap object. 1040 /// 1041 /// \ref named-func-param "Named parameter" 1042 ///for setting DistMap object. 1037 1038 ///\brief \ref named-templ-param "Named parameter" for setting 1039 ///the distance map. 1040 /// 1041 ///\ref named-templ-param "Named parameter" function for setting 1042 ///the map that stores the distances of the nodes calculated 1043 ///by the algorithm. 1043 1044 template<class T> 1044 1045 DfsWizard<SetDistMapBase<T> > distMap(const T &t) … … 1054 1055 SetProcessedMapBase(const TR &b) : TR(b) {} 1055 1056 }; 1056 ///\brief \ref named-func-param "Named parameter" 1057 ///for setting ProcessedMap object. 1058 /// 1059 /// \ref named-func-param "Named parameter" 1060 ///for setting ProcessedMap object. 1057 1058 ///\brief \ref named-func-param "Named parameter" for setting 1059 ///the processed map. 1060 /// 1061 ///\ref named-templ-param "Named parameter" function for setting 1062 ///the map that indicates which nodes are processed. 1061 1063 template<class T> 1062 1064 DfsWizard<SetProcessedMapBase<T> > processedMap(const T &t) … … 1210 1212 /// 1211 1213 /// The type of the map that indicates which nodes are reached. 1212 /// It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept. 1214 /// It must conform to the 1215 /// \ref concepts::ReadWriteMap "ReadWriteMap" concept. 1213 1216 typedef typename Digraph::template NodeMap<bool> ReachedMap; 1214 1217 … … 1248 1251 /// does not observe the DFS events. If you want to observe the DFS 1249 1252 /// events, you should implement your own visitor class. 1250 /// \tparam TR T raits class to set various datatypes used by the1251 /// algorithm. The default traits class is1252 /// \ref DfsVisitDefaultTraits"DfsVisitDefaultTraits<GR>".1253 /// See \ref DfsVisitDefaultTraits for the documentation of1254 /// a DFS visit traits class.1253 /// \tparam TR The traits class that defines various types used by the 1254 /// algorithm. By default, it is \ref DfsVisitDefaultTraits 1255 /// "DfsVisitDefaultTraits<GR>". 1256 /// In most cases, this parameter should not be set directly, 1257 /// consider to use the named template parameters instead. 1255 1258 #ifdef DOXYGEN 1256 1259 template <typename GR, typename VS, typename TR> … … 1371 1374 /// The simplest way to execute the DFS algorithm is to use one of the 1372 1375 /// member functions called \ref run(Node) "run()".\n 1373 /// If you need more control on the execution, firstyou have to call1374 /// \ref init() , then you can add a source node with \ref addSource()1376 /// If you need better control on the execution, you have to call 1377 /// \ref init() first, then you can add a source node with \ref addSource() 1375 1378 /// and perform the actual computation with \ref start(). 1376 1379 /// This procedure can be repeated if there are nodes that have not … … 1585 1588 /// \brief Runs the algorithm to visit all nodes in the digraph. 1586 1589 1587 /// This method runs the %DFS algorithm in order to 1588 /// compute the %DFS path to each node. 1589 /// 1590 /// The algorithm computes 1591 /// - the %DFS tree (forest), 1592 /// - the distance of each node from the root(s) in the %DFS tree. 1590 /// This method runs the %DFS algorithm in order to visit all nodes 1591 /// in the digraph. 1593 1592 /// 1594 1593 /// \note <tt>d.run()</tt> is just a shortcut of the following code. … … 1622 1621 ///@{ 1623 1622 1624 /// \brief Checks if anode is reached from the root(s).1623 /// \brief Checks if the given node is reached from the root(s). 1625 1624 /// 1626 1625 /// Returns \c true if \c v is reached from the root(s). -
lemon/glpk.cc
r956 r1142 557 557 void GlpkBase::_clear() { 558 558 glp_erase_prob(lp); 559 rows.clear();560 cols.clear();561 559 } 562 560 -
lemon/glpk.cc
r1140 r1142 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-20 095 * Copyright (C) 2003-2010 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 57 57 int i = glp_add_rows(lp, 1); 58 58 glp_set_row_bnds(lp, i, GLP_FR, 0.0, 0.0); 59 return i; 60 } 61 62 int GlpkBase::_addRow(Value lo, ExprIterator b, 63 ExprIterator e, Value up) { 64 int i = glp_add_rows(lp, 1); 65 66 if (lo == -INF) { 67 if (up == INF) { 68 glp_set_row_bnds(lp, i, GLP_FR, lo, up); 69 } else { 70 glp_set_row_bnds(lp, i, GLP_UP, lo, up); 71 } 72 } else { 73 if (up == INF) { 74 glp_set_row_bnds(lp, i, GLP_LO, lo, up); 75 } else if (lo != up) { 76 glp_set_row_bnds(lp, i, GLP_DB, lo, up); 77 } else { 78 glp_set_row_bnds(lp, i, GLP_FX, lo, up); 79 } 80 } 81 82 std::vector<int> indexes; 83 std::vector<Value> values; 84 85 indexes.push_back(0); 86 values.push_back(0); 87 88 for(ExprIterator it = b; it != e; ++it) { 89 indexes.push_back(it->first); 90 values.push_back(it->second); 91 } 92 93 glp_set_mat_row(lp, i, values.size() - 1, 94 &indexes.front(), &values.front()); 59 95 return i; 60 96 } -
lemon/graph_to_eps.h
r1107 r1159 223 223 using T::_copyright; 224 224 225 using T::NodeTextColorType;225 using typename T::NodeTextColorType; 226 226 using T::CUST_COL; 227 227 using T::DIST_COL; -
lemon/graph_to_eps.h
r1157 r1159 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-20 095 * Copyright (C) 2003-2010 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 143 143 ///\param gr Reference to the graph to be printed. 144 144 ///\param ost Reference to the output stream. 145 ///By default it is <tt>std::cout</tt>.145 ///By default, it is <tt>std::cout</tt>. 146 146 ///\param pros If it is \c true, then the \c ostream referenced by \c os 147 147 ///will be explicitly deallocated by the destructor. … … 513 513 ///Turn on/off pre-scaling 514 514 515 ///By default graphToEps() rescales the whole image in order to avoid515 ///By default, graphToEps() rescales the whole image in order to avoid 516 516 ///very big or very small bounding boxes. 517 517 /// … … 1115 1115 ///\param g Reference to the graph to be printed. 1116 1116 ///\param os Reference to the output stream. 1117 ///By default it is <tt>std::cout</tt>.1117 ///By default, it is <tt>std::cout</tt>. 1118 1118 /// 1119 1119 ///This function also has a lot of … … 1127 1127 ///\endcode 1128 1128 /// 1129 ///For more detailed examples see the \ref graph_to_eps_demo.cc demo file.1129 ///For more detailed examples, see the \ref graph_to_eps_demo.cc demo file. 1130 1130 /// 1131 1131 ///\warning Don't forget to put the \ref GraphToEps::run() "run()" -
lemon/lp_base.h
r1094 r1143 1557 1557 1558 1558 ///Clears the problem 1559 void clear() { _clear(); }1559 void clear() { _clear(); rows.clear(); cols.clear(); } 1560 1560 1561 1561 /// Sets the message level of the solver -
lemon/lp_base.h
r1140 r1143 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-20 085 * Copyright (C) 2003-2010 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 83 83 MESSAGE_VERBOSE 84 84 }; 85 85 86 86 87 87 ///The floating point type used by the solver … … 115 115 typedef True LpCol; 116 116 /// Default constructor 117 117 118 118 /// \warning The default constructor sets the Col to an 119 119 /// undefined value. 120 120 Col() {} 121 121 /// Invalid constructor \& conversion. 122 122 123 123 /// This constructor initializes the Col to be invalid. 124 /// \sa Invalid for more details. 124 /// \sa Invalid for more details. 125 125 Col(const Invalid&) : _id(-1) {} 126 126 /// Equality operator … … 147 147 ///Iterator for iterate over the columns of an LP problem 148 148 149 /// Its usage is quite simple, for example you can count the number149 /// Its usage is quite simple, for example, you can count the number 150 150 /// of columns in an LP \c lp: 151 151 ///\code … … 157 157 public: 158 158 /// Default constructor 159 159 160 160 /// \warning The default constructor sets the iterator 161 161 /// to an undefined value. 162 162 ColIt() {} 163 163 /// Sets the iterator to the first Col 164 164 165 165 /// Sets the iterator to the first Col. 166 166 /// … … 170 170 } 171 171 /// Invalid constructor \& conversion 172 172 173 173 /// Initialize the iterator to be invalid. 174 174 /// \sa Invalid for more details. 175 175 ColIt(const Invalid&) : Col(INVALID) {} 176 176 /// Next column 177 177 178 178 /// Assign the iterator to the next column. 179 179 /// … … 210 210 typedef True LpRow; 211 211 /// Default constructor 212 212 213 213 /// \warning The default constructor sets the Row to an 214 214 /// undefined value. 215 215 Row() {} 216 216 /// Invalid constructor \& conversion. 217 217 218 218 /// This constructor initializes the Row to be invalid. 219 /// \sa Invalid for more details. 219 /// \sa Invalid for more details. 220 220 Row(const Invalid&) : _id(-1) {} 221 221 /// Equality operator … … 225 225 bool operator==(Row r) const {return _id == r._id;} 226 226 /// Inequality operator 227 227 228 228 /// \sa operator==(Row r) 229 229 /// … … 242 242 ///Iterator for iterate over the rows of an LP problem 243 243 244 /// Its usage is quite simple, for example you can count the number244 /// Its usage is quite simple, for example, you can count the number 245 245 /// of rows in an LP \c lp: 246 246 ///\code … … 252 252 public: 253 253 /// Default constructor 254 254 255 255 /// \warning The default constructor sets the iterator 256 256 /// to an undefined value. 257 257 RowIt() {} 258 258 /// Sets the iterator to the first Row 259 259 260 260 /// Sets the iterator to the first Row. 261 261 /// … … 265 265 } 266 266 /// Invalid constructor \& conversion 267 267 268 268 /// Initialize the iterator to be invalid. 269 269 /// \sa Invalid for more details. 270 270 RowIt(const Invalid&) : Row(INVALID) {} 271 271 /// Next row 272 272 273 273 /// Assign the iterator to the next row. 274 274 /// … … 348 348 typedef True SolverExpr; 349 349 /// Default constructor 350 350 351 351 /// Construct an empty expression, the coefficients and 352 352 /// the constant component are initialized to zero. … … 449 449 450 450 ///Iterator over the expression 451 452 ///The iterator iterates over the terms of the expression. 453 /// 451 452 ///The iterator iterates over the terms of the expression. 453 /// 454 454 ///\code 455 455 ///double s=0; … … 465 465 466 466 /// Sets the iterator to the first term 467 467 468 468 /// Sets the iterator to the first term of the expression. 469 469 /// … … 482 482 const Value& operator*() const { return _it->second; } 483 483 /// Next term 484 484 485 485 /// Assign the iterator to the next term. 486 486 /// … … 494 494 495 495 /// Const iterator over the expression 496 497 ///The iterator iterates over the terms of the expression. 498 /// 496 497 ///The iterator iterates over the terms of the expression. 498 /// 499 499 ///\code 500 500 ///double s=0; … … 510 510 511 511 /// Sets the iterator to the first term 512 512 513 513 /// Sets the iterator to the first term of the expression. 514 514 /// … … 525 525 526 526 /// Next term 527 527 528 528 /// Assign the iterator to the next term. 529 529 /// … … 674 674 typedef True SolverExpr; 675 675 /// Default constructor 676 676 677 677 /// Construct an empty expression, the coefficients are 678 678 /// initialized to zero. … … 709 709 } 710 710 /// \brief Removes the coefficients which's absolute value does 711 /// not exceed \c epsilon. 711 /// not exceed \c epsilon. 712 712 void simplify(Value epsilon = 0.0) { 713 713 std::map<int, Value>::iterator it=comps.begin(); … … 758 758 759 759 ///Iterator over the expression 760 761 ///The iterator iterates over the terms of the expression. 762 /// 760 761 ///The iterator iterates over the terms of the expression. 762 /// 763 763 ///\code 764 764 ///double s=0; … … 774 774 775 775 /// Sets the iterator to the first term 776 776 777 777 /// Sets the iterator to the first term of the expression. 778 778 /// … … 792 792 793 793 /// Next term 794 794 795 795 /// Assign the iterator to the next term. 796 796 /// … … 804 804 805 805 ///Iterator over the expression 806 807 ///The iterator iterates over the terms of the expression. 808 /// 806 807 ///The iterator iterates over the terms of the expression. 808 /// 809 809 ///\code 810 810 ///double s=0; … … 820 820 821 821 /// Sets the iterator to the first term 822 822 823 823 /// Sets the iterator to the first term of the expression. 824 824 /// … … 835 835 836 836 /// Next term 837 837 838 838 /// Assign the iterator to the next term. 839 839 /// … … 943 943 virtual int _addCol() = 0; 944 944 virtual int _addRow() = 0; 945 946 virtual int _addRow(Value l, ExprIterator b, ExprIterator e, Value u) { 947 int row = _addRow(); 948 _setRowCoeffs(row, b, e); 949 _setRowLowerBound(row, l); 950 _setRowUpperBound(row, u); 951 return row; 952 } 945 953 946 954 virtual void _eraseCol(int col) = 0; … … 1208 1216 ///\return The created row. 1209 1217 Row addRow(Value l,const Expr &e, Value u) { 1210 Row r=addRow(); 1211 row(r,l,e,u); 1218 Row r; 1219 e.simplify(); 1220 r._id = _addRowId(_addRow(l - *e, ExprIterator(e.comps.begin(), cols), 1221 ExprIterator(e.comps.end(), cols), u - *e)); 1212 1222 return r; 1213 1223 } … … 1218 1228 ///\return The created row. 1219 1229 Row addRow(const Constr &c) { 1220 Row r=addRow(); 1221 row(r,c); 1230 Row r; 1231 c.expr().simplify(); 1232 r._id = _addRowId(_addRow(c.lowerBounded()?c.lowerBound()-*c.expr():-INF, 1233 ExprIterator(c.expr().comps.begin(), cols), 1234 ExprIterator(c.expr().comps.end(), cols), 1235 c.upperBounded()?c.upperBound()-*c.expr():INF)); 1222 1236 return r; 1223 1237 } … … 1804 1818 enum VarStatus { 1805 1819 /// The variable is in the basis 1806 BASIC, 1820 BASIC, 1807 1821 /// The variable is free, but not basic 1808 1822 FREE, 1809 /// The variable has active lower bound 1823 /// The variable has active lower bound 1810 1824 LOWER, 1811 1825 /// The variable has active upper bound … … 1886 1900 } 1887 1901 /// Returns a component of the primal ray 1888 1902 1889 1903 /// The primal ray is solution of the modified primal problem, 1890 1904 /// where we change each finite bound to 0, and we looking for a … … 1920 1934 1921 1935 /// Returns a component of the dual ray 1922 1936 1923 1937 /// The dual ray is solution of the modified primal problem, where 1924 1938 /// we change each finite bound to 0 (i.e. the objective function … … 2062 2076 } 2063 2077 ///The value of the objective function 2064 2078 2065 2079 ///\return 2066 2080 ///- \ref INF or -\ref INF means either infeasibility or unboundedness -
lemon/path.h
r956 r1146 65 65 Path() {} 66 66 67 /// \brief Copy constructor 68 /// 69 Path(const Path& cpath) { 70 pathCopy(cpath, *this); 71 } 72 67 73 /// \brief Template copy constructor 68 74 /// … … 72 78 Path(const CPath& cpath) { 73 79 pathCopy(cpath, *this); 80 } 81 82 /// \brief Copy assignment 83 /// 84 Path& operator=(const Path& cpath) { 85 pathCopy(cpath, *this); 86 return *this; 74 87 } 75 88 … … 253 266 SimplePath() {} 254 267 268 /// \brief Copy constructor 269 /// 270 SimplePath(const SimplePath& cpath) { 271 pathCopy(cpath, *this); 272 } 273 255 274 /// \brief Template copy constructor 256 275 /// … … 260 279 SimplePath(const CPath& cpath) { 261 280 pathCopy(cpath, *this); 281 } 282 283 /// \brief Copy assignment 284 /// 285 SimplePath& operator=(const SimplePath& cpath) { 286 pathCopy(cpath, *this); 287 return *this; 262 288 } 263 289 … … 432 458 ListPath() : first(0), last(0) {} 433 459 460 /// \brief Copy constructor 461 /// 462 ListPath(const ListPath& cpath) : first(0), last(0) { 463 pathCopy(cpath, *this); 464 } 465 434 466 /// \brief Template copy constructor 435 467 /// … … 446 478 ~ListPath() { 447 479 clear(); 480 } 481 482 /// \brief Copy assignment 483 /// 484 ListPath& operator=(const ListPath& cpath) { 485 pathCopy(cpath, *this); 486 return *this; 448 487 } 449 488 … … 759 798 StaticPath() : len(0), arcs(0) {} 760 799 800 /// \brief Copy constructor 801 /// 802 StaticPath(const StaticPath& cpath) : arcs(0) { 803 pathCopy(cpath, *this); 804 } 805 761 806 /// \brief Template copy constructor 762 807 /// … … 772 817 ~StaticPath() { 773 818 if (arcs) delete[] arcs; 819 } 820 821 /// \brief Copy assignment 822 /// 823 StaticPath& operator=(const StaticPath& cpath) { 824 pathCopy(cpath, *this); 825 return *this; 774 826 } 775 827 -
lemon/path.h
r1144 r1146 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-20 095 * Copyright (C) 2003-2010 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 1019 1019 }; 1020 1020 1021 1021 1022 1022 template <typename From, typename To, 1023 1023 bool revEnable = RevPathTagIndicator<From>::value> … … 1025 1025 static void copy(const From& from, To& to) { 1026 1026 PathCopySelectorForward<From, To>::copy(from, to); 1027 } 1027 } 1028 1028 }; 1029 1029 … … 1032 1032 static void copy(const From& from, To& to) { 1033 1033 PathCopySelectorBackward<From, To>::copy(from, to); 1034 } 1034 } 1035 1035 }; 1036 1036 -
test/CMakeLists.txt
r1107 r1159 14 14 SET(TESTS 15 15 adaptors_test 16 arc_look_up_test 16 17 bellman_ford_test 17 18 bfs_test … … 87 88 GET_FILENAME_COMPONENT(TARGET_PATH ${TARGET_LOC} PATH) 88 89 ADD_CUSTOM_COMMAND(TARGET lp_test POST_BUILD 89 COMMAND ${CMAKE_COMMAND} -E copy ${CPLEX_BIN_DIR}/cplex 91.dll ${TARGET_PATH}90 COMMAND ${CMAKE_COMMAND} -E copy ${CPLEX_BIN_DIR}/cplex.dll ${TARGET_PATH} 90 91 ) 91 92 ENDIF() … … 129 130 GET_FILENAME_COMPONENT(TARGET_PATH ${TARGET_LOC} PATH) 130 131 ADD_CUSTOM_COMMAND(TARGET mip_test POST_BUILD 131 COMMAND ${CMAKE_COMMAND} -E copy ${CPLEX_BIN_DIR}/cplex 91.dll ${TARGET_PATH}132 COMMAND ${CMAKE_COMMAND} -E copy ${CPLEX_BIN_DIR}/cplex.dll ${TARGET_PATH} 132 133 ) 133 134 ENDIF() -
test/CMakeLists.txt
r1149 r1159 15 15 adaptors_test 16 16 arc_look_up_test 17 bellman_ford_test 17 18 bfs_test 18 19 circulation_test … … 26 27 error_test 27 28 euler_test 29 fractional_matching_test 28 30 gomory_hu_test 29 31 graph_copy_test … … 38 40 min_cost_arborescence_test 39 41 min_cost_flow_test 42 min_mean_cycle_test 40 43 path_test 44 planarity_test 41 45 preflow_test 42 46 radix_sort_test -
test/adaptors_test.cc
r1153 r1159 66 66 Digraph::Arc a2 = digraph.addArc(n1, n3); 67 67 Digraph::Arc a3 = digraph.addArc(n2, n3); 68 ignore_unused_variable_warning(a3); 68 69 69 70 // Check the adaptor … … 100 101 Adaptor::Arc a7 = adaptor.addArc(n1, n4); 101 102 Adaptor::Arc a8 = adaptor.addArc(n1, n2); 103 ignore_unused_variable_warning(a6,a7,a8); 102 104 103 105 adaptor.erase(a1); … … 759 761 Digraph::Arc a2 = digraph.addArc(n1, n3); 760 762 Digraph::Arc a3 = digraph.addArc(n2, n3); 763 ignore_unused_variable_warning(a1,a2,a3); 761 764 762 765 checkGraphNodeList(adaptor, 6); -
test/adaptors_test.cc
r1157 r1159 1375 1375 1376 1376 GridGraph::EdgeMap<bool> dir_map(graph); 1377 dir_map[graph.right(n1)] = graph.u(graph.right(n1)) == n1;1378 dir_map[graph.up(n1)] = graph.u(graph.up(n1)) != n1;1379 dir_map[graph.left(n4)] = graph.u(graph.left(n4)) != n4;1380 dir_map[graph.down(n4)] = graph.u(graph.down(n4)) != n4;1377 dir_map[graph.right(n1)] = graph.u(graph.right(n1)) != n1; 1378 dir_map[graph.up(n1)] = graph.u(graph.up(n1)) == n1; 1379 dir_map[graph.left(n4)] = graph.u(graph.left(n4)) == n4; 1380 dir_map[graph.down(n4)] = graph.u(graph.down(n4)) == n4; 1381 1381 1382 1382 // Apply several adaptors on the grid graph 1383 typedef SplitNodes< ReverseDigraph< const Orienter< 1384 const GridGraph, GridGraph::EdgeMap<bool> > > > 1385 RevSplitGridGraph; 1386 typedef ReverseDigraph<const RevSplitGridGraph> SplitGridGraph; 1383 typedef Orienter< const GridGraph, GridGraph::EdgeMap<bool> > 1384 OrientedGridGraph; 1385 typedef SplitNodes<OrientedGridGraph> SplitGridGraph; 1387 1386 typedef Undirector<const SplitGridGraph> USplitGridGraph; 1388 typedef Undirector<const USplitGridGraph> UUSplitGridGraph;1389 checkConcept<concepts::Digraph, RevSplitGridGraph>();1390 1387 checkConcept<concepts::Digraph, SplitGridGraph>(); 1391 1388 checkConcept<concepts::Graph, USplitGridGraph>(); 1392 checkConcept<concepts::Graph, UUSplitGridGraph>(); 1393 1394 RevSplitGridGraph rev_adaptor = 1395 splitNodes(reverseDigraph(orienter(graph, dir_map))); 1396 SplitGridGraph adaptor = reverseDigraph(rev_adaptor); 1389 1390 OrientedGridGraph oadaptor = orienter(graph, dir_map); 1391 SplitGridGraph adaptor = splitNodes(oadaptor); 1397 1392 USplitGridGraph uadaptor = undirector(adaptor); 1398 UUSplitGridGraph uuadaptor = undirector(uadaptor);1399 1393 1400 1394 // Check adaptor … … 1403 1397 checkGraphConArcList(adaptor, 8); 1404 1398 1405 checkGraphOutArcList(adaptor, rev_adaptor.inNode(n1), 1);1406 checkGraphOutArcList(adaptor, rev_adaptor.outNode(n1), 1);1407 checkGraphOutArcList(adaptor, rev_adaptor.inNode(n2), 2);1408 checkGraphOutArcList(adaptor, rev_adaptor.outNode(n2), 1);1409 checkGraphOutArcList(adaptor, rev_adaptor.inNode(n3), 1);1410 checkGraphOutArcList(adaptor, rev_adaptor.outNode(n3), 1);1411 checkGraphOutArcList(adaptor, rev_adaptor.inNode(n4), 0);1412 checkGraphOutArcList(adaptor, rev_adaptor.outNode(n4), 1);1413 1414 checkGraphInArcList(adaptor, rev_adaptor.inNode(n1), 1);1415 checkGraphInArcList(adaptor, rev_adaptor.outNode(n1), 1);1416 checkGraphInArcList(adaptor, rev_adaptor.inNode(n2), 1);1417 checkGraphInArcList(adaptor, rev_adaptor.outNode(n2), 0);1418 checkGraphInArcList(adaptor, rev_adaptor.inNode(n3), 1);1419 checkGraphInArcList(adaptor, rev_adaptor.outNode(n3), 1);1420 checkGraphInArcList(adaptor, rev_adaptor.inNode(n4), 1);1421 checkGraphInArcList(adaptor, rev_adaptor.outNode(n4), 2);1399 checkGraphOutArcList(adaptor, adaptor.inNode(n1), 1); 1400 checkGraphOutArcList(adaptor, adaptor.outNode(n1), 1); 1401 checkGraphOutArcList(adaptor, adaptor.inNode(n2), 1); 1402 checkGraphOutArcList(adaptor, adaptor.outNode(n2), 0); 1403 checkGraphOutArcList(adaptor, adaptor.inNode(n3), 1); 1404 checkGraphOutArcList(adaptor, adaptor.outNode(n3), 1); 1405 checkGraphOutArcList(adaptor, adaptor.inNode(n4), 1); 1406 checkGraphOutArcList(adaptor, adaptor.outNode(n4), 2); 1407 1408 checkGraphInArcList(adaptor, adaptor.inNode(n1), 1); 1409 checkGraphInArcList(adaptor, adaptor.outNode(n1), 1); 1410 checkGraphInArcList(adaptor, adaptor.inNode(n2), 2); 1411 checkGraphInArcList(adaptor, adaptor.outNode(n2), 1); 1412 checkGraphInArcList(adaptor, adaptor.inNode(n3), 1); 1413 checkGraphInArcList(adaptor, adaptor.outNode(n3), 1); 1414 checkGraphInArcList(adaptor, adaptor.inNode(n4), 0); 1415 checkGraphInArcList(adaptor, adaptor.outNode(n4), 1); 1422 1416 1423 1417 checkNodeIds(adaptor); … … 1442 1436 checkGraphArcMap(uadaptor); 1443 1437 1444 checkGraphIncEdgeArcLists(uadaptor, rev_adaptor.inNode(n1), 2); 1445 checkGraphIncEdgeArcLists(uadaptor, rev_adaptor.outNode(n1), 2); 1446 checkGraphIncEdgeArcLists(uadaptor, rev_adaptor.inNode(n2), 3); 1447 checkGraphIncEdgeArcLists(uadaptor, rev_adaptor.outNode(n2), 1); 1448 checkGraphIncEdgeArcLists(uadaptor, rev_adaptor.inNode(n3), 2); 1449 checkGraphIncEdgeArcLists(uadaptor, rev_adaptor.outNode(n3), 2); 1450 checkGraphIncEdgeArcLists(uadaptor, rev_adaptor.inNode(n4), 1); 1451 checkGraphIncEdgeArcLists(uadaptor, rev_adaptor.outNode(n4), 3); 1452 1453 // Check uuadaptor 1454 checkGraphNodeList(uuadaptor, 8); 1455 checkGraphEdgeList(uuadaptor, 16); 1456 checkGraphArcList(uuadaptor, 32); 1457 checkGraphConEdgeList(uuadaptor, 16); 1458 checkGraphConArcList(uuadaptor, 32); 1459 1460 checkNodeIds(uuadaptor); 1461 checkEdgeIds(uuadaptor); 1462 checkArcIds(uuadaptor); 1463 1464 checkGraphNodeMap(uuadaptor); 1465 checkGraphEdgeMap(uuadaptor); 1466 checkGraphArcMap(uuadaptor); 1438 checkGraphIncEdgeArcLists(uadaptor, adaptor.inNode(n1), 2); 1439 checkGraphIncEdgeArcLists(uadaptor, adaptor.outNode(n1), 2); 1440 checkGraphIncEdgeArcLists(uadaptor, adaptor.inNode(n2), 3); 1441 checkGraphIncEdgeArcLists(uadaptor, adaptor.outNode(n2), 1); 1442 checkGraphIncEdgeArcLists(uadaptor, adaptor.inNode(n3), 2); 1443 checkGraphIncEdgeArcLists(uadaptor, adaptor.outNode(n3), 2); 1444 checkGraphIncEdgeArcLists(uadaptor, adaptor.inNode(n4), 1); 1445 checkGraphIncEdgeArcLists(uadaptor, adaptor.outNode(n4), 3); 1467 1446 } 1468 1447 -
test/connectivity_test.cc
r956 r1159 69 69 Graph g(d); 70 70 Digraph::Node n = d.addNode(); 71 ignore_unused_variable_warning(n); 71 72 72 73 check(stronglyConnected(d), "This digraph is strongly connected"); … … 246 247 Digraph::Node watch = d.addNode(); 247 248 Digraph::Node pants = d.addNode(); 249 ignore_unused_variable_warning(watch); 248 250 249 251 d.addArc(socks, shoe); -
test/connectivity_test.cc
r1157 r1159 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-20 095 * Copyright (C) 2003-2010 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 30 30 typedef ListDigraph Digraph; 31 31 typedef Undirector<Digraph> Graph; 32 33 { 34 Digraph d; 35 Digraph::NodeMap<int> order(d); 36 Graph g(d); 37 32 33 { 34 Digraph d; 35 Digraph::NodeMap<int> order(d); 36 Graph g(d); 37 38 38 check(stronglyConnected(d), "The empty digraph is strongly connected"); 39 39 check(countStronglyConnectedComponents(d) == 0, … … 49 49 check(countBiEdgeConnectedComponents(g) == 0, 50 50 "The empty graph has 0 bi-edge-connected component"); 51 51 52 52 check(dag(d), "The empty digraph is DAG."); 53 53 check(checkedTopologicalSort(d, order), "The empty digraph is DAG."); … … 84 84 check(countBiEdgeConnectedComponents(g) == 1, 85 85 "This graph has 1 bi-edge-connected component"); 86 86 87 87 check(dag(d), "This digraph is DAG."); 88 88 check(checkedTopologicalSort(d, order), "This digraph is DAG."); … … 103 103 Digraph::NodeMap<int> order(d); 104 104 Graph g(d); 105 105 106 106 Digraph::Node n1 = d.addNode(); 107 107 Digraph::Node n2 = d.addNode(); … … 110 110 Digraph::Node n5 = d.addNode(); 111 111 Digraph::Node n6 = d.addNode(); 112 112 113 113 d.addArc(n1, n3); 114 114 d.addArc(n3, n2); … … 138 138 check(!parallelFree(g), "This graph is not parallel-free."); 139 139 check(!simpleGraph(g), "This graph is not simple."); 140 140 141 141 d.addArc(n3, n3); 142 142 143 143 check(!loopFree(d), "This digraph is not loop-free."); 144 144 check(!loopFree(g), "This graph is not loop-free."); 145 145 check(!simpleGraph(d), "This digraph is not simple."); 146 146 147 147 d.addArc(n3, n2); 148 148 149 149 check(!parallelFree(d), "This digraph is not parallel-free."); 150 150 } 151 151 152 152 { 153 153 Digraph d; 154 154 Digraph::ArcMap<bool> cutarcs(d, false); 155 155 Graph g(d); 156 156 157 157 Digraph::Node n1 = d.addNode(); 158 158 Digraph::Node n2 = d.addNode(); … … 174 174 d.addArc(n6, n7); 175 175 d.addArc(n7, n6); 176 176 177 177 check(!stronglyConnected(d), "This digraph is not strongly connected"); 178 178 check(countStronglyConnectedComponents(d) == 3, … … 237 237 Digraph d; 238 238 Digraph::NodeMap<int> order(d); 239 239 240 240 Digraph::Node belt = d.addNode(); 241 241 Digraph::Node trousers = d.addNode(); … … 258 258 d.addArc(shirt, necktie); 259 259 d.addArc(necktie, coat); 260 260 261 261 check(dag(d), "This digraph is DAG."); 262 262 topologicalSort(d, order); … … 270 270 ListGraph g; 271 271 ListGraph::NodeMap<bool> map(g); 272 272 273 273 ListGraph::Node n1 = g.addNode(); 274 274 ListGraph::Node n2 = g.addNode(); … … 286 286 g.addEdge(n4, n7); 287 287 g.addEdge(n5, n7); 288 288 289 289 check(bipartite(g), "This graph is bipartite"); 290 290 check(bipartitePartitions(g, map), "This graph is bipartite"); 291 291 292 292 check(map[n1] == map[n2] && map[n1] == map[n6] && map[n1] == map[n7], 293 293 "Wrong bipartitePartitions()"); -
test/digraph_test.cc
r956 r1159 65 65 a3 = G.addArc(n2, n3), 66 66 a4 = G.addArc(n2, n3); 67 ignore_unused_variable_warning(a2,a3,a4); 67 68 68 69 checkGraphNodeList(G, 3); … … 93 94 Arc a1 = G.addArc(n1, n2), a2 = G.addArc(n2, n1), 94 95 a3 = G.addArc(n2, n3), a4 = G.addArc(n2, n3); 96 ignore_unused_variable_warning(a1,a2,a3,a4); 95 97 96 98 Node n4 = G.split(n2); … … 126 128 a3 = G.addArc(n4, n3), a4 = G.addArc(n4, n3), 127 129 a5 = G.addArc(n2, n4); 130 ignore_unused_variable_warning(a1,a2,a3,a5); 128 131 129 132 checkGraphNodeList(G, 4); … … 205 208 a3 = G.addArc(n4, n3), a4 = G.addArc(n3, n1), 206 209 a5 = G.addArc(n2, n4); 210 ignore_unused_variable_warning(a2,a3,a4,a5); 207 211 208 212 // Check arc deletion … … 252 256 Arc a1 = G.addArc(n1, n2), a2 = G.addArc(n2, n1), 253 257 a3 = G.addArc(n2, n3), a4 = G.addArc(n2, n3); 258 ignore_unused_variable_warning(a1,a2,a3,a4); 254 259 255 260 typename Digraph::Snapshot snapshot(G); … … 352 357 e1 = g.addArc(n1, n2), 353 358 e2 = g.addArc(n2, n3); 359 ignore_unused_variable_warning(e2); 354 360 355 361 check(g.valid(n1), "Wrong validity check"); -
test/digraph_test.cc
r1157 r1159 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-20 095 * Copyright (C) 2003-2010 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 20 20 #include <lemon/list_graph.h> 21 21 #include <lemon/smart_graph.h> 22 #include <lemon/static_graph.h> 22 23 #include <lemon/full_graph.h> 23 24 … … 35 36 checkGraphNodeList(G, 0); 36 37 checkGraphArcList(G, 0); 38 39 G.reserveNode(3); 40 G.reserveArc(4); 37 41 38 42 Node … … 289 293 290 294 snapshot.restore(); 295 snapshot.save(G); 296 297 checkGraphNodeList(G, 4); 298 checkGraphArcList(G, 4); 299 300 G.addArc(G.addNode(), G.addNode()); 301 302 snapshot.restore(); 291 303 292 304 checkGraphNodeList(G, 4); … … 323 335 checkConcept<ClearableDigraphComponent<>, SmartDigraph>(); 324 336 } 337 { // Checking StaticDigraph 338 checkConcept<Digraph, StaticDigraph>(); 339 checkConcept<ClearableDigraphComponent<>, StaticDigraph>(); 340 } 325 341 { // Checking FullDigraph 326 342 checkConcept<Digraph, FullDigraph>(); … … 379 395 } 380 396 397 void checkStaticDigraph() { 398 SmartDigraph g; 399 SmartDigraph::NodeMap<StaticDigraph::Node> nref(g); 400 SmartDigraph::ArcMap<StaticDigraph::Arc> aref(g); 401 402 StaticDigraph G; 403 404 checkGraphNodeList(G, 0); 405 checkGraphArcList(G, 0); 406 407 G.build(g, nref, aref); 408 409 checkGraphNodeList(G, 0); 410 checkGraphArcList(G, 0); 411 412 SmartDigraph::Node 413 n1 = g.addNode(), 414 n2 = g.addNode(), 415 n3 = g.addNode(); 416 417 G.build(g, nref, aref); 418 419 checkGraphNodeList(G, 3); 420 checkGraphArcList(G, 0); 421 422 SmartDigraph::Arc a1 = g.addArc(n1, n2); 423 424 G.build(g, nref, aref); 425 426 check(G.source(aref[a1]) == nref[n1] && G.target(aref[a1]) == nref[n2], 427 "Wrong arc or wrong references"); 428 checkGraphNodeList(G, 3); 429 checkGraphArcList(G, 1); 430 431 checkGraphOutArcList(G, nref[n1], 1); 432 checkGraphOutArcList(G, nref[n2], 0); 433 checkGraphOutArcList(G, nref[n3], 0); 434 435 checkGraphInArcList(G, nref[n1], 0); 436 checkGraphInArcList(G, nref[n2], 1); 437 checkGraphInArcList(G, nref[n3], 0); 438 439 checkGraphConArcList(G, 1); 440 441 SmartDigraph::Arc 442 a2 = g.addArc(n2, n1), 443 a3 = g.addArc(n2, n3), 444 a4 = g.addArc(n2, n3); 445 446 digraphCopy(g, G).nodeRef(nref).run(); 447 448 checkGraphNodeList(G, 3); 449 checkGraphArcList(G, 4); 450 451 checkGraphOutArcList(G, nref[n1], 1); 452 checkGraphOutArcList(G, nref[n2], 3); 453 checkGraphOutArcList(G, nref[n3], 0); 454 455 checkGraphInArcList(G, nref[n1], 1); 456 checkGraphInArcList(G, nref[n2], 1); 457 checkGraphInArcList(G, nref[n3], 2); 458 459 checkGraphConArcList(G, 4); 460 461 std::vector<std::pair<int,int> > arcs; 462 arcs.push_back(std::make_pair(0,1)); 463 arcs.push_back(std::make_pair(0,2)); 464 arcs.push_back(std::make_pair(1,3)); 465 arcs.push_back(std::make_pair(1,2)); 466 arcs.push_back(std::make_pair(3,0)); 467 arcs.push_back(std::make_pair(3,3)); 468 arcs.push_back(std::make_pair(4,2)); 469 arcs.push_back(std::make_pair(4,3)); 470 arcs.push_back(std::make_pair(4,1)); 471 472 G.build(6, arcs.begin(), arcs.end()); 473 474 checkGraphNodeList(G, 6); 475 checkGraphArcList(G, 9); 476 477 checkGraphOutArcList(G, G.node(0), 2); 478 checkGraphOutArcList(G, G.node(1), 2); 479 checkGraphOutArcList(G, G.node(2), 0); 480 checkGraphOutArcList(G, G.node(3), 2); 481 checkGraphOutArcList(G, G.node(4), 3); 482 checkGraphOutArcList(G, G.node(5), 0); 483 484 checkGraphInArcList(G, G.node(0), 1); 485 checkGraphInArcList(G, G.node(1), 2); 486 checkGraphInArcList(G, G.node(2), 3); 487 checkGraphInArcList(G, G.node(3), 3); 488 checkGraphInArcList(G, G.node(4), 0); 489 checkGraphInArcList(G, G.node(5), 0); 490 491 checkGraphConArcList(G, 9); 492 493 checkNodeIds(G); 494 checkArcIds(G); 495 checkGraphNodeMap(G); 496 checkGraphArcMap(G); 497 498 int n = G.nodeNum(); 499 int m = G.arcNum(); 500 check(G.index(G.node(n-1)) == n-1, "Wrong index."); 501 check(G.index(G.arc(m-1)) == m-1, "Wrong index."); 502 } 503 381 504 void checkFullDigraph(int num) { 382 505 typedef FullDigraph Digraph; 383 506 DIGRAPH_TYPEDEFS(Digraph); 507 384 508 Digraph G(num); 509 check(G.nodeNum() == num && G.arcNum() == num * num, "Wrong size"); 510 511 G.resize(num); 512 check(G.nodeNum() == num && G.arcNum() == num * num, "Wrong size"); 385 513 386 514 checkGraphNodeList(G, num); … … 426 554 checkDigraphValidity<SmartDigraph>(); 427 555 } 556 { // Checking StaticDigraph 557 checkStaticDigraph(); 558 } 428 559 { // Checking FullDigraph 429 560 checkFullDigraph(8); -
test/edge_set_test.cc
r956 r1159 45 45 46 46 Digraph::Arc ga1 = digraph.addArc(n1, n2); 47 ignore_unused_variable_warning(ga1); 47 48 48 49 ArcSet arc_set(digraph); 49 50 50 51 Digraph::Arc ga2 = digraph.addArc(n2, n1); 52 ignore_unused_variable_warning(ga2); 51 53 52 54 checkGraphNodeList(arc_set, 2); … … 76 78 a3 = arc_set.addArc(n2, n3), 77 79 a4 = arc_set.addArc(n2, n3); 80 ignore_unused_variable_warning(a2,a3,a4); 81 78 82 checkGraphNodeList(arc_set, 3); 79 83 checkGraphArcList(arc_set, 4); … … 111 115 112 116 Digraph::Arc ga1 = digraph.addArc(n1, n2); 117 ignore_unused_variable_warning(ga1); 113 118 114 119 ArcSet arc_set(digraph); 115 120 116 121 Digraph::Arc ga2 = digraph.addArc(n2, n1); 122 ignore_unused_variable_warning(ga2); 117 123 118 124 checkGraphNodeList(arc_set, 2); … … 142 148 a3 = arc_set.addArc(n2, n3), 143 149 a4 = arc_set.addArc(n2, n3); 150 ignore_unused_variable_warning(a2,a3,a4); 151 144 152 checkGraphNodeList(arc_set, 3); 145 153 checkGraphArcList(arc_set, 4); … … 191 199 192 200 Digraph::Arc ga1 = digraph.addArc(n1, n2); 201 ignore_unused_variable_warning(ga1); 193 202 194 203 EdgeSet edge_set(digraph); 195 204 196 205 Digraph::Arc ga2 = digraph.addArc(n2, n1); 206 ignore_unused_variable_warning(ga2); 197 207 198 208 checkGraphNodeList(edge_set, 2); … … 231 241 e3 = edge_set.addEdge(n2, n3), 232 242 e4 = edge_set.addEdge(n2, n3); 243 ignore_unused_variable_warning(e2,e3,e4); 244 233 245 checkGraphNodeList(edge_set, 3); 234 246 checkGraphEdgeList(edge_set, 4); … … 275 287 276 288 Digraph::Arc ga1 = digraph.addArc(n1, n2); 289 ignore_unused_variable_warning(ga1); 277 290 278 291 EdgeSet edge_set(digraph); 279 292 280 293 Digraph::Arc ga2 = digraph.addArc(n2, n1); 294 ignore_unused_variable_warning(ga2); 281 295 282 296 checkGraphNodeList(edge_set, 2); … … 315 329 e3 = edge_set.addEdge(n2, n3), 316 330 e4 = edge_set.addEdge(n2, n3); 331 ignore_unused_variable_warning(e2,e3,e4); 332 317 333 checkGraphNodeList(edge_set, 3); 318 334 checkGraphEdgeList(edge_set, 4); -
test/edge_set_test.cc
r1157 r1159 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-20 085 * Copyright (C) 2003-2010 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). -
test/euler_test.cc
r956 r1159 102 102 Graph g(d); 103 103 Digraph::Node n = d.addNode(); 104 104 ignore_unused_variable_warning(n); 105 105 106 checkDiEulerIt(d); 106 107 checkDiEulerIt(g); … … 190 191 Digraph::Node n4 = d.addNode(); 191 192 Digraph::Node n5 = d.addNode(); 193 ignore_unused_variable_warning(n0,n4,n5); 192 194 193 195 d.addArc(n1, n2); -
test/euler_test.cc
r1157 r1159 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-20 095 * Copyright (C) 2003-2010 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 86 86 typedef ListDigraph Digraph; 87 87 typedef Undirector<Digraph> Graph; 88 89 { 90 Digraph d; 91 Graph g(d); 92 88 89 { 90 Digraph d; 91 Graph g(d); 92 93 93 checkDiEulerIt(d); 94 94 checkDiEulerIt(g); … … 130 130 Digraph::Node n2 = d.addNode(); 131 131 Digraph::Node n3 = d.addNode(); 132 132 133 133 d.addArc(n1, n2); 134 134 d.addArc(n2, n1); … … 155 155 Digraph::Node n5 = d.addNode(); 156 156 Digraph::Node n6 = d.addNode(); 157 157 158 158 d.addArc(n1, n2); 159 159 d.addArc(n2, n4); … … 214 214 Digraph::Node n2 = d.addNode(); 215 215 Digraph::Node n3 = d.addNode(); 216 216 217 217 d.addArc(n1, n2); 218 218 d.addArc(n2, n3); -
test/graph_test.cc
r956 r1159 67 67 Edge e2 = G.addEdge(n2, n1), 68 68 e3 = G.addEdge(n2, n3); 69 ignore_unused_variable_warning(e2,e3); 69 70 70 71 checkGraphNodeList(G, 3); … … 99 100 e3 = G.addEdge(n2, n3), e4 = G.addEdge(n1, n4), 100 101 e5 = G.addEdge(n4, n3); 102 ignore_unused_variable_warning(e1,e3,e4,e5); 101 103 102 104 checkGraphNodeList(G, 4); … … 178 180 e3 = G.addEdge(n2, n3), e4 = G.addEdge(n1, n4), 179 181 e5 = G.addEdge(n4, n3); 182 ignore_unused_variable_warning(e1,e3,e4,e5); 180 183 181 184 // Check edge deletion … … 218 221 Edge e1 = G.addEdge(n1, n2), e2 = G.addEdge(n2, n1), 219 222 e3 = G.addEdge(n2, n3); 223 ignore_unused_variable_warning(e1,e2,e3); 220 224 221 225 checkGraphNodeList(G, 3); … … 382 386 e1 = g.addEdge(n1, n2), 383 387 e2 = g.addEdge(n2, n3); 388 ignore_unused_variable_warning(e2); 384 389 385 390 check(g.valid(n1), "Wrong validity check"); … … 520 525 521 526 Node n = G.nodeFromId(dim); 527 ignore_unused_variable_warning(n); 522 528 523 529 for (NodeIt n(G); n != INVALID; ++n) { -
test/graph_test.cc
r1157 r1159 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-20 095 * Copyright (C) 2003-2010 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 39 39 checkGraphArcList(G, 0); 40 40 41 G.reserveNode(3); 42 G.reserveEdge(3); 43 41 44 Node 42 45 n1 = G.addNode(), … … 261 264 262 265 snapshot.restore(); 266 snapshot.save(G); 263 267 264 268 checkGraphNodeList(G, 4); 265 269 checkGraphEdgeList(G, 3); 266 270 checkGraphArcList(G, 6); 271 272 G.addEdge(G.addNode(), G.addNode()); 273 274 snapshot.restore(); 275 276 checkGraphNodeList(G, 4); 277 checkGraphEdgeList(G, 3); 278 checkGraphArcList(G, 6); 267 279 } 268 280 … … 272 284 273 285 Graph G(num); 286 check(G.nodeNum() == num && G.edgeNum() == num * (num - 1) / 2, 287 "Wrong size"); 288 289 G.resize(num); 290 check(G.nodeNum() == num && G.edgeNum() == num * (num - 1) / 2, 291 "Wrong size"); 292 274 293 checkGraphNodeList(G, num); 275 294 checkGraphEdgeList(G, num * (num - 1) / 2); … … 417 436 check(G.height() == height, "Wrong row number"); 418 437 438 G.resize(width, height); 439 check(G.width() == width, "Wrong column number"); 440 check(G.height() == height, "Wrong row number"); 441 419 442 for (int i = 0; i < width; ++i) { 420 443 for (int j = 0; j < height; ++j) { … … 492 515 493 516 HypercubeGraph G(dim); 517 check(G.dimension() == dim, "Wrong dimension"); 518 519 G.resize(dim); 520 check(G.dimension() == dim, "Wrong dimension"); 521 494 522 checkGraphNodeList(G, 1 << dim); 495 523 checkGraphEdgeList(G, dim * (1 << (dim-1))); -
test/maps_test.cc
r1057 r1159 104 104 NullMap<A,B> map1; 105 105 NullMap<A,B> map2 = map1; 106 ignore_unused_variable_warning(map2); 106 107 map1 = nullMap<A,B>(); 107 108 } … … 114 115 ConstMap<A,B> map2 = B(); 115 116 ConstMap<A,B> map3 = map1; 117 ignore_unused_variable_warning(map2,map3); 118 116 119 map1 = constMap<A>(B()); 117 120 map1 = constMap<A,B>(); … … 119 122 ConstMap<A,C> map4(C(1)); 120 123 ConstMap<A,C> map5 = map4; 124 ignore_unused_variable_warning(map5); 125 121 126 map4 = constMap<A>(C(2)); 122 127 map4.setAll(C(3)); … … 139 144 IdentityMap<A> map1; 140 145 IdentityMap<A> map2 = map1; 146 ignore_unused_variable_warning(map2); 147 141 148 map1 = identityMap<A>(); 142 149 … … 198 205 checkConcept<ReadMap<B,double>, CompMap>(); 199 206 CompMap map1 = CompMap(DoubleMap(),ReadMap<B,A>()); 207 ignore_unused_variable_warning(map1); 200 208 CompMap map2 = composeMap(DoubleMap(), ReadMap<B,A>()); 209 ignore_unused_variable_warning(map2); 201 210 202 211 SparseMap<double, bool> m1(false); m1[3.14] = true; … … 211 220 checkConcept<ReadMap<A,double>, CombMap>(); 212 221 CombMap map1 = CombMap(DoubleMap(), DoubleMap()); 222 ignore_unused_variable_warning(map1); 213 223 CombMap map2 = combineMap(DoubleMap(), DoubleMap(), std::plus<double>()); 224 ignore_unused_variable_warning(map2); 214 225 215 226 check(combineMap(constMap<B,int,2>(), identityMap<B>(), &binc)[B()] == 3, … … 223 234 FunctorToMap<F> map1; 224 235 FunctorToMap<F> map2 = FunctorToMap<F>(F()); 236 ignore_unused_variable_warning(map2); 237 225 238 B b = functorToMap(F())[A()]; 239 ignore_unused_variable_warning(b); 226 240 227 241 checkConcept<ReadMap<A,B>, MapToFunctor<ReadMap<A,B> > >(); 228 242 MapToFunctor<ReadMap<A,B> > map = 229 243 MapToFunctor<ReadMap<A,B> >(ReadMap<A,B>()); 244 ignore_unused_variable_warning(map); 230 245 231 246 check(functorToMap(&func)[A()] == 3, … … 245 260 ConvertMap<ReadMap<double, int>, double> >(); 246 261 ConvertMap<RangeMap<bool>, int> map1(rangeMap(1, true)); 262 ignore_unused_variable_warning(map1); 247 263 ConvertMap<RangeMap<bool>, int> map2 = convertMap<int>(rangeMap(2, false)); 264 ignore_unused_variable_warning(map2); 265 248 266 } 249 267 -
test/maps_test.cc
r1157 r1159 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-20 095 * Copyright (C) 2003-2010 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 24 24 #include <lemon/maps.h> 25 25 #include <lemon/list_graph.h> 26 #include <lemon/smart_graph.h> 27 #include <lemon/adaptors.h> 28 #include <lemon/dfs.h> 29 #include <algorithm> 26 30 27 31 #include "test_tools.h" … … 35 39 36 40 class C { 37 int x;41 int _x; 38 42 public: 39 C(int _x) : x(_x) {} 43 C(int x) : _x(x) {} 44 int get() const { return _x; } 45 }; 46 inline bool operator<(C c1, C c2) { return c1.get() < c2.get(); } 47 inline bool operator==(C c1, C c2) { return c1.get() == c2.get(); } 48 49 C createC(int x) { return C(x); } 50 51 template <typename T> 52 class Less { 53 T _t; 54 public: 55 Less(T t): _t(t) {} 56 bool operator()(const T& t) const { return t < _t; } 40 57 }; 41 58 … … 53 70 54 71 int binc(int a, B) { return a+1; } 72 73 template <typename T> 74 class Sum { 75 T& _sum; 76 public: 77 Sum(T& sum) : _sum(sum) {} 78 void operator()(const T& t) { _sum += t; } 79 }; 55 80 56 81 typedef ReadMap<A, double> DoubleMap; … … 349 374 { 350 375 typedef std::vector<int> vec; 376 checkConcept<WriteMap<int, bool>, LoggerBoolMap<vec::iterator> >(); 377 checkConcept<WriteMap<int, bool>, 378 LoggerBoolMap<std::back_insert_iterator<vec> > >(); 379 351 380 vec v1; 352 381 vec v2(10); … … 368 397 it != map2.end(); ++it ) 369 398 check(v1[i++] == *it, "Something is wrong with LoggerBoolMap"); 370 } 371 372 // CrossRefMap 373 { 399 374 400 typedef ListDigraph Graph; 375 401 DIGRAPH_TYPEDEFS(Graph); 402 Graph gr; 403 404 Node n0 = gr.addNode(); 405 Node n1 = gr.addNode(); 406 Node n2 = gr.addNode(); 407 Node n3 = gr.addNode(); 408 409 gr.addArc(n3, n0); 410 gr.addArc(n3, n2); 411 gr.addArc(n0, n2); 412 gr.addArc(n2, n1); 413 gr.addArc(n0, n1); 414 415 { 416 std::vector<Node> v; 417 dfs(gr).processedMap(loggerBoolMap(std::back_inserter(v))).run(); 418 419 check(v.size()==4 && v[0]==n1 && v[1]==n2 && v[2]==n0 && v[3]==n3, 420 "Something is wrong with LoggerBoolMap"); 421 } 422 { 423 std::vector<Node> v(countNodes(gr)); 424 dfs(gr).processedMap(loggerBoolMap(v.begin())).run(); 425 426 check(v.size()==4 && v[0]==n1 && v[1]==n2 && v[2]==n0 && v[3]==n3, 427 "Something is wrong with LoggerBoolMap"); 428 } 429 } 430 431 // IdMap, RangeIdMap 432 { 433 typedef ListDigraph Graph; 434 DIGRAPH_TYPEDEFS(Graph); 435 436 checkConcept<ReadMap<Node, int>, IdMap<Graph, Node> >(); 437 checkConcept<ReadMap<Arc, int>, IdMap<Graph, Arc> >(); 438 checkConcept<ReadMap<Node, int>, RangeIdMap<Graph, Node> >(); 439 checkConcept<ReadMap<Arc, int>, RangeIdMap<Graph, Arc> >(); 440 441 Graph gr; 442 IdMap<Graph, Node> nmap(gr); 443 IdMap<Graph, Arc> amap(gr); 444 RangeIdMap<Graph, Node> nrmap(gr); 445 RangeIdMap<Graph, Arc> armap(gr); 446 447 Node n0 = gr.addNode(); 448 Node n1 = gr.addNode(); 449 Node n2 = gr.addNode(); 450 451 Arc a0 = gr.addArc(n0, n1); 452 Arc a1 = gr.addArc(n0, n2); 453 Arc a2 = gr.addArc(n2, n1); 454 Arc a3 = gr.addArc(n2, n0); 455 456 check(nmap[n0] == gr.id(n0) && nmap(gr.id(n0)) == n0, "Wrong IdMap"); 457 check(nmap[n1] == gr.id(n1) && nmap(gr.id(n1)) == n1, "Wrong IdMap"); 458 check(nmap[n2] == gr.id(n2) && nmap(gr.id(n2)) == n2, "Wrong IdMap"); 459 460 check(amap[a0] == gr.id(a0) && amap(gr.id(a0)) == a0, "Wrong IdMap"); 461 check(amap[a1] == gr.id(a1) && amap(gr.id(a1)) == a1, "Wrong IdMap"); 462 check(amap[a2] == gr.id(a2) && amap(gr.id(a2)) == a2, "Wrong IdMap"); 463 check(amap[a3] == gr.id(a3) && amap(gr.id(a3)) == a3, "Wrong IdMap"); 464 465 check(nmap.inverse()[gr.id(n0)] == n0, "Wrong IdMap::InverseMap"); 466 check(amap.inverse()[gr.id(a0)] == a0, "Wrong IdMap::InverseMap"); 467 468 check(nrmap.size() == 3 && armap.size() == 4, 469 "Wrong RangeIdMap::size()"); 470 471 check(nrmap[n0] == 0 && nrmap(0) == n0, "Wrong RangeIdMap"); 472 check(nrmap[n1] == 1 && nrmap(1) == n1, "Wrong RangeIdMap"); 473 check(nrmap[n2] == 2 && nrmap(2) == n2, "Wrong RangeIdMap"); 474 475 check(armap[a0] == 0 && armap(0) == a0, "Wrong RangeIdMap"); 476 check(armap[a1] == 1 && armap(1) == a1, "Wrong RangeIdMap"); 477 check(armap[a2] == 2 && armap(2) == a2, "Wrong RangeIdMap"); 478 check(armap[a3] == 3 && armap(3) == a3, "Wrong RangeIdMap"); 479 480 check(nrmap.inverse()[0] == n0, "Wrong RangeIdMap::InverseMap"); 481 check(armap.inverse()[0] == a0, "Wrong RangeIdMap::InverseMap"); 482 483 gr.erase(n1); 484 485 if (nrmap[n0] == 1) nrmap.swap(n0, n2); 486 nrmap.swap(n2, n0); 487 if (armap[a1] == 1) armap.swap(a1, a3); 488 armap.swap(a3, a1); 489 490 check(nrmap.size() == 2 && armap.size() == 2, 491 "Wrong RangeIdMap::size()"); 492 493 check(nrmap[n0] == 1 && nrmap(1) == n0, "Wrong RangeIdMap"); 494 check(nrmap[n2] == 0 && nrmap(0) == n2, "Wrong RangeIdMap"); 495 496 check(armap[a1] == 1 && armap(1) == a1, "Wrong RangeIdMap"); 497 check(armap[a3] == 0 && armap(0) == a3, "Wrong RangeIdMap"); 498 499 check(nrmap.inverse()[0] == n2, "Wrong RangeIdMap::InverseMap"); 500 check(armap.inverse()[0] == a3, "Wrong RangeIdMap::InverseMap"); 501 } 502 503 // SourceMap, TargetMap, ForwardMap, BackwardMap, InDegMap, OutDegMap 504 { 505 typedef ListGraph Graph; 506 GRAPH_TYPEDEFS(Graph); 507 508 checkConcept<ReadMap<Arc, Node>, SourceMap<Graph> >(); 509 checkConcept<ReadMap<Arc, Node>, TargetMap<Graph> >(); 510 checkConcept<ReadMap<Edge, Arc>, ForwardMap<Graph> >(); 511 checkConcept<ReadMap<Edge, Arc>, BackwardMap<Graph> >(); 512 checkConcept<ReadMap<Node, int>, InDegMap<Graph> >(); 513 checkConcept<ReadMap<Node, int>, OutDegMap<Graph> >(); 514 515 Graph gr; 516 Node n0 = gr.addNode(); 517 Node n1 = gr.addNode(); 518 Node n2 = gr.addNode(); 519 520 gr.addEdge(n0,n1); 521 gr.addEdge(n1,n2); 522 gr.addEdge(n0,n2); 523 gr.addEdge(n2,n1); 524 gr.addEdge(n1,n2); 525 gr.addEdge(n0,n1); 526 527 for (EdgeIt e(gr); e != INVALID; ++e) { 528 check(forwardMap(gr)[e] == gr.direct(e, true), "Wrong ForwardMap"); 529 check(backwardMap(gr)[e] == gr.direct(e, false), "Wrong BackwardMap"); 530 } 531 532 check(mapCompare(gr, 533 sourceMap(orienter(gr, constMap<Edge, bool>(true))), 534 targetMap(orienter(gr, constMap<Edge, bool>(false)))), 535 "Wrong SourceMap or TargetMap"); 536 537 typedef Orienter<Graph, const ConstMap<Edge, bool> > Digraph; 538 Digraph dgr(gr, constMap<Edge, bool>(true)); 539 OutDegMap<Digraph> odm(dgr); 540 InDegMap<Digraph> idm(dgr); 541 542 check(odm[n0] == 3 && odm[n1] == 2 && odm[n2] == 1, "Wrong OutDegMap"); 543 check(idm[n0] == 0 && idm[n1] == 3 && idm[n2] == 3, "Wrong InDegMap"); 544 545 gr.addEdge(n2, n0); 546 547 check(odm[n0] == 3 && odm[n1] == 2 && odm[n2] == 2, "Wrong OutDegMap"); 548 check(idm[n0] == 1 && idm[n1] == 3 && idm[n2] == 3, "Wrong InDegMap"); 549 } 550 551 // CrossRefMap 552 { 553 typedef ListDigraph Graph; 554 DIGRAPH_TYPEDEFS(Graph); 376 555 377 556 checkConcept<ReadWriteMap<Node, int>, 378 557 CrossRefMap<Graph, Node, int> >(); 379 558 checkConcept<ReadWriteMap<Node, bool>, 559 CrossRefMap<Graph, Node, bool> >(); 560 checkConcept<ReadWriteMap<Node, double>, 561 CrossRefMap<Graph, Node, double> >(); 562 563 Graph gr; 564 typedef CrossRefMap<Graph, Node, char> CRMap; 565 CRMap map(gr); 566 567 Node n0 = gr.addNode(); 568 Node n1 = gr.addNode(); 569 Node n2 = gr.addNode(); 570 571 map.set(n0, 'A'); 572 map.set(n1, 'B'); 573 map.set(n2, 'C'); 574 575 check(map[n0] == 'A' && map('A') == n0 && map.inverse()['A'] == n0, 576 "Wrong CrossRefMap"); 577 check(map[n1] == 'B' && map('B') == n1 && map.inverse()['B'] == n1, 578 "Wrong CrossRefMap"); 579 check(map[n2] == 'C' && map('C') == n2 && map.inverse()['C'] == n2, 580 "Wrong CrossRefMap"); 581 check(map.count('A') == 1 && map.count('B') == 1 && map.count('C') == 1, 582 "Wrong CrossRefMap::count()"); 583 584 CRMap::ValueIt it = map.beginValue(); 585 check(*it++ == 'A' && *it++ == 'B' && *it++ == 'C' && 586 it == map.endValue(), "Wrong value iterator"); 587 588 map.set(n2, 'A'); 589 590 check(map[n0] == 'A' && map[n1] == 'B' && map[n2] == 'A', 591 "Wrong CrossRefMap"); 592 check(map('A') == n0 && map.inverse()['A'] == n0, "Wrong CrossRefMap"); 593 check(map('B') == n1 && map.inverse()['B'] == n1, "Wrong CrossRefMap"); 594 check(map('C') == INVALID && map.inverse()['C'] == INVALID, 595 "Wrong CrossRefMap"); 596 check(map.count('A') == 2 && map.count('B') == 1 && map.count('C') == 0, 597 "Wrong CrossRefMap::count()"); 598 599 it = map.beginValue(); 600 check(*it++ == 'A' && *it++ == 'A' && *it++ == 'B' && 601 it == map.endValue(), "Wrong value iterator"); 602 603 map.set(n0, 'C'); 604 605 check(map[n0] == 'C' && map[n1] == 'B' && map[n2] == 'A', 606 "Wrong CrossRefMap"); 607 check(map('A') == n2 && map.inverse()['A'] == n2, "Wrong CrossRefMap"); 608 check(map('B') == n1 && map.inverse()['B'] == n1, "Wrong CrossRefMap"); 609 check(map('C') == n0 && map.inverse()['C'] == n0, "Wrong CrossRefMap"); 610 check(map.count('A') == 1 && map.count('B') == 1 && map.count('C') == 1, 611 "Wrong CrossRefMap::count()"); 612 613 it = map.beginValue(); 614 check(*it++ == 'A' && *it++ == 'B' && *it++ == 'C' && 615 it == map.endValue(), "Wrong value iterator"); 616 } 617 618 // CrossRefMap 619 { 620 typedef SmartDigraph Graph; 621 DIGRAPH_TYPEDEFS(Graph); 622 623 checkConcept<ReadWriteMap<Node, int>, 624 CrossRefMap<Graph, Node, int> >(); 625 380 626 Graph gr; 381 627 typedef CrossRefMap<Graph, Node, char> CRMap; 382 628 typedef CRMap::ValueIterator ValueIt; 383 629 CRMap map(gr); 384 630 385 631 Node n0 = gr.addNode(); 386 632 Node n1 = gr.addNode(); 387 633 Node n2 = gr.addNode(); 388 634 389 635 map.set(n0, 'A'); 390 636 map.set(n1, 'B'); … … 404 650 } 405 651 652 // Iterable bool map 653 { 654 typedef SmartGraph Graph; 655 typedef SmartGraph::Node Item; 656 657 typedef IterableBoolMap<SmartGraph, SmartGraph::Node> Ibm; 658 checkConcept<ReferenceMap<Item, bool, bool&, const bool&>, Ibm>(); 659 660 const int num = 10; 661 Graph g; 662 Ibm map0(g, true); 663 std::vector<Item> items; 664 for (int i = 0; i < num; ++i) { 665 items.push_back(g.addNode()); 666 } 667 668 Ibm map1(g, true); 669 int n = 0; 670 for (Ibm::TrueIt it(map1); it != INVALID; ++it) { 671 check(map1[static_cast<Item>(it)], "Wrong TrueIt"); 672 ++n; 673 } 674 check(n == num, "Wrong number"); 675 676 n = 0; 677 for (Ibm::ItemIt it(map1, true); it != INVALID; ++it) { 678 check(map1[static_cast<Item>(it)], "Wrong ItemIt for true"); 679 ++n; 680 } 681 check(n == num, "Wrong number"); 682 check(Ibm::FalseIt(map1) == INVALID, "Wrong FalseIt"); 683 check(Ibm::ItemIt(map1, false) == INVALID, "Wrong ItemIt for false"); 684 685 map1[items[5]] = true; 686 687 n = 0; 688 for (Ibm::ItemIt it(map1, true); it != INVALID; ++it) { 689 check(map1[static_cast<Item>(it)], "Wrong ItemIt for true"); 690 ++n; 691 } 692 check(n == num, "Wrong number"); 693 694 map1[items[num / 2]] = false; 695 check(map1[items[num / 2]] == false, "Wrong map value"); 696 697 n = 0; 698 for (Ibm::TrueIt it(map1); it != INVALID; ++it) { 699 check(map1[static_cast<Item>(it)], "Wrong TrueIt for true"); 700 ++n; 701 } 702 check(n == num - 1, "Wrong number"); 703 704 n = 0; 705 for (Ibm::FalseIt it(map1); it != INVALID; ++it) { 706 check(!map1[static_cast<Item>(it)], "Wrong FalseIt for true"); 707 ++n; 708 } 709 check(n == 1, "Wrong number"); 710 711 map1[items[0]] = false; 712 check(map1[items[0]] == false, "Wrong map value"); 713 714 map1[items[num - 1]] = false; 715 check(map1[items[num - 1]] == false, "Wrong map value"); 716 717 n = 0; 718 for (Ibm::TrueIt it(map1); it != INVALID; ++it) { 719 check(map1[static_cast<Item>(it)], "Wrong TrueIt for true"); 720 ++n; 721 } 722 check(n == num - 3, "Wrong number"); 723 check(map1.trueNum() == num - 3, "Wrong number"); 724 725 n = 0; 726 for (Ibm::FalseIt it(map1); it != INVALID; ++it) { 727 check(!map1[static_cast<Item>(it)], "Wrong FalseIt for true"); 728 ++n; 729 } 730 check(n == 3, "Wrong number"); 731 check(map1.falseNum() == 3, "Wrong number"); 732 } 733 734 // Iterable int map 735 { 736 typedef SmartGraph Graph; 737 typedef SmartGraph::Node Item; 738 typedef IterableIntMap<SmartGraph, SmartGraph::Node> Iim; 739 740 checkConcept<ReferenceMap<Item, int, int&, const int&>, Iim>(); 741 742 const int num = 10; 743 Graph g; 744 Iim map0(g, 0); 745 std::vector<Item> items; 746 for (int i = 0; i < num; ++i) { 747 items.push_back(g.addNode()); 748 } 749 750 Iim map1(g); 751 check(map1.size() == 0, "Wrong size"); 752 753 for (int i = 0; i < num; ++i) { 754 map1[items[i]] = i; 755 } 756 check(map1.size() == num, "Wrong size"); 757 758 for (int i = 0; i < num; ++i) { 759 Iim::ItemIt it(map1, i); 760 check(static_cast<Item>(it) == items[i], "Wrong value"); 761 ++it; 762 check(static_cast<Item>(it) == INVALID, "Wrong value"); 763 } 764 765 for (int i = 0; i < num; ++i) { 766 map1[items[i]] = i % 2; 767 } 768 check(map1.size() == 2, "Wrong size"); 769 770 int n = 0; 771 for (Iim::ItemIt it(map1, 0); it != INVALID; ++it) { 772 check(map1[static_cast<Item>(it)] == 0, "Wrong value"); 773 ++n; 774 } 775 check(n == (num + 1) / 2, "Wrong number"); 776 777 for (Iim::ItemIt it(map1, 1); it != INVALID; ++it) { 778 check(map1[static_cast<Item>(it)] == 1, "Wrong value"); 779 ++n; 780 } 781 check(n == num, "Wrong number"); 782 783 } 784 785 // Iterable value map 786 { 787 typedef SmartGraph Graph; 788 typedef SmartGraph::Node Item; 789 typedef IterableValueMap<SmartGraph, SmartGraph::Node, double> Ivm; 790 791 checkConcept<ReadWriteMap<Item, double>, Ivm>(); 792 793 const int num = 10; 794 Graph g; 795 Ivm map0(g, 0.0); 796 std::vector<Item> items; 797 for (int i = 0; i < num; ++i) { 798 items.push_back(g.addNode()); 799 } 800 801 Ivm map1(g, 0.0); 802 check(distance(map1.beginValue(), map1.endValue()) == 1, "Wrong size"); 803 check(*map1.beginValue() == 0.0, "Wrong value"); 804 805 for (int i = 0; i < num; ++i) { 806 map1.set(items[i], static_cast<double>(i)); 807 } 808 check(distance(map1.beginValue(), map1.endValue()) == num, "Wrong size"); 809 810 for (int i = 0; i < num; ++i) { 811 Ivm::ItemIt it(map1, static_cast<double>(i)); 812 check(static_cast<Item>(it) == items[i], "Wrong value"); 813 ++it; 814 check(static_cast<Item>(it) == INVALID, "Wrong value"); 815 } 816 817 for (Ivm::ValueIt vit = map1.beginValue(); 818 vit != map1.endValue(); ++vit) { 819 check(map1[static_cast<Item>(Ivm::ItemIt(map1, *vit))] == *vit, 820 "Wrong ValueIt"); 821 } 822 823 for (int i = 0; i < num; ++i) { 824 map1.set(items[i], static_cast<double>(i % 2)); 825 } 826 check(distance(map1.beginValue(), map1.endValue()) == 2, "Wrong size"); 827 828 int n = 0; 829 for (Ivm::ItemIt it(map1, 0.0); it != INVALID; ++it) { 830 check(map1[static_cast<Item>(it)] == 0.0, "Wrong value"); 831 ++n; 832 } 833 check(n == (num + 1) / 2, "Wrong number"); 834 835 for (Ivm::ItemIt it(map1, 1.0); it != INVALID; ++it) { 836 check(map1[static_cast<Item>(it)] == 1.0, "Wrong value"); 837 ++n; 838 } 839 check(n == num, "Wrong number"); 840 841 } 842 843 // Graph map utilities: 844 // mapMin(), mapMax(), mapMinValue(), mapMaxValue() 845 // mapFind(), mapFindIf(), mapCount(), mapCountIf() 846 // mapCopy(), mapCompare(), mapFill() 847 { 848 DIGRAPH_TYPEDEFS(SmartDigraph); 849 850 SmartDigraph g; 851 Node n1 = g.addNode(); 852 Node n2 = g.addNode(); 853 Node n3 = g.addNode(); 854 855 SmartDigraph::NodeMap<int> map1(g); 856 SmartDigraph::ArcMap<char> map2(g); 857 ConstMap<Node, A> cmap1 = A(); 858 ConstMap<Arc, C> cmap2 = C(0); 859 860 map1[n1] = 10; 861 map1[n2] = 5; 862 map1[n3] = 12; 863 864 // mapMin(), mapMax(), mapMinValue(), mapMaxValue() 865 check(mapMin(g, map1) == n2, "Wrong mapMin()"); 866 check(mapMax(g, map1) == n3, "Wrong mapMax()"); 867 check(mapMin(g, map1, std::greater<int>()) == n3, "Wrong mapMin()"); 868 check(mapMax(g, map1, std::greater<int>()) == n2, "Wrong mapMax()"); 869 check(mapMinValue(g, map1) == 5, "Wrong mapMinValue()"); 870 check(mapMaxValue(g, map1) == 12, "Wrong mapMaxValue()"); 871 872 check(mapMin(g, map2) == INVALID, "Wrong mapMin()"); 873 check(mapMax(g, map2) == INVALID, "Wrong mapMax()"); 874 875 check(mapMin(g, cmap1) != INVALID, "Wrong mapMin()"); 876 check(mapMax(g, cmap2) == INVALID, "Wrong mapMax()"); 877 878 Arc a1 = g.addArc(n1, n2); 879 Arc a2 = g.addArc(n1, n3); 880 Arc a3 = g.addArc(n2, n3); 881 Arc a4 = g.addArc(n3, n1); 882 883 map2[a1] = 'b'; 884 map2[a2] = 'a'; 885 map2[a3] = 'b'; 886 map2[a4] = 'c'; 887 888 // mapMin(), mapMax(), mapMinValue(), mapMaxValue() 889 check(mapMin(g, map2) == a2, "Wrong mapMin()"); 890 check(mapMax(g, map2) == a4, "Wrong mapMax()"); 891 check(mapMin(g, map2, std::greater<int>()) == a4, "Wrong mapMin()"); 892 check(mapMax(g, map2, std::greater<int>()) == a2, "Wrong mapMax()"); 893 check(mapMinValue(g, map2, std::greater<int>()) == 'c', 894 "Wrong mapMinValue()"); 895 check(mapMaxValue(g, map2, std::greater<int>()) == 'a', 896 "Wrong mapMaxValue()"); 897 898 check(mapMin(g, cmap1) != INVALID, "Wrong mapMin()"); 899 check(mapMax(g, cmap2) != INVALID, "Wrong mapMax()"); 900 check(mapMaxValue(g, cmap2) == C(0), "Wrong mapMaxValue()"); 901 902 check(mapMin(g, composeMap(functorToMap(&createC), map2)) == a2, 903 "Wrong mapMin()"); 904 check(mapMax(g, composeMap(functorToMap(&createC), map2)) == a4, 905 "Wrong mapMax()"); 906 check(mapMinValue(g, composeMap(functorToMap(&createC), map2)) == C('a'), 907 "Wrong mapMinValue()"); 908 check(mapMaxValue(g, composeMap(functorToMap(&createC), map2)) == C('c'), 909 "Wrong mapMaxValue()"); 910 911 // mapFind(), mapFindIf() 912 check(mapFind(g, map1, 5) == n2, "Wrong mapFind()"); 913 check(mapFind(g, map1, 6) == INVALID, "Wrong mapFind()"); 914 check(mapFind(g, map2, 'a') == a2, "Wrong mapFind()"); 915 check(mapFind(g, map2, 'e') == INVALID, "Wrong mapFind()"); 916 check(mapFind(g, cmap2, C(0)) == ArcIt(g), "Wrong mapFind()"); 917 check(mapFind(g, cmap2, C(1)) == INVALID, "Wrong mapFind()"); 918 919 check(mapFindIf(g, map1, Less<int>(7)) == n2, 920 "Wrong mapFindIf()"); 921 check(mapFindIf(g, map1, Less<int>(5)) == INVALID, 922 "Wrong mapFindIf()"); 923 check(mapFindIf(g, map2, Less<char>('d')) == ArcIt(g), 924 "Wrong mapFindIf()"); 925 check(mapFindIf(g, map2, Less<char>('a')) == INVALID, 926 "Wrong mapFindIf()"); 927 928 // mapCount(), mapCountIf() 929 check(mapCount(g, map1, 5) == 1, "Wrong mapCount()"); 930 check(mapCount(g, map1, 6) == 0, "Wrong mapCount()"); 931 check(mapCount(g, map2, 'a') == 1, "Wrong mapCount()"); 932 check(mapCount(g, map2, 'b') == 2, "Wrong mapCount()"); 933 check(mapCount(g, map2, 'e') == 0, "Wrong mapCount()"); 934 check(mapCount(g, cmap2, C(0)) == 4, "Wrong mapCount()"); 935 check(mapCount(g, cmap2, C(1)) == 0, "Wrong mapCount()"); 936 937 check(mapCountIf(g, map1, Less<int>(11)) == 2, 938 "Wrong mapCountIf()"); 939 check(mapCountIf(g, map1, Less<int>(13)) == 3, 940 "Wrong mapCountIf()"); 941 check(mapCountIf(g, map1, Less<int>(5)) == 0, 942 "Wrong mapCountIf()"); 943 check(mapCountIf(g, map2, Less<char>('d')) == 4, 944 "Wrong mapCountIf()"); 945 check(mapCountIf(g, map2, Less<char>('c')) == 3, 946 "Wrong mapCountIf()"); 947 check(mapCountIf(g, map2, Less<char>('a')) == 0, 948 "Wrong mapCountIf()"); 949 950 // MapIt, ConstMapIt 951 /* 952 These tests can be used after applying bugfix #330 953 typedef SmartDigraph::NodeMap<int>::MapIt MapIt; 954 typedef SmartDigraph::NodeMap<int>::ConstMapIt ConstMapIt; 955 check(*std::min_element(MapIt(map1), MapIt(INVALID)) == 5, 956 "Wrong NodeMap<>::MapIt"); 957 check(*std::max_element(ConstMapIt(map1), ConstMapIt(INVALID)) == 12, 958 "Wrong NodeMap<>::MapIt"); 959 960 int sum = 0; 961 std::for_each(MapIt(map1), MapIt(INVALID), Sum<int>(sum)); 962 check(sum == 27, "Wrong NodeMap<>::MapIt"); 963 std::for_each(ConstMapIt(map1), ConstMapIt(INVALID), Sum<int>(sum)); 964 check(sum == 54, "Wrong NodeMap<>::ConstMapIt"); 965 */ 966 967 // mapCopy(), mapCompare(), mapFill() 968 check(mapCompare(g, map1, map1), "Wrong mapCompare()"); 969 check(mapCompare(g, cmap2, cmap2), "Wrong mapCompare()"); 970 check(mapCompare(g, map1, shiftMap(map1, 0)), "Wrong mapCompare()"); 971 check(mapCompare(g, map2, scaleMap(map2, 1)), "Wrong mapCompare()"); 972 check(!mapCompare(g, map1, shiftMap(map1, 1)), "Wrong mapCompare()"); 973 974 SmartDigraph::NodeMap<int> map3(g, 0); 975 SmartDigraph::ArcMap<char> map4(g, 'a'); 976 977 check(!mapCompare(g, map1, map3), "Wrong mapCompare()"); 978 check(!mapCompare(g, map2, map4), "Wrong mapCompare()"); 979 980 mapCopy(g, map1, map3); 981 mapCopy(g, map2, map4); 982 983 check(mapCompare(g, map1, map3), "Wrong mapCompare() or mapCopy()"); 984 check(mapCompare(g, map2, map4), "Wrong mapCompare() or mapCopy()"); 985 986 Undirector<SmartDigraph> ug(g); 987 Undirector<SmartDigraph>::EdgeMap<char> umap1(ug, 'x'); 988 Undirector<SmartDigraph>::ArcMap<double> umap2(ug, 3.14); 989 990 check(!mapCompare(g, map2, umap1), "Wrong mapCompare() or mapCopy()"); 991 check(!mapCompare(g, umap1, map2), "Wrong mapCompare() or mapCopy()"); 992 check(!mapCompare(ug, map2, umap1), "Wrong mapCompare() or mapCopy()"); 993 check(!mapCompare(ug, umap1, map2), "Wrong mapCompare() or mapCopy()"); 994 995 mapCopy(g, map2, umap1); 996 997 check(mapCompare(g, map2, umap1), "Wrong mapCompare() or mapCopy()"); 998 check(mapCompare(g, umap1, map2), "Wrong mapCompare() or mapCopy()"); 999 check(mapCompare(ug, map2, umap1), "Wrong mapCompare() or mapCopy()"); 1000 check(mapCompare(ug, umap1, map2), "Wrong mapCompare() or mapCopy()"); 1001 1002 mapCopy(g, map2, umap1); 1003 mapCopy(g, umap1, map2); 1004 mapCopy(ug, map2, umap1); 1005 mapCopy(ug, umap1, map2); 1006 1007 check(!mapCompare(ug, umap1, umap2), "Wrong mapCompare() or mapCopy()"); 1008 mapCopy(ug, umap1, umap2); 1009 check(mapCompare(ug, umap1, umap2), "Wrong mapCompare() or mapCopy()"); 1010 1011 check(!mapCompare(g, map1, constMap<Node>(2)), "Wrong mapCompare()"); 1012 mapFill(g, map1, 2); 1013 check(mapCompare(g, constMap<Node>(2), map1), "Wrong mapFill()"); 1014 1015 check(!mapCompare(g, map2, constMap<Arc>('z')), "Wrong mapCompare()"); 1016 mapCopy(g, constMap<Arc>('z'), map2); 1017 check(mapCompare(g, constMap<Arc>('z'), map2), "Wrong mapCopy()"); 1018 } 1019 406 1020 return 0; 407 1021 }
Note: See TracChangeset
for help on using the changeset viewer.