Changes in / [624:1f631044c290:621:b536eaacb39b] in lemon-main
- Files:
-
- 28 edited
Legend:
- Unmodified
- Added
- Removed
-
demo/graph_to_eps_demo.cc
r612 r440 183 183 ListDigraph::NodeMap<Point> hcoords(h); 184 184 185 int cols=int(s td::sqrt(double(palette.size())));185 int cols=int(sqrt(double(palette.size()))); 186 186 for(int i=0;i<int(paletteW.size());i++) { 187 187 Node n=h.addNode(); -
lemon/adaptors.h
r617 r579 110 110 template <typename V> 111 111 class NodeMap : public DGR::template NodeMap<V> { 112 public: 113 112 114 typedef typename DGR::template NodeMap<V> Parent; 113 115 114 public:115 116 explicit NodeMap(const Adaptor& adaptor) 116 117 : Parent(*adaptor._digraph) {} 118 117 119 NodeMap(const Adaptor& adaptor, const V& value) 118 120 : Parent(*adaptor._digraph, value) { } … … 133 135 template <typename V> 134 136 class ArcMap : public DGR::template ArcMap<V> { 137 public: 138 135 139 typedef typename DGR::template ArcMap<V> Parent; 136 140 137 public:138 141 explicit ArcMap(const DigraphAdaptorBase<DGR>& adaptor) 139 142 : Parent(*adaptor._digraph) {} 143 140 144 ArcMap(const DigraphAdaptorBase<DGR>& adaptor, const V& value) 141 145 : Parent(*adaptor._digraph, value) {} … … 252 256 template <typename V> 253 257 class NodeMap : public GR::template NodeMap<V> { 258 public: 254 259 typedef typename GR::template NodeMap<V> Parent; 255 256 public:257 260 explicit NodeMap(const GraphAdaptorBase<GR>& adapter) 258 261 : Parent(*adapter._graph) {} … … 275 278 template <typename V> 276 279 class ArcMap : public GR::template ArcMap<V> { 280 public: 277 281 typedef typename GR::template ArcMap<V> Parent; 278 279 public:280 282 explicit ArcMap(const GraphAdaptorBase<GR>& adapter) 281 283 : Parent(*adapter._graph) {} … … 297 299 template <typename V> 298 300 class EdgeMap : public GR::template EdgeMap<V> { 301 public: 299 302 typedef typename GR::template EdgeMap<V> Parent; 300 301 public:302 303 explicit EdgeMap(const GraphAdaptorBase<GR>& adapter) 303 304 : Parent(*adapter._graph) {} … … 321 322 template <typename DGR> 322 323 class ReverseDigraphBase : public DigraphAdaptorBase<DGR> { 324 public: 325 typedef DGR Digraph; 323 326 typedef DigraphAdaptorBase<DGR> Parent; 324 public:325 typedef DGR Digraph;326 327 protected: 327 328 ReverseDigraphBase() : Parent() { } … … 374 375 public DigraphAdaptorExtender<ReverseDigraphBase<DGR> > { 375 376 #endif 376 typedef DigraphAdaptorExtender<ReverseDigraphBase<DGR> > Parent;377 377 public: 378 378 /// The type of the adapted digraph. 379 379 typedef DGR Digraph; 380 typedef DigraphAdaptorExtender<ReverseDigraphBase<DGR> > Parent; 380 381 protected: 381 382 ReverseDigraph() { } … … 403 404 template <typename DGR, typename NF, typename AF, bool ch = true> 404 405 class SubDigraphBase : public DigraphAdaptorBase<DGR> { 405 typedef DigraphAdaptorBase<DGR> Parent;406 406 public: 407 407 typedef DGR Digraph; … … 410 410 411 411 typedef SubDigraphBase Adaptor; 412 typedef DigraphAdaptorBase<DGR> Parent; 412 413 protected: 413 414 NF* _node_filter; … … 509 510 : public SubMapExtender<SubDigraphBase<DGR, NF, AF, ch>, 510 511 LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, NodeMap<V>)> { 511 typedef SubMapExtender<SubDigraphBase<DGR, NF, AF, ch>,512 LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, NodeMap<V>)> Parent;513 514 512 public: 515 513 typedef V Value; 514 typedef SubMapExtender<SubDigraphBase<DGR, NF, AF, ch>, 515 LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, NodeMap<V>)> Parent; 516 516 517 517 NodeMap(const SubDigraphBase<DGR, NF, AF, ch>& adaptor) … … 536 536 : public SubMapExtender<SubDigraphBase<DGR, NF, AF, ch>, 537 537 LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, ArcMap<V>)> { 538 public: 539 typedef V Value; 538 540 typedef SubMapExtender<SubDigraphBase<DGR, NF, AF, ch>, 539 541 LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, ArcMap<V>)> Parent; 540 541 public:542 typedef V Value;543 542 544 543 ArcMap(const SubDigraphBase<DGR, NF, AF, ch>& adaptor) … … 564 563 class SubDigraphBase<DGR, NF, AF, false> 565 564 : public DigraphAdaptorBase<DGR> { 566 typedef DigraphAdaptorBase<DGR> Parent;567 565 public: 568 566 typedef DGR Digraph; … … 571 569 572 570 typedef SubDigraphBase Adaptor; 571 typedef DigraphAdaptorBase<Digraph> Parent; 573 572 protected: 574 573 NF* _node_filter; … … 652 651 : public SubMapExtender<SubDigraphBase<DGR, NF, AF, false>, 653 652 LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, NodeMap<V>)> { 653 public: 654 typedef V Value; 654 655 typedef SubMapExtender<SubDigraphBase<DGR, NF, AF, false>, 655 656 LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, NodeMap<V>)> Parent; 656 657 public:658 typedef V Value;659 657 660 658 NodeMap(const SubDigraphBase<DGR, NF, AF, false>& adaptor) … … 679 677 : public SubMapExtender<SubDigraphBase<DGR, NF, AF, false>, 680 678 LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, ArcMap<V>)> { 681 typedef SubMapExtender<SubDigraphBase<DGR, NF, AF, false>,682 LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, ArcMap<V>)> Parent;683 684 679 public: 685 680 typedef V Value; 681 typedef SubMapExtender<SubDigraphBase<DGR, NF, AF, false>, 682 LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, ArcMap<V>)> Parent; 686 683 687 684 ArcMap(const SubDigraphBase<DGR, NF, AF, false>& adaptor) … … 867 864 template <typename GR, typename NF, typename EF, bool ch = true> 868 865 class SubGraphBase : public GraphAdaptorBase<GR> { 869 typedef GraphAdaptorBase<GR> Parent;870 866 public: 871 867 typedef GR Graph; … … 874 870 875 871 typedef SubGraphBase Adaptor; 872 typedef GraphAdaptorBase<GR> Parent; 876 873 protected: 877 874 … … 1020 1017 : public SubMapExtender<SubGraphBase<GR, NF, EF, ch>, 1021 1018 LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, NodeMap<V>)> { 1019 public: 1020 typedef V Value; 1022 1021 typedef SubMapExtender<SubGraphBase<GR, NF, EF, ch>, 1023 1022 LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, NodeMap<V>)> Parent; 1024 1025 public:1026 typedef V Value;1027 1023 1028 1024 NodeMap(const SubGraphBase<GR, NF, EF, ch>& adaptor) … … 1047 1043 : public SubMapExtender<SubGraphBase<GR, NF, EF, ch>, 1048 1044 LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, ArcMap<V>)> { 1045 public: 1046 typedef V Value; 1049 1047 typedef SubMapExtender<SubGraphBase<GR, NF, EF, ch>, 1050 1048 LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, ArcMap<V>)> Parent; 1051 1052 public:1053 typedef V Value;1054 1049 1055 1050 ArcMap(const SubGraphBase<GR, NF, EF, ch>& adaptor) … … 1074 1069 : public SubMapExtender<SubGraphBase<GR, NF, EF, ch>, 1075 1070 LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, EdgeMap<V>)> { 1071 public: 1072 typedef V Value; 1076 1073 typedef SubMapExtender<SubGraphBase<GR, NF, EF, ch>, 1077 1074 LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, EdgeMap<V>)> Parent; 1078 1079 public:1080 typedef V Value;1081 1075 1082 1076 EdgeMap(const SubGraphBase<GR, NF, EF, ch>& adaptor) … … 1103 1097 class SubGraphBase<GR, NF, EF, false> 1104 1098 : public GraphAdaptorBase<GR> { 1105 typedef GraphAdaptorBase<GR> Parent;1106 1099 public: 1107 1100 typedef GR Graph; … … 1110 1103 1111 1104 typedef SubGraphBase Adaptor; 1105 typedef GraphAdaptorBase<GR> Parent; 1112 1106 protected: 1113 1107 NF* _node_filter; … … 1218 1212 : public SubMapExtender<SubGraphBase<GR, NF, EF, false>, 1219 1213 LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, NodeMap<V>)> { 1214 public: 1215 typedef V Value; 1220 1216 typedef SubMapExtender<SubGraphBase<GR, NF, EF, false>, 1221 1217 LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, NodeMap<V>)> Parent; 1222 1223 public:1224 typedef V Value;1225 1218 1226 1219 NodeMap(const SubGraphBase<GR, NF, EF, false>& adaptor) … … 1245 1238 : public SubMapExtender<SubGraphBase<GR, NF, EF, false>, 1246 1239 LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, ArcMap<V>)> { 1240 public: 1241 typedef V Value; 1247 1242 typedef SubMapExtender<SubGraphBase<GR, NF, EF, false>, 1248 1243 LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, ArcMap<V>)> Parent; 1249 1250 public:1251 typedef V Value;1252 1244 1253 1245 ArcMap(const SubGraphBase<GR, NF, EF, false>& adaptor) … … 1272 1264 : public SubMapExtender<SubGraphBase<GR, NF, EF, false>, 1273 1265 LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, EdgeMap<V>)> { 1274 typedef SubMapExtender<SubGraphBase<GR, NF, EF, false>,1275 LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, EdgeMap<V>)> Parent;1276 1277 1266 public: 1278 1267 typedef V Value; 1268 typedef SubMapExtender<SubGraphBase<GR, NF, EF, false>, 1269 LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, EdgeMap<V>)> Parent; 1279 1270 1280 1271 EdgeMap(const SubGraphBase<GR, NF, EF, false>& adaptor) … … 1495 1486 true> > { 1496 1487 #endif 1488 public: 1489 1490 typedef GR Digraph; 1491 typedef NF NodeFilterMap; 1492 1497 1493 typedef DigraphAdaptorExtender< 1498 1494 SubDigraphBase<GR, NF, ConstMap<typename GR::Arc, Const<bool, true> >, 1499 1495 true> > Parent; 1500 1501 public:1502 1503 typedef GR Digraph;1504 typedef NF NodeFilterMap;1505 1496 1506 1497 typedef typename Parent::Node Node; … … 1558 1549 true> > { 1559 1550 1551 public: 1552 typedef GR Graph; 1553 typedef NF NodeFilterMap; 1560 1554 typedef GraphAdaptorExtender< 1561 1555 SubGraphBase<GR, NF, ConstMap<typename GR::Edge, Const<bool, true> >, 1562 1556 true> > Parent; 1563 1557 1564 public:1565 1566 typedef GR Graph;1567 typedef NF NodeFilterMap;1568 1569 1558 typedef typename Parent::Node Node; 1570 1571 1559 protected: 1572 1560 ConstMap<typename GR::Edge, Const<bool, true> > const_true_map; … … 1642 1630 AF, false> > { 1643 1631 #endif 1644 typedef DigraphAdaptorExtender< 1645 SubDigraphBase<DGR, ConstMap<typename DGR::Node, Const<bool, true> >, 1646 AF, false> > Parent; 1647 1648 public: 1649 1632 public: 1650 1633 /// The type of the adapted digraph. 1651 1634 typedef DGR Digraph; 1652 1635 /// The type of the arc filter map. 1653 1636 typedef AF ArcFilterMap; 1637 1638 typedef DigraphAdaptorExtender< 1639 SubDigraphBase<DGR, ConstMap<typename DGR::Node, Const<bool, true> >, 1640 AF, false> > Parent; 1654 1641 1655 1642 typedef typename Parent::Arc Arc; … … 1752 1739 EF, false> > { 1753 1740 #endif 1754 typedef GraphAdaptorExtender< 1755 SubGraphBase<GR, ConstMap<typename GR::Node, Const<bool, true > >, 1756 EF, false> > Parent; 1757 1758 public: 1759 1741 public: 1760 1742 /// The type of the adapted graph. 1761 1743 typedef GR Graph; 1762 1744 /// The type of the edge filter map. 1763 1745 typedef EF EdgeFilterMap; 1746 1747 typedef GraphAdaptorExtender< 1748 SubGraphBase<GR, ConstMap<typename GR::Node, Const<bool, true > >, 1749 EF, false> > Parent; 1764 1750 1765 1751 typedef typename Parent::Edge Edge; … … 2126 2112 template <typename V> 2127 2113 class NodeMap : public DGR::template NodeMap<V> { 2128 typedef typename DGR::template NodeMap<V> Parent;2129 2130 2114 public: 2115 2131 2116 typedef V Value; 2117 typedef typename DGR::template NodeMap<Value> Parent; 2132 2118 2133 2119 explicit NodeMap(const UndirectorBase<DGR>& adaptor) … … 2152 2138 template <typename V> 2153 2139 class ArcMap 2154 : public SubMapExtender<UndirectorBase<DGR>, ArcMapBase<V> > { 2155 typedef SubMapExtender<UndirectorBase<DGR>, ArcMapBase<V> > Parent; 2156 2140 : public SubMapExtender<UndirectorBase<DGR>, ArcMapBase<V> > 2141 { 2157 2142 public: 2158 2143 typedef V Value; 2144 typedef SubMapExtender<Adaptor, ArcMapBase<V> > Parent; 2159 2145 2160 2146 explicit ArcMap(const UndirectorBase<DGR>& adaptor) … … 2178 2164 template <typename V> 2179 2165 class EdgeMap : public Digraph::template ArcMap<V> { 2166 public: 2167 2168 typedef V Value; 2180 2169 typedef typename Digraph::template ArcMap<V> Parent; 2181 2182 public:2183 typedef V Value;2184 2170 2185 2171 explicit EdgeMap(const UndirectorBase<DGR>& adaptor) … … 2253 2239 public GraphAdaptorExtender<UndirectorBase<DGR> > { 2254 2240 #endif 2255 typedef GraphAdaptorExtender<UndirectorBase<DGR> > Parent;2256 2241 public: 2257 2242 /// The type of the adapted digraph. 2258 2243 typedef DGR Digraph; 2244 typedef GraphAdaptorExtender<UndirectorBase<DGR> > Parent; 2259 2245 protected: 2260 2246 Undirector() { } … … 2464 2450 template <typename V> 2465 2451 class NodeMap : public GR::template NodeMap<V> { 2452 public: 2453 2466 2454 typedef typename GR::template NodeMap<V> Parent; 2467 2468 public:2469 2455 2470 2456 explicit NodeMap(const OrienterBase<GR, DM>& adapter) … … 2489 2475 template <typename V> 2490 2476 class ArcMap : public GR::template EdgeMap<V> { 2477 public: 2478 2491 2479 typedef typename Graph::template EdgeMap<V> Parent; 2492 2493 public:2494 2480 2495 2481 explicit ArcMap(const OrienterBase<GR, DM>& adapter) … … 2561 2547 public DigraphAdaptorExtender<OrienterBase<GR, DM> > { 2562 2548 #endif 2563 typedef DigraphAdaptorExtender<OrienterBase<GR, DM> > Parent;2564 2549 public: 2565 2550 … … 2569 2554 typedef DM DirectionMap; 2570 2555 2556 typedef DigraphAdaptorExtender<OrienterBase<GR, DM> > Parent; 2571 2557 typedef typename Parent::Arc Arc; 2572 2573 2558 protected: 2574 2559 Orienter() { } 2575 2576 2560 public: 2577 2561 … … 2883 2867 template <typename DGR> 2884 2868 class SplitNodesBase { 2869 public: 2870 2871 typedef DGR Digraph; 2885 2872 typedef DigraphAdaptorBase<const DGR> Parent; 2886 2887 public:2888 2889 typedef DGR Digraph;2890 2873 typedef SplitNodesBase Adaptor; 2891 2874 … … 3246 3229 template <typename V> 3247 3230 class NodeMap 3248 : public SubMapExtender<SplitNodesBase<DGR>, NodeMapBase<V> > { 3249 typedef SubMapExtender<SplitNodesBase<DGR>, NodeMapBase<V> > Parent; 3250 3231 : public SubMapExtender<SplitNodesBase<DGR>, NodeMapBase<V> > 3232 { 3251 3233 public: 3252 3234 typedef V Value; 3235 typedef SubMapExtender<SplitNodesBase<DGR>, NodeMapBase<Value> > Parent; 3253 3236 3254 3237 NodeMap(const SplitNodesBase<DGR>& adaptor) … … 3272 3255 template <typename V> 3273 3256 class ArcMap 3274 : public SubMapExtender<SplitNodesBase<DGR>, ArcMapBase<V> > { 3275 typedef SubMapExtender<SplitNodesBase<DGR>, ArcMapBase<V> > Parent; 3276 3257 : public SubMapExtender<SplitNodesBase<DGR>, ArcMapBase<V> > 3258 { 3277 3259 public: 3278 3260 typedef V Value; 3261 typedef SubMapExtender<SplitNodesBase<DGR>, ArcMapBase<Value> > Parent; 3279 3262 3280 3263 ArcMap(const SplitNodesBase<DGR>& adaptor) … … 3342 3325 : public DigraphAdaptorExtender<SplitNodesBase<const DGR> > { 3343 3326 #endif 3327 public: 3328 typedef DGR Digraph; 3344 3329 typedef DigraphAdaptorExtender<SplitNodesBase<const DGR> > Parent; 3345 3346 public:3347 typedef DGR Digraph;3348 3330 3349 3331 typedef typename DGR::Node DigraphNode; -
lemon/bits/array_map.h
r617 r503 48 48 public: 49 49 // The graph type. 50 typedef _Graph Graph Type;50 typedef _Graph Graph; 51 51 // The item type. 52 52 typedef _Item Item; … … 64 64 typedef _Value& Reference; 65 65 66 // The map type.67 typedef ArrayMap Map;68 69 66 // The notifier type. 70 67 typedef typename ItemSetTraits<_Graph, _Item>::ItemNotifier Notifier; 71 68 72 private:73 74 69 // The MapBase of the Map which imlements the core regisitry function. 75 70 typedef typename Notifier::ObserverBase Parent; 76 71 72 private: 77 73 typedef std::allocator<Value> Allocator; 78 74 … … 82 78 // 83 79 // Graph initialized map constructor. 84 explicit ArrayMap(const Graph Type& graph) {80 explicit ArrayMap(const Graph& graph) { 85 81 Parent::attach(graph.notifier(Item())); 86 82 allocate_memory(); … … 96 92 // 97 93 // It constructs a map and initialize all of the the map. 98 ArrayMap(const Graph Type& graph, const Value& value) {94 ArrayMap(const Graph& graph, const Value& value) { 99 95 Parent::attach(graph.notifier(Item())); 100 96 allocate_memory(); -
lemon/bits/base_extender.h
r617 r440 39 39 template <typename Base> 40 40 class UndirDigraphExtender : public Base { 41 42 public: 43 41 44 typedef Base Parent; 42 43 public:44 45 45 typedef typename Parent::Arc Edge; 46 46 typedef typename Parent::Node Node; … … 281 281 template <typename Base> 282 282 class BidirBpGraphExtender : public Base { 283 public: 283 284 typedef Base Parent; 284 285 public:286 285 typedef BidirBpGraphExtender Digraph; 287 286 -
lemon/bits/default_map.h
r617 r535 154 154 class DefaultMap 155 155 : public DefaultMapSelector<_Graph, _Item, _Value>::Map { 156 public: 156 157 typedef typename DefaultMapSelector<_Graph, _Item, _Value>::Map Parent; 158 typedef DefaultMap<_Graph, _Item, _Value> Map; 157 159 158 public: 159 typedef DefaultMap<_Graph, _Item, _Value> Map; 160 161 typedef typename Parent::GraphType GraphType; 160 typedef typename Parent::Graph Graph; 162 161 typedef typename Parent::Value Value; 163 162 164 explicit DefaultMap(const Graph Type& graph) : Parent(graph) {}165 DefaultMap(const Graph Type& graph, const Value& value)163 explicit DefaultMap(const Graph& graph) : Parent(graph) {} 164 DefaultMap(const Graph& graph, const Value& value) 166 165 : Parent(graph, value) {} 167 166 -
lemon/bits/edge_set_extender.h
r617 r559 35 35 template <typename Base> 36 36 class ArcSetExtender : public Base { 37 public: 38 37 39 typedef Base Parent; 38 39 public:40 41 40 typedef ArcSetExtender Digraph; 42 41 … … 220 219 class ArcMap 221 220 : public MapExtender<DefaultMap<Digraph, Arc, _Value> > { 221 public: 222 typedef ArcSetExtender Digraph; 222 223 typedef MapExtender<DefaultMap<Digraph, Arc, _Value> > Parent; 223 224 224 public:225 225 explicit ArcMap(const Digraph& _g) 226 226 : Parent(_g) {} … … 275 275 template <typename Base> 276 276 class EdgeSetExtender : public Base { 277 278 public: 279 277 280 typedef Base Parent; 278 279 public: 280 281 typedef EdgeSetExtender Graph; 281 typedef EdgeSetExtender Digraph; 282 282 283 283 typedef typename Parent::Node Node; 284 284 typedef typename Parent::Arc Arc; 285 285 typedef typename Parent::Edge Edge; 286 286 287 287 288 int maxId(Node) const { … … 350 351 351 352 class NodeIt : public Node { 352 const Graph*graph;353 const Digraph* digraph; 353 354 public: 354 355 … … 357 358 NodeIt(Invalid i) : Node(i) { } 358 359 359 explicit NodeIt(const Graph& _graph) :graph(&_graph) {360 explicit NodeIt(const Digraph& _graph) : digraph(&_graph) { 360 361 _graph.first(static_cast<Node&>(*this)); 361 362 } 362 363 363 NodeIt(const Graph& _graph, const Node& node)364 : Node(node), graph(&_graph) {}364 NodeIt(const Digraph& _graph, const Node& node) 365 : Node(node), digraph(&_graph) {} 365 366 366 367 NodeIt& operator++() { 367 graph->next(*this);368 digraph->next(*this); 368 369 return *this; 369 370 } … … 373 374 374 375 class ArcIt : public Arc { 375 const Graph*graph;376 const Digraph* digraph; 376 377 public: 377 378 … … 380 381 ArcIt(Invalid i) : Arc(i) { } 381 382 382 explicit ArcIt(const Graph& _graph) :graph(&_graph) {383 explicit ArcIt(const Digraph& _graph) : digraph(&_graph) { 383 384 _graph.first(static_cast<Arc&>(*this)); 384 385 } 385 386 386 ArcIt(const Graph& _graph, const Arc& e) :387 Arc(e), graph(&_graph) { }387 ArcIt(const Digraph& _graph, const Arc& e) : 388 Arc(e), digraph(&_graph) { } 388 389 389 390 ArcIt& operator++() { 390 graph->next(*this);391 digraph->next(*this); 391 392 return *this; 392 393 } … … 396 397 397 398 class OutArcIt : public Arc { 398 const Graph*graph;399 const Digraph* digraph; 399 400 public: 400 401 … … 403 404 OutArcIt(Invalid i) : Arc(i) { } 404 405 405 OutArcIt(const Graph& _graph, const Node& node)406 : graph(&_graph) {406 OutArcIt(const Digraph& _graph, const Node& node) 407 : digraph(&_graph) { 407 408 _graph.firstOut(*this, node); 408 409 } 409 410 410 OutArcIt(const Graph& _graph, const Arc& arc)411 : Arc(arc), graph(&_graph) {}411 OutArcIt(const Digraph& _graph, const Arc& arc) 412 : Arc(arc), digraph(&_graph) {} 412 413 413 414 OutArcIt& operator++() { 414 graph->nextOut(*this);415 digraph->nextOut(*this); 415 416 return *this; 416 417 } … … 420 421 421 422 class InArcIt : public Arc { 422 const Graph*graph;423 const Digraph* digraph; 423 424 public: 424 425 … … 427 428 InArcIt(Invalid i) : Arc(i) { } 428 429 429 InArcIt(const Graph& _graph, const Node& node)430 : graph(&_graph) {430 InArcIt(const Digraph& _graph, const Node& node) 431 : digraph(&_graph) { 431 432 _graph.firstIn(*this, node); 432 433 } 433 434 434 InArcIt(const Graph& _graph, const Arc& arc) :435 Arc(arc), graph(&_graph) {}435 InArcIt(const Digraph& _graph, const Arc& arc) : 436 Arc(arc), digraph(&_graph) {} 436 437 437 438 InArcIt& operator++() { 438 graph->nextIn(*this);439 digraph->nextIn(*this); 439 440 return *this; 440 441 } … … 444 445 445 446 class EdgeIt : public Parent::Edge { 446 const Graph*graph;447 const Digraph* digraph; 447 448 public: 448 449 … … 451 452 EdgeIt(Invalid i) : Edge(i) { } 452 453 453 explicit EdgeIt(const Graph& _graph) :graph(&_graph) {454 explicit EdgeIt(const Digraph& _graph) : digraph(&_graph) { 454 455 _graph.first(static_cast<Edge&>(*this)); 455 456 } 456 457 457 EdgeIt(const Graph& _graph, const Edge& e) :458 Edge(e), graph(&_graph) { }458 EdgeIt(const Digraph& _graph, const Edge& e) : 459 Edge(e), digraph(&_graph) { } 459 460 460 461 EdgeIt& operator++() { 461 graph->next(*this);462 digraph->next(*this); 462 463 return *this; 463 464 } … … 467 468 class IncEdgeIt : public Parent::Edge { 468 469 friend class EdgeSetExtender; 469 const Graph*graph;470 const Digraph* digraph; 470 471 bool direction; 471 472 public: … … 475 476 IncEdgeIt(Invalid i) : Edge(i), direction(false) { } 476 477 477 IncEdgeIt(const Graph& _graph, const Node &n) :graph(&_graph) {478 IncEdgeIt(const Digraph& _graph, const Node &n) : digraph(&_graph) { 478 479 _graph.firstInc(*this, direction, n); 479 480 } 480 481 481 IncEdgeIt(const Graph& _graph, const Edge &ue, const Node &n)482 : graph(&_graph), Edge(ue) {482 IncEdgeIt(const Digraph& _graph, const Edge &ue, const Node &n) 483 : digraph(&_graph), Edge(ue) { 483 484 direction = (_graph.source(ue) == n); 484 485 } 485 486 486 487 IncEdgeIt& operator++() { 487 graph->nextInc(*this, direction);488 digraph->nextInc(*this, direction); 488 489 return *this; 489 490 } … … 534 535 template <typename _Value> 535 536 class ArcMap 536 : public MapExtender<DefaultMap<Graph, Arc, _Value> > { 537 typedef MapExtender<DefaultMap<Graph, Arc, _Value> > Parent; 538 539 public: 540 ArcMap(const Graph& _g) 537 : public MapExtender<DefaultMap<Digraph, Arc, _Value> > { 538 public: 539 typedef EdgeSetExtender Digraph; 540 typedef MapExtender<DefaultMap<Digraph, Arc, _Value> > Parent; 541 542 ArcMap(const Digraph& _g) 541 543 : Parent(_g) {} 542 ArcMap(const Graph& _g, const _Value& _v)544 ArcMap(const Digraph& _g, const _Value& _v) 543 545 : Parent(_g, _v) {} 544 546 … … 558 560 template <typename _Value> 559 561 class EdgeMap 560 : public MapExtender<DefaultMap<Graph, Edge, _Value> > { 561 typedef MapExtender<DefaultMap<Graph, Edge, _Value> > Parent; 562 563 public: 564 EdgeMap(const Graph& _g) 562 : public MapExtender<DefaultMap<Digraph, Edge, _Value> > { 563 public: 564 typedef EdgeSetExtender Digraph; 565 typedef MapExtender<DefaultMap<Digraph, Edge, _Value> > Parent; 566 567 EdgeMap(const Digraph& _g) 565 568 : Parent(_g) {} 566 569 567 EdgeMap(const Graph& _g, const _Value& _v)570 EdgeMap(const Digraph& _g, const _Value& _v) 568 571 : Parent(_g, _v) {} 569 572 -
lemon/bits/graph_adaptor_extender.h
r617 r580 27 27 template <typename _Digraph> 28 28 class DigraphAdaptorExtender : public _Digraph { 29 public: 30 29 31 typedef _Digraph Parent; 30 31 public:32 33 32 typedef _Digraph Digraph; 34 33 typedef DigraphAdaptorExtender Adaptor; … … 175 174 template <typename _Graph> 176 175 class GraphAdaptorExtender : public _Graph { 176 public: 177 177 178 typedef _Graph Parent; 178 179 public:180 181 179 typedef _Graph Graph; 182 180 typedef GraphAdaptorExtender Adaptor; -
lemon/bits/graph_extender.h
r617 r440 38 38 template <typename Base> 39 39 class DigraphExtender : public Base { 40 public: 41 40 42 typedef Base Parent; 41 42 public:43 44 43 typedef DigraphExtender Digraph; 45 44 … … 220 219 class NodeMap 221 220 : public MapExtender<DefaultMap<Digraph, Node, _Value> > { 221 public: 222 typedef DigraphExtender Digraph; 222 223 typedef MapExtender<DefaultMap<Digraph, Node, _Value> > Parent; 223 224 224 public:225 225 explicit NodeMap(const Digraph& digraph) 226 226 : Parent(digraph) {} … … 244 244 class ArcMap 245 245 : public MapExtender<DefaultMap<Digraph, Arc, _Value> > { 246 public: 247 typedef DigraphExtender Digraph; 246 248 typedef MapExtender<DefaultMap<Digraph, Arc, _Value> > Parent; 247 249 248 public:249 250 explicit ArcMap(const Digraph& digraph) 250 251 : Parent(digraph) {} … … 330 331 template <typename Base> 331 332 class GraphExtender : public Base { 333 public: 334 332 335 typedef Base Parent; 333 334 public:335 336 336 typedef GraphExtender Graph; 337 337 … … 602 602 class NodeMap 603 603 : public MapExtender<DefaultMap<Graph, Node, _Value> > { 604 public: 605 typedef GraphExtender Graph; 604 606 typedef MapExtender<DefaultMap<Graph, Node, _Value> > Parent; 605 607 606 public:607 608 NodeMap(const Graph& graph) 608 609 : Parent(graph) {} … … 626 627 class ArcMap 627 628 : public MapExtender<DefaultMap<Graph, Arc, _Value> > { 629 public: 630 typedef GraphExtender Graph; 628 631 typedef MapExtender<DefaultMap<Graph, Arc, _Value> > Parent; 629 632 630 public:631 633 ArcMap(const Graph& graph) 632 634 : Parent(graph) {} … … 650 652 class EdgeMap 651 653 : public MapExtender<DefaultMap<Graph, Edge, _Value> > { 654 public: 655 typedef GraphExtender Graph; 652 656 typedef MapExtender<DefaultMap<Graph, Edge, _Value> > Parent; 653 657 654 public:655 658 EdgeMap(const Graph& graph) 656 659 : Parent(graph) {} -
lemon/bits/map_extender.h
r617 r580 37 37 template <typename _Map> 38 38 class MapExtender : public _Map { 39 public: 40 39 41 typedef _Map Parent; 40 typedef typename Parent::GraphType GraphType;41 42 public:43 44 42 typedef MapExtender Map; 43 44 45 typedef typename Parent::Graph Graph; 45 46 typedef typename Parent::Key Item; 46 47 … … 58 59 public: 59 60 60 MapExtender(const Graph Type& graph)61 MapExtender(const Graph& graph) 61 62 : Parent(graph) {} 62 63 63 MapExtender(const Graph Type& graph, const Value& value)64 MapExtender(const Graph& graph, const Value& value) 64 65 : Parent(graph, value) {} 65 66 … … 77 78 public: 78 79 class MapIt : public Item { 79 typedef Item Parent; 80 81 public: 82 80 public: 81 82 typedef Item Parent; 83 83 typedef typename Map::Value Value; 84 84 … … 117 117 118 118 class ConstMapIt : public Item { 119 typedef Item Parent;120 121 public:119 public: 120 121 typedef Item Parent; 122 122 123 123 typedef typename Map::Value Value; … … 148 148 149 149 class ItemIt : public Item { 150 typedef Item Parent;151 152 public:150 public: 151 152 typedef Item Parent; 153 153 154 154 ItemIt() {} … … 179 179 template <typename _Graph, typename _Map> 180 180 class SubMapExtender : public _Map { 181 public: 182 181 183 typedef _Map Parent; 182 typedef _Graph GraphType;183 184 public:185 186 184 typedef SubMapExtender Map; 185 186 typedef _Graph Graph; 187 187 188 typedef typename Parent::Key Item; 188 189 … … 200 201 public: 201 202 202 SubMapExtender(const Graph Type& _graph)203 SubMapExtender(const Graph& _graph) 203 204 : Parent(_graph), graph(_graph) {} 204 205 205 SubMapExtender(const Graph Type& _graph, const Value& _value)206 SubMapExtender(const Graph& _graph, const Value& _value) 206 207 : Parent(_graph, _value), graph(_graph) {} 207 208 … … 223 224 public: 224 225 class MapIt : public Item { 225 typedef Item Parent;226 227 public:226 public: 227 228 typedef Item Parent; 228 229 typedef typename Map::Value Value; 229 230 … … 262 263 263 264 class ConstMapIt : public Item { 264 typedef Item Parent;265 266 public:265 public: 266 267 typedef Item Parent; 267 268 268 269 typedef typename Map::Value Value; … … 293 294 294 295 class ItemIt : public Item { 295 typedef Item Parent;296 297 public:296 public: 297 298 typedef Item Parent; 298 299 299 300 ItemIt() {} … … 320 321 private: 321 322 322 const Graph Type& graph;323 const Graph& graph; 323 324 324 325 }; -
lemon/bits/traits.h
r616 r440 30 30 struct InvalidType {}; 31 31 32 template <typename GR, typename _Item>32 template <typename _Graph, typename _Item> 33 33 class ItemSetTraits {}; 34 34 35 35 36 template <typename G R, typename Enable = void>36 template <typename Graph, typename Enable = void> 37 37 struct NodeNotifierIndicator { 38 38 typedef InvalidType Type; 39 39 }; 40 template <typename G R>40 template <typename Graph> 41 41 struct NodeNotifierIndicator< 42 G R,43 typename enable_if<typename G R::NodeNotifier::Notifier, void>::type44 > { 45 typedef typename G R::NodeNotifier Type;46 }; 47 48 template <typename GR>49 class ItemSetTraits< GR, typename GR::Node> {42 Graph, 43 typename enable_if<typename Graph::NodeNotifier::Notifier, void>::type 44 > { 45 typedef typename Graph::NodeNotifier Type; 46 }; 47 48 template <typename _Graph> 49 class ItemSetTraits<_Graph, typename _Graph::Node> { 50 50 public: 51 51 52 typedef GR Graph; 53 typedef GR Digraph; 54 55 typedef typename GR::Node Item; 56 typedef typename GR::NodeIt ItemIt; 57 58 typedef typename NodeNotifierIndicator<GR>::Type ItemNotifier; 59 60 template <typename V> 61 class Map : public GR::template NodeMap<V> { 62 typedef typename GR::template NodeMap<V> Parent; 63 52 typedef _Graph Graph; 53 54 typedef typename Graph::Node Item; 55 typedef typename Graph::NodeIt ItemIt; 56 57 typedef typename NodeNotifierIndicator<Graph>::Type ItemNotifier; 58 59 template <typename _Value> 60 class Map : public Graph::template NodeMap<_Value> { 64 61 public: 65 typedef typename GR::template NodeMap<V> Type; 62 typedef typename Graph::template NodeMap<_Value> Parent; 63 typedef typename Graph::template NodeMap<_Value> Type; 66 64 typedef typename Parent::Value Value; 67 65 68 Map(const G R& _digraph) : Parent(_digraph) {}69 Map(const G R& _digraph, const Value& _value)66 Map(const Graph& _digraph) : Parent(_digraph) {} 67 Map(const Graph& _digraph, const Value& _value) 70 68 : Parent(_digraph, _value) {} 71 69 … … 74 72 }; 75 73 76 template <typename G R, typename Enable = void>74 template <typename Graph, typename Enable = void> 77 75 struct ArcNotifierIndicator { 78 76 typedef InvalidType Type; 79 77 }; 80 template <typename G R>78 template <typename Graph> 81 79 struct ArcNotifierIndicator< 82 G R,83 typename enable_if<typename G R::ArcNotifier::Notifier, void>::type84 > { 85 typedef typename G R::ArcNotifier Type;86 }; 87 88 template <typename GR>89 class ItemSetTraits< GR, typename GR::Arc> {80 Graph, 81 typename enable_if<typename Graph::ArcNotifier::Notifier, void>::type 82 > { 83 typedef typename Graph::ArcNotifier Type; 84 }; 85 86 template <typename _Graph> 87 class ItemSetTraits<_Graph, typename _Graph::Arc> { 90 88 public: 91 89 92 typedef GR Graph; 93 typedef GR Digraph; 94 95 typedef typename GR::Arc Item; 96 typedef typename GR::ArcIt ItemIt; 97 98 typedef typename ArcNotifierIndicator<GR>::Type ItemNotifier; 99 100 template <typename V> 101 class Map : public GR::template ArcMap<V> { 102 typedef typename GR::template ArcMap<V> Parent; 103 90 typedef _Graph Graph; 91 92 typedef typename Graph::Arc Item; 93 typedef typename Graph::ArcIt ItemIt; 94 95 typedef typename ArcNotifierIndicator<Graph>::Type ItemNotifier; 96 97 template <typename _Value> 98 class Map : public Graph::template ArcMap<_Value> { 104 99 public: 105 typedef typename GR::template ArcMap<V> Type; 100 typedef typename Graph::template ArcMap<_Value> Parent; 101 typedef typename Graph::template ArcMap<_Value> Type; 106 102 typedef typename Parent::Value Value; 107 103 108 Map(const G R& _digraph) : Parent(_digraph) {}109 Map(const G R& _digraph, const Value& _value)104 Map(const Graph& _digraph) : Parent(_digraph) {} 105 Map(const Graph& _digraph, const Value& _value) 110 106 : Parent(_digraph, _value) {} 111 107 }; … … 113 109 }; 114 110 115 template <typename G R, typename Enable = void>111 template <typename Graph, typename Enable = void> 116 112 struct EdgeNotifierIndicator { 117 113 typedef InvalidType Type; 118 114 }; 119 template <typename G R>115 template <typename Graph> 120 116 struct EdgeNotifierIndicator< 121 G R,122 typename enable_if<typename G R::EdgeNotifier::Notifier, void>::type123 > { 124 typedef typename G R::EdgeNotifier Type;125 }; 126 127 template <typename GR>128 class ItemSetTraits< GR, typename GR::Edge> {117 Graph, 118 typename enable_if<typename Graph::EdgeNotifier::Notifier, void>::type 119 > { 120 typedef typename Graph::EdgeNotifier Type; 121 }; 122 123 template <typename _Graph> 124 class ItemSetTraits<_Graph, typename _Graph::Edge> { 129 125 public: 130 126 131 typedef GR Graph; 132 typedef GR Digraph; 133 134 typedef typename GR::Edge Item; 135 typedef typename GR::EdgeIt ItemIt; 136 137 typedef typename EdgeNotifierIndicator<GR>::Type ItemNotifier; 138 139 template <typename V> 140 class Map : public GR::template EdgeMap<V> { 141 typedef typename GR::template EdgeMap<V> Parent; 142 127 typedef _Graph Graph; 128 129 typedef typename Graph::Edge Item; 130 typedef typename Graph::EdgeIt ItemIt; 131 132 typedef typename EdgeNotifierIndicator<Graph>::Type ItemNotifier; 133 134 template <typename _Value> 135 class Map : public Graph::template EdgeMap<_Value> { 143 136 public: 144 typedef typename GR::template EdgeMap<V> Type; 137 typedef typename Graph::template EdgeMap<_Value> Parent; 138 typedef typename Graph::template EdgeMap<_Value> Type; 145 139 typedef typename Parent::Value Value; 146 140 147 Map(const G R& _digraph) : Parent(_digraph) {}148 Map(const G R& _digraph, const Value& _value)141 Map(const Graph& _digraph) : Parent(_digraph) {} 142 Map(const Graph& _digraph, const Value& _value) 149 143 : Parent(_digraph, _value) {} 150 144 }; … … 211 205 // Indicators for the tags 212 206 213 template <typename G R, typename Enable = void>207 template <typename Graph, typename Enable = void> 214 208 struct NodeNumTagIndicator { 215 209 static const bool value = false; 216 210 }; 217 211 218 template <typename G R>212 template <typename Graph> 219 213 struct NodeNumTagIndicator< 220 G R,221 typename enable_if<typename G R::NodeNumTag, void>::type222 > { 223 static const bool value = true; 224 }; 225 226 template <typename G R, typename Enable = void>214 Graph, 215 typename enable_if<typename Graph::NodeNumTag, void>::type 216 > { 217 static const bool value = true; 218 }; 219 220 template <typename Graph, typename Enable = void> 227 221 struct ArcNumTagIndicator { 228 222 static const bool value = false; 229 223 }; 230 224 231 template <typename G R>225 template <typename Graph> 232 226 struct ArcNumTagIndicator< 233 G R,234 typename enable_if<typename G R::ArcNumTag, void>::type235 > { 236 static const bool value = true; 237 }; 238 239 template <typename G R, typename Enable = void>227 Graph, 228 typename enable_if<typename Graph::ArcNumTag, void>::type 229 > { 230 static const bool value = true; 231 }; 232 233 template <typename Graph, typename Enable = void> 240 234 struct EdgeNumTagIndicator { 241 235 static const bool value = false; 242 236 }; 243 237 244 template <typename G R>238 template <typename Graph> 245 239 struct EdgeNumTagIndicator< 246 G R,247 typename enable_if<typename G R::EdgeNumTag, void>::type248 > { 249 static const bool value = true; 250 }; 251 252 template <typename G R, typename Enable = void>240 Graph, 241 typename enable_if<typename Graph::EdgeNumTag, void>::type 242 > { 243 static const bool value = true; 244 }; 245 246 template <typename Graph, typename Enable = void> 253 247 struct FindArcTagIndicator { 254 248 static const bool value = false; 255 249 }; 256 250 257 template <typename G R>251 template <typename Graph> 258 252 struct FindArcTagIndicator< 259 G R,260 typename enable_if<typename G R::FindArcTag, void>::type261 > { 262 static const bool value = true; 263 }; 264 265 template <typename G R, typename Enable = void>253 Graph, 254 typename enable_if<typename Graph::FindArcTag, void>::type 255 > { 256 static const bool value = true; 257 }; 258 259 template <typename Graph, typename Enable = void> 266 260 struct FindEdgeTagIndicator { 267 261 static const bool value = false; 268 262 }; 269 263 270 template <typename G R>264 template <typename Graph> 271 265 struct FindEdgeTagIndicator< 272 G R,273 typename enable_if<typename G R::FindEdgeTag, void>::type274 > { 275 static const bool value = true; 276 }; 277 278 template <typename G R, typename Enable = void>266 Graph, 267 typename enable_if<typename Graph::FindEdgeTag, void>::type 268 > { 269 static const bool value = true; 270 }; 271 272 template <typename Graph, typename Enable = void> 279 273 struct UndirectedTagIndicator { 280 274 static const bool value = false; 281 275 }; 282 276 283 template <typename G R>277 template <typename Graph> 284 278 struct UndirectedTagIndicator< 285 G R,286 typename enable_if<typename G R::UndirectedTag, void>::type287 > { 288 static const bool value = true; 289 }; 290 291 template <typename G R, typename Enable = void>279 Graph, 280 typename enable_if<typename Graph::UndirectedTag, void>::type 281 > { 282 static const bool value = true; 283 }; 284 285 template <typename Graph, typename Enable = void> 292 286 struct BuildTagIndicator { 293 287 static const bool value = false; 294 288 }; 295 289 296 template <typename G R>290 template <typename Graph> 297 291 struct BuildTagIndicator< 298 G R,299 typename enable_if<typename G R::BuildTag, void>::type292 Graph, 293 typename enable_if<typename Graph::BuildTag, void>::type 300 294 > { 301 295 static const bool value = true; -
lemon/bits/vector_map.h
r617 r503 57 57 58 58 // The graph type of the map. 59 typedef _Graph Graph Type;59 typedef _Graph Graph; 60 60 // The item type of the map. 61 61 typedef _Item Item; … … 73 73 // The map type. 74 74 typedef VectorMap Map; 75 // The base class of the map. 76 typedef typename Notifier::ObserverBase Parent; 75 77 76 78 // The reference type of the map; … … 79 81 typedef typename Container::const_reference ConstReference; 80 82 81 private:82 83 // The base class of the map.84 typedef typename Notifier::ObserverBase Parent;85 86 public:87 83 88 84 // \brief Constructor to attach the new map into the notifier. … … 90 86 // It constructs a map and attachs it into the notifier. 91 87 // It adds all the items of the graph to the map. 92 VectorMap(const Graph Type& graph) {88 VectorMap(const Graph& graph) { 93 89 Parent::attach(graph.notifier(Item())); 94 90 container.resize(Parent::notifier()->maxId() + 1); … … 99 95 // It constructs a map uses a given value to initialize the map. 100 96 // It adds all the items of the graph to the map. 101 VectorMap(const Graph Type& graph, const Value& value) {97 VectorMap(const Graph& graph, const Value& value) { 102 98 Parent::attach(graph.notifier(Item())); 103 99 container.resize(Parent::notifier()->maxId() + 1, value); -
lemon/circulation.h
r622 r611 22 22 #include <lemon/tolerance.h> 23 23 #include <lemon/elevator.h> 24 #include <limits>25 24 26 25 ///\ingroup max_flow … … 121 120 122 121 The exact formulation of this problem is the following. 123 Let \f$G=(V,A)\f$ be a digraph, \f$lower: A\rightarrow\mathbf{R}\f$124 \f$ upper: A\rightarrow\mathbf{R}\cup\{\infty\}\f$ denote the lower and125 upper bounds on the arcs, for which \f$ lower(uv) \leq upper(uv)\f$122 Let \f$G=(V,A)\f$ be a digraph, 123 \f$lower, upper: A\rightarrow\mathbf{R}^+_0\f$ denote the lower and 124 upper bounds on the arcs, for which \f$0 \leq lower(uv) \leq upper(uv)\f$ 126 125 holds for all \f$uv\in A\f$, and \f$sup: V\rightarrow\mathbf{R}\f$ 127 126 denotes the signed supply values of the nodes. … … 129 128 supply, if \f$sup(u)<0\f$, then \f$u\f$ is a demand node with 130 129 \f$-sup(u)\f$ demand. 131 A feasible circulation is an \f$f: A\rightarrow\mathbf{R} \f$130 A feasible circulation is an \f$f: A\rightarrow\mathbf{R}^+_0\f$ 132 131 solution of the following problem. 133 132 … … 152 151 the direction of the arcs and taking the negative of the supply values 153 152 (e.g. using \ref ReverseDigraph and \ref NegMap adaptors). 154 155 This algorithm either calculates a feasible circulation, or provides156 a \ref barrier() "barrier", which prooves that a feasible soultion157 cannot exist.158 153 159 154 Note that this algorithm also provides a feasible solution for the … … 343 338 private: 344 339 345 bool checkBoundMaps() {346 for (ArcIt e(_g);e!=INVALID;++e) {347 if (_tol.less((*_up)[e], (*_lo)[e])) return false;348 }349 return true;350 }351 352 340 void createStructures() { 353 341 _node_num = _el = countNodes(_g); … … 393 381 /// Sets the upper bound (capacity) map. 394 382 /// \return <tt>(*this)</tt> 395 Circulation& upperMap(const UpperMap& map) {383 Circulation& upperMap(const LowerMap& map) { 396 384 _up = ↦ 397 385 return *this; … … 480 468 void init() 481 469 { 482 LEMON_DEBUG(checkBoundMaps(),483 "Upper bounds must be greater or equal to the lower bounds");484 485 470 createStructures(); 486 471 … … 512 497 void greedyInit() 513 498 { 514 LEMON_DEBUG(checkBoundMaps(),515 "Upper bounds must be greater or equal to the lower bounds");516 517 499 createStructures(); 518 500 … … 522 504 523 505 for (ArcIt e(_g);e!=INVALID;++e) { 524 if (!_tol. less(-(*_excess)[_g.target(e)],(*_up)[e])) {506 if (!_tol.positive((*_excess)[_g.target(e)] + (*_up)[e])) { 525 507 _flow->set(e, (*_up)[e]); 526 508 (*_excess)[_g.target(e)] += (*_up)[e]; 527 509 (*_excess)[_g.source(e)] -= (*_up)[e]; 528 } else if (_tol. less(-(*_excess)[_g.target(e)],(*_lo)[e])) {510 } else if (_tol.positive((*_excess)[_g.target(e)] + (*_lo)[e])) { 529 511 _flow->set(e, (*_lo)[e]); 530 512 (*_excess)[_g.target(e)] += (*_lo)[e]; … … 767 749 { 768 750 Flow delta=0; 769 Flow inf_cap = std::numeric_limits<Flow>::has_infinity ?770 std::numeric_limits<Flow>::infinity() :771 std::numeric_limits<Flow>::max();772 751 for(NodeIt n(_g);n!=INVALID;++n) 773 752 if(barrier(n)) … … 777 756 Node s=_g.source(e); 778 757 Node t=_g.target(e); 779 if(barrier(s)&&!barrier(t)) { 780 if (_tol.less(inf_cap - (*_up)[e], delta)) return false; 781 delta+=(*_up)[e]; 782 } 758 if(barrier(s)&&!barrier(t)) delta+=(*_up)[e]; 783 759 else if(barrier(t)&&!barrier(s)) delta-=(*_lo)[e]; 784 760 } -
lemon/concepts/graph_components.h
r617 r584 181 181 class BaseGraphComponent : public BaseDigraphComponent { 182 182 public: 183 184 typedef BaseGraphComponent Graph;185 186 183 typedef BaseDigraphComponent::Node Node; 187 184 typedef BaseDigraphComponent::Arc Arc; … … 193 190 /// represented by two opposite directed arcs. 194 191 class Edge : public GraphItem<'e'> { 192 public: 195 193 typedef GraphItem<'e'> Parent; 196 194 197 public:198 195 /// \brief Default constructor. 199 196 /// … … 995 992 template <typename GR, typename K, typename V> 996 993 class GraphMap : public ReferenceMap<K, V, V&, const V&> { 997 typedef ReferenceMap<K, V, V&, const V&> Parent; 998 999 public: 1000 994 public: 995 996 typedef ReadWriteMap<K, V> Parent; 997 998 /// The graph type of the map. 999 typedef GR Graph; 1001 1000 /// The key type of the map. 1002 1001 typedef K Key; … … 1014 1013 /// 1015 1014 /// Construct a new map for the graph. 1016 explicit GraphMap(const G R&) {}1015 explicit GraphMap(const Graph&) {} 1017 1016 /// \brief Construct a new map with default value. 1018 1017 /// 1019 1018 /// Construct a new map for the graph and initalize the values. 1020 GraphMap(const G R&, const Value&) {}1019 GraphMap(const Graph&, const Value&) {} 1021 1020 1022 1021 private: … … 1059 1058 1060 1059 const _Map &m; 1061 const G R&g;1060 const Graph &g; 1062 1061 const typename GraphMap::Value &t; 1063 1062 }; … … 1087 1086 template <typename V> 1088 1087 class NodeMap : public GraphMap<MappableDigraphComponent, Node, V> { 1088 public: 1089 1089 typedef GraphMap<MappableDigraphComponent, Node, V> Parent; 1090 1090 1091 public:1092 1091 /// \brief Construct a new map. 1093 1092 /// … … 1125 1124 template <typename V> 1126 1125 class ArcMap : public GraphMap<MappableDigraphComponent, Arc, V> { 1126 public: 1127 1127 typedef GraphMap<MappableDigraphComponent, Arc, V> Parent; 1128 1128 1129 public:1130 1129 /// \brief Construct a new map. 1131 1130 /// … … 1223 1222 template <typename V> 1224 1223 class EdgeMap : public GraphMap<MappableGraphComponent, Edge, V> { 1224 public: 1225 1225 typedef GraphMap<MappableGraphComponent, Edge, V> Parent; 1226 1226 1227 public:1228 1227 /// \brief Construct a new map. 1229 1228 /// -
lemon/core.h
r617 r581 1037 1037 template <typename GR> 1038 1038 class ConArcIt : public GR::Arc { 1039 typedef typename GR::Arc Parent;1040 1041 1039 public: 1042 1040 1043 typedef typename GR::Arc Arc; 1044 typedef typename GR::Node Node; 1041 typedef GR Graph; 1042 typedef typename Graph::Arc Parent; 1043 1044 typedef typename Graph::Arc Arc; 1045 typedef typename Graph::Node Node; 1045 1046 1046 1047 /// \brief Constructor. … … 1048 1049 /// Construct a new ConArcIt iterating on the arcs that 1049 1050 /// connects nodes \c u and \c v. 1050 ConArcIt(const G R& g, Node u, Node v) : _graph(g) {1051 ConArcIt(const Graph& g, Node u, Node v) : _graph(g) { 1051 1052 Parent::operator=(findArc(_graph, u, v)); 1052 1053 } … … 1055 1056 /// 1056 1057 /// Construct a new ConArcIt that continues the iterating from arc \c a. 1057 ConArcIt(const G R& g, Arc a) : Parent(a), _graph(g) {}1058 ConArcIt(const Graph& g, Arc a) : Parent(a), _graph(g) {} 1058 1059 1059 1060 /// \brief Increment operator. … … 1066 1067 } 1067 1068 private: 1068 const G R& _graph;1069 const Graph& _graph; 1069 1070 }; 1070 1071 … … 1159 1160 template <typename GR> 1160 1161 class ConEdgeIt : public GR::Edge { 1161 typedef typename GR::Edge Parent;1162 1163 1162 public: 1164 1163 1165 typedef typename GR::Edge Edge; 1166 typedef typename GR::Node Node; 1164 typedef GR Graph; 1165 typedef typename Graph::Edge Parent; 1166 1167 typedef typename Graph::Edge Edge; 1168 typedef typename Graph::Node Node; 1167 1169 1168 1170 /// \brief Constructor. … … 1170 1172 /// Construct a new ConEdgeIt iterating on the edges that 1171 1173 /// connects nodes \c u and \c v. 1172 ConEdgeIt(const G R& g, Node u, Node v) : _graph(g), _u(u), _v(v) {1174 ConEdgeIt(const Graph& g, Node u, Node v) : _graph(g), _u(u), _v(v) { 1173 1175 Parent::operator=(findEdge(_graph, _u, _v)); 1174 1176 } … … 1177 1179 /// 1178 1180 /// Construct a new ConEdgeIt that continues iterating from edge \c e. 1179 ConEdgeIt(const G R& g, Edge e) : Parent(e), _graph(g) {}1181 ConEdgeIt(const Graph& g, Edge e) : Parent(e), _graph(g) {} 1180 1182 1181 1183 /// \brief Increment operator. … … 1187 1189 } 1188 1190 private: 1189 const G R& _graph;1191 const Graph& _graph; 1190 1192 Node _u, _v; 1191 1193 }; … … 1218 1220 : protected ItemSetTraits<GR, typename GR::Arc>::ItemNotifier::ObserverBase 1219 1221 { 1222 public: 1220 1223 typedef typename ItemSetTraits<GR, typename GR::Arc> 1221 1224 ::ItemNotifier::ObserverBase Parent; 1222 1225 1223 1226 TEMPLATE_DIGRAPH_TYPEDEFS(GR); 1224 1225 public:1226 1227 /// The Digraph type1228 1227 typedef GR Digraph; 1229 1228 … … 1231 1230 1232 1231 class AutoNodeMap : public ItemSetTraits<GR, Node>::template Map<Arc>::Type { 1232 public: 1233 1233 1234 typedef typename ItemSetTraits<GR, Node>::template Map<Arc>::Type Parent; 1234 1235 public:1236 1235 1237 1236 AutoNodeMap(const GR& digraph) : Parent(digraph, INVALID) {} … … 1258 1257 } 1259 1258 }; 1259 1260 const Digraph &_g; 1261 AutoNodeMap _head; 1262 typename Digraph::template ArcMap<Arc> _parent; 1263 typename Digraph::template ArcMap<Arc> _left; 1264 typename Digraph::template ArcMap<Arc> _right; 1260 1265 1261 1266 class ArcLess { … … 1268 1273 } 1269 1274 }; 1270 1271 protected:1272 1273 const Digraph &_g;1274 AutoNodeMap _head;1275 typename Digraph::template ArcMap<Arc> _parent;1276 typename Digraph::template ArcMap<Arc> _left;1277 typename Digraph::template ArcMap<Arc> _right;1278 1275 1279 1276 public: … … 1634 1631 class ArcLookUp 1635 1632 { 1633 public: 1636 1634 TEMPLATE_DIGRAPH_TYPEDEFS(GR); 1637 1638 public:1639 1640 /// The Digraph type1641 1635 typedef GR Digraph; 1642 1636 … … 1753 1747 1754 1748 TEMPLATE_DIGRAPH_TYPEDEFS(GR); 1755 1756 typename GR::template ArcMap<Arc> _next; 1749 typedef GR Digraph; 1750 1751 typename Digraph::template ArcMap<Arc> _next; 1757 1752 1758 1753 Arc refreshNext(Arc head,Arc next=INVALID) … … 1773 1768 1774 1769 public: 1775 1776 /// The Digraph type1777 typedef GR Digraph;1778 1779 1770 ///Constructor 1780 1771 -
lemon/edge_set.h
r617 r559 34 34 public: 35 35 36 typedef GR Graph; 36 37 typedef typename GR::Node Node; 37 38 typedef typename GR::NodeIt NodeIt; … … 208 209 template <typename V> 209 210 class NodeMap : public GR::template NodeMap<V> { 211 public: 212 210 213 typedef typename GR::template NodeMap<V> Parent; 211 212 public:213 214 214 215 explicit NodeMap(const ListArcSetBase<GR>& arcset) … … 259 260 template <typename GR> 260 261 class ListArcSet : public ArcSetExtender<ListArcSetBase<GR> > { 262 263 public: 264 261 265 typedef ArcSetExtender<ListArcSetBase<GR> > Parent; 262 263 public:264 266 265 267 typedef typename Parent::Node Node; 266 268 typedef typename Parent::Arc Arc; 269 270 typedef GR Graph; 271 267 272 268 273 typedef typename Parent::NodesImplBase NodesImplBase; … … 288 293 289 294 class NodesImpl : public NodesImplBase { 295 public: 290 296 typedef NodesImplBase Parent; 291 297 292 public:293 298 NodesImpl(const GR& graph, ListArcSet& arcset) 294 299 : Parent(graph), _arcset(arcset) {} … … 350 355 public: 351 356 357 typedef GR Graph; 352 358 typedef typename GR::Node Node; 353 359 typedef typename GR::NodeIt NodeIt; … … 632 638 template <typename V> 633 639 class NodeMap : public GR::template NodeMap<V> { 640 public: 641 634 642 typedef typename GR::template NodeMap<V> Parent; 635 636 public:637 643 638 644 explicit NodeMap(const ListEdgeSetBase<GR>& arcset) … … 683 689 template <typename GR> 684 690 class ListEdgeSet : public EdgeSetExtender<ListEdgeSetBase<GR> > { 691 692 public: 693 685 694 typedef EdgeSetExtender<ListEdgeSetBase<GR> > Parent; 686 687 public:688 695 689 696 typedef typename Parent::Node Node; 690 697 typedef typename Parent::Arc Arc; 691 698 typedef typename Parent::Edge Edge; 699 700 typedef GR Graph; 701 692 702 693 703 typedef typename Parent::NodesImplBase NodesImplBase; … … 708 718 709 719 class NodesImpl : public NodesImplBase { 720 public: 710 721 typedef NodesImplBase Parent; 711 722 712 public:713 723 NodesImpl(const GR& graph, ListEdgeSet& arcset) 714 724 : Parent(graph), _arcset(arcset) {} … … 770 780 public: 771 781 772 typedef typename GR::Node Node; 773 typedef typename GR::NodeIt NodeIt; 782 typedef GR Graph; 783 typedef typename Graph::Node Node; 784 typedef typename Graph::NodeIt NodeIt; 774 785 775 786 protected: … … 890 901 template <typename V> 891 902 class NodeMap : public GR::template NodeMap<V> { 903 public: 904 892 905 typedef typename GR::template NodeMap<V> Parent; 893 894 public:895 906 896 907 explicit NodeMap(const SmartArcSetBase<GR>& arcset) … … 946 957 template <typename GR> 947 958 class SmartArcSet : public ArcSetExtender<SmartArcSetBase<GR> > { 959 960 public: 961 948 962 typedef ArcSetExtender<SmartArcSetBase<GR> > Parent; 949 950 public:951 963 952 964 typedef typename Parent::Node Node; 953 965 typedef typename Parent::Arc Arc; 966 967 typedef GR Graph; 954 968 955 969 protected: … … 970 984 971 985 class NodesImpl : public NodesImplBase { 986 public: 972 987 typedef NodesImplBase Parent; 973 988 974 public:975 989 NodesImpl(const GR& graph, SmartArcSet& arcset) 976 990 : Parent(graph), _arcset(arcset) {} … … 1049 1063 public: 1050 1064 1065 typedef GR Graph; 1051 1066 typedef typename GR::Node Node; 1052 1067 typedef typename GR::NodeIt NodeIt; … … 1235 1250 template <typename V> 1236 1251 class NodeMap : public GR::template NodeMap<V> { 1252 public: 1253 1237 1254 typedef typename GR::template NodeMap<V> Parent; 1238 1239 public:1240 1255 1241 1256 explicit NodeMap(const SmartEdgeSetBase<GR>& arcset) … … 1290 1305 template <typename GR> 1291 1306 class SmartEdgeSet : public EdgeSetExtender<SmartEdgeSetBase<GR> > { 1307 1308 public: 1309 1292 1310 typedef EdgeSetExtender<SmartEdgeSetBase<GR> > Parent; 1293 1294 public:1295 1311 1296 1312 typedef typename Parent::Node Node; … … 1298 1314 typedef typename Parent::Edge Edge; 1299 1315 1316 typedef GR Graph; 1317 1300 1318 protected: 1301 1319 … … 1314 1332 1315 1333 class NodesImpl : public NodesImplBase { 1334 public: 1316 1335 typedef NodesImplBase Parent; 1317 1336 1318 public:1319 1337 NodesImpl(const GR& graph, SmartEdgeSet& arcset) 1320 1338 : Parent(graph), _arcset(arcset) {} -
lemon/full_graph.h
r617 r582 32 32 public: 33 33 34 typedef FullDigraphBase Digraph;34 typedef FullDigraphBase Graph; 35 35 36 36 class Node; … … 170 170 /// \sa FullGraph 171 171 class FullDigraph : public ExtendedFullDigraphBase { 172 public: 173 172 174 typedef ExtendedFullDigraphBase Parent; 173 174 public:175 175 176 176 /// \brief Constructor … … 227 227 228 228 class FullGraphBase { 229 int _node_num; 230 int _edge_num; 229 231 public: 230 232 … … 236 238 237 239 protected: 238 239 int _node_num;240 int _edge_num;241 240 242 241 FullGraphBase() {} … … 539 538 /// \sa FullDigraph 540 539 class FullGraph : public ExtendedFullGraphBase { 540 public: 541 541 542 typedef ExtendedFullGraphBase Parent; 542 543 public:544 543 545 544 /// \brief Constructor -
lemon/graph_to_eps.h
r617 r584 70 70 { 71 71 typedef GR Graph; 72 typedef GR Digraph;73 72 typedef typename Graph::Node Node; 74 73 typedef typename Graph::NodeIt NodeIt; … … 243 242 244 243 typedef typename T::Graph Graph; 245 typedef typename T::Digraph Digraph;246 244 typedef typename Graph::Node Node; 247 245 typedef typename Graph::NodeIt NodeIt; -
lemon/grid_graph.h
r617 r582 500 500 /// "Graph concept". 501 501 class GridGraph : public ExtendedGridGraphBase { 502 public: 503 502 504 typedef ExtendedGridGraphBase Parent; 503 504 public:505 505 506 506 /// \brief Map to get the indices of the nodes as dim2::Point<int>. -
lemon/hypercube_graph.h
r617 r582 295 295 /// "Graph concept". 296 296 class HypercubeGraph : public ExtendedHypercubeGraphBase { 297 public: 298 297 299 typedef ExtendedHypercubeGraphBase Parent; 298 299 public:300 300 301 301 /// \brief Constructs a hypercube graph with \c dim dimensions. -
lemon/list_graph.h
r617 r582 324 324 325 325 class ListDigraph : public ExtendedListDigraphBase { 326 typedef ExtendedListDigraphBase Parent;327 328 326 private: 329 327 ///ListDigraph is \e not copy constructible. Use copyDigraph() instead. … … 339 337 void operator=(const ListDigraph &) {} 340 338 public: 339 340 typedef ExtendedListDigraphBase Parent; 341 341 342 342 /// Constructor … … 794 794 public: 795 795 796 typedef ListGraphBase Graph;796 typedef ListGraphBase Digraph; 797 797 798 798 class Node; … … 1177 1177 1178 1178 class ListGraph : public ExtendedListGraphBase { 1179 typedef ExtendedListGraphBase Parent;1180 1181 1179 private: 1182 1180 ///ListGraph is \e not copy constructible. Use copyGraph() instead. … … 1197 1195 /// 1198 1196 ListGraph() {} 1197 1198 typedef ExtendedListGraphBase Parent; 1199 1199 1200 1200 typedef Parent::OutArcIt IncEdgeIt; -
lemon/maps.h
r617 r584 1839 1839 /// The graph type of IdMap. 1840 1840 typedef GR Graph; 1841 typedef GR Digraph;1842 1841 /// The key type of IdMap (\c Node, \c Arc or \c Edge). 1843 1842 typedef K Item; … … 1931 1930 /// The graph type of CrossRefMap. 1932 1931 typedef GR Graph; 1933 typedef GR Digraph;1934 1932 /// The key type of CrossRefMap (\c Node, \c Arc or \c Edge). 1935 1933 typedef K Item; … … 2135 2133 /// The graph type of RangeIdMap. 2136 2134 typedef GR Graph; 2137 typedef GR Digraph;2138 2135 /// The key type of RangeIdMap (\c Node, \c Arc or \c Edge). 2139 2136 typedef K Item; … … 2498 2495 public: 2499 2496 2500 /// The graph type of InDegMap 2501 typedef GR Graph; 2497 /// The digraph type 2502 2498 typedef GR Digraph; 2503 2499 /// The key type … … 2628 2624 public: 2629 2625 2630 /// The graph type of OutDegMap 2631 typedef GR Graph; 2626 /// The digraph type 2632 2627 typedef GR Digraph; 2633 2628 /// The key type -
lemon/network_simplex.h
r618 r609 382 382 const int MIN_BLOCK_SIZE = 10; 383 383 384 _block_size = std::max( int(BLOCK_SIZE_FACTOR * 385 std::sqrt(double(_arc_num))), 384 _block_size = std::max( int(BLOCK_SIZE_FACTOR * sqrt(_arc_num)), 386 385 MIN_BLOCK_SIZE ); 387 386 } … … 459 458 const int MIN_MINOR_LIMIT = 3; 460 459 461 _list_length = std::max( int(LIST_LENGTH_FACTOR * 462 std::sqrt(double(_arc_num))), 460 _list_length = std::max( int(LIST_LENGTH_FACTOR * sqrt(_arc_num)), 463 461 MIN_LIST_LENGTH ); 464 462 _minor_limit = std::max( int(MINOR_LIMIT_FACTOR * _list_length), … … 580 578 const int MIN_HEAD_LENGTH = 3; 581 579 582 _block_size = std::max( int(BLOCK_SIZE_FACTOR * 583 std::sqrt(double(_arc_num))), 580 _block_size = std::max( int(BLOCK_SIZE_FACTOR * sqrt(_arc_num)), 584 581 MIN_BLOCK_SIZE ); 585 582 _head_length = std::max( int(HEAD_LENGTH_FACTOR * _block_size), … … 1148 1145 // Run Circulation to check if a feasible solution exists 1149 1146 typedef ConstMap<Arc, Flow> ConstArcMap; 1150 ConstArcMap zero_arc_map(0), inf_arc_map(inf_cap);1151 1147 FlowNodeMap *csup = NULL; 1152 1148 bool local_csup = false; … … 1169 1165 } else { 1170 1166 Circulation<GR, FlowArcMap, ConstArcMap, FlowNodeMap> 1171 circ(_graph, *_plower, inf_arc_map, *csup);1167 circ(_graph, *_plower, ConstArcMap(inf_cap), *csup); 1172 1168 circ_result = circ.run(); 1173 1169 } … … 1175 1171 if (_pupper) { 1176 1172 Circulation<GR, ConstArcMap, FlowArcMap, FlowNodeMap> 1177 circ(_graph, zero_arc_map, *_pupper, *csup);1173 circ(_graph, ConstArcMap(0), *_pupper, *csup); 1178 1174 circ_result = circ.run(); 1179 1175 } else { 1180 1176 Circulation<GR, ConstArcMap, ConstArcMap, FlowNodeMap> 1181 circ(_graph, zero_arc_map, inf_arc_map, *csup);1177 circ(_graph, ConstArcMap(0), ConstArcMap(inf_cap), *csup); 1182 1178 circ_result = circ.run(); 1183 1179 } … … 1196 1192 } else { 1197 1193 Circulation<RevGraph, FlowArcMap, ConstArcMap, NegNodeMap> 1198 circ(rgraph, *_plower, inf_arc_map, neg_csup);1194 circ(rgraph, *_plower, ConstArcMap(inf_cap), neg_csup); 1199 1195 circ_result = circ.run(); 1200 1196 } … … 1202 1198 if (_pupper) { 1203 1199 Circulation<RevGraph, ConstArcMap, FlowArcMap, NegNodeMap> 1204 circ(rgraph, zero_arc_map, *_pupper, neg_csup);1200 circ(rgraph, ConstArcMap(0), *_pupper, neg_csup); 1205 1201 circ_result = circ.run(); 1206 1202 } else { 1207 1203 Circulation<RevGraph, ConstArcMap, ConstArcMap, NegNodeMap> 1208 circ(rgraph, zero_arc_map, inf_arc_map, neg_csup);1204 circ(rgraph, ConstArcMap(0), ConstArcMap(inf_cap), neg_csup); 1209 1205 circ_result = circ.run(); 1210 1206 } … … 1230 1226 1231 1227 // Store the arcs in a mixed order 1232 int k = std::max(int(s td::sqrt(double(_arc_num))), 10);1228 int k = std::max(int(sqrt(_arc_num)), 10); 1233 1229 int i = 0; 1234 1230 for (ArcIt e(_graph); e != INVALID; ++e) { -
lemon/smart_graph.h
r617 r582 56 56 public: 57 57 58 typedef SmartDigraphBase Digraph;58 typedef SmartDigraphBase Graph; 59 59 60 60 class Node; … … 196 196 ///\sa concepts::Digraph. 197 197 class SmartDigraph : public ExtendedSmartDigraphBase { 198 public: 199 198 200 typedef ExtendedSmartDigraphBase Parent; 199 201 … … 419 421 public: 420 422 421 typedef SmartGraphBase Graph;423 typedef SmartGraphBase Digraph; 422 424 423 425 class Node; … … 630 632 /// \sa concepts::Graph. 631 633 class SmartGraph : public ExtendedSmartGraphBase { 632 typedef ExtendedSmartGraphBase Parent;633 634 634 private: 635 635 … … 648 648 649 649 public: 650 651 typedef ExtendedSmartGraphBase Parent; 650 652 651 653 /// Constructor -
lemon/suurballe.h
r623 r584 26 26 27 27 #include <vector> 28 #include <limits>29 28 #include <lemon/bin_heap.h> 30 29 #include <lemon/path.h> … … 44 43 /// from a given source node to a given target node in a digraph. 45 44 /// 46 /// Note that this problem is a special case of the \ref min_cost_flow 47 /// "minimum cost flow problem". This implementation is actually an 48 /// efficient specialized version of the \ref CapacityScaling 49 /// "Successive Shortest Path" algorithm directly for this problem. 50 /// Therefore this class provides query functions for flow values and 51 /// node potentials (the dual solution) just like the minimum cost flow 52 /// algorithms. 45 /// In fact, this implementation is the specialization of the 46 /// \ref CapacityScaling "successive shortest path" algorithm. 53 47 /// 54 48 /// \tparam GR The digraph type the algorithm runs on. 55 /// \tparam LEN The type of the length map. 56 /// The default value is <tt>GR::ArcMap<int></tt>. 49 /// The default value is \c ListDigraph. 50 /// \tparam LEN The type of the length (cost) map. 51 /// The default value is <tt>Digraph::ArcMap<int></tt>. 57 52 /// 58 53 /// \warning Length values should be \e non-negative \e integers. 59 54 /// 60 55 /// \note For finding node-disjoint paths this algorithm can be used 61 /// along with the \ref SplitNodes adaptor.56 /// with \ref SplitNodes. 62 57 #ifdef DOXYGEN 63 58 template <typename GR, typename LEN> 64 59 #else 65 template < typename GR ,60 template < typename GR = ListDigraph, 66 61 typename LEN = typename GR::template ArcMap<int> > 67 62 #endif … … 81 76 /// The type of the lengths. 82 77 typedef typename LengthMap::Value Length; 83 #ifdef DOXYGEN84 /// The type of the flow map.85 typedef GR::ArcMap<int> FlowMap;86 /// The type of the potential map.87 typedef GR::NodeMap<Length> PotentialMap;88 #else89 78 /// The type of the flow map. 90 79 typedef typename Digraph::template ArcMap<int> FlowMap; 91 80 /// The type of the potential map. 92 81 typedef typename Digraph::template NodeMap<Length> PotentialMap; 93 #endif94 95 82 /// The type of the path structures. 96 typedef SimplePath< GR> Path;83 typedef SimplePath<Digraph> Path; 97 84 98 85 private: 99 86 100 // ResidualDijkstra is a special implementation of the 101 // Dijkstra algorithm for finding shortest paths in the 102 // residual network with respect to the reduced arc lengths 103 // and modifying the node potentials according to the 104 // distance of the nodes. 87 /// \brief Special implementation of the Dijkstra algorithm 88 /// for finding shortest paths in the residual network. 89 /// 90 /// \ref ResidualDijkstra is a special implementation of the 91 /// \ref Dijkstra algorithm for finding shortest paths in the 92 /// residual network of the digraph with respect to the reduced arc 93 /// lengths and modifying the node potentials according to the 94 /// distance of the nodes. 105 95 class ResidualDijkstra 106 96 { … … 131 121 132 122 /// Constructor. 133 ResidualDijkstra( const Digraph & graph,123 ResidualDijkstra( const Digraph &digraph, 134 124 const FlowMap &flow, 135 125 const LengthMap &length, … … 137 127 PredMap &pred, 138 128 Node s, Node t ) : 139 _graph( graph), _flow(flow), _length(length), _potential(potential),140 _dist( graph), _pred(pred), _s(s), _t(t) {}129 _graph(digraph), _flow(flow), _length(length), _potential(potential), 130 _dist(digraph), _pred(pred), _s(s), _t(t) {} 141 131 142 132 /// \brief Run the algorithm. It returns \c true if a path is found … … 247 237 /// Constructor. 248 238 /// 249 /// \param graph The digraph the algorithm runs on.239 /// \param digraph The digraph the algorithm runs on. 250 240 /// \param length The length (cost) values of the arcs. 251 Suurballe( const Digraph &graph,252 const LengthMap &length ) :253 _graph(graph), _length(length), _flow(0), _local_flow(false),254 _potential(0), _local_potential(false), _pred(graph)255 {256 LEMON_ASSERT(std::numeric_limits<Length>::is_integer,257 "The length type of Suurballe must be integer");258 }241 /// \param s The source node. 242 /// \param t The target node. 243 Suurballe( const Digraph &digraph, 244 const LengthMap &length, 245 Node s, Node t ) : 246 _graph(digraph), _length(length), _flow(0), _local_flow(false), 247 _potential(0), _local_potential(false), _source(s), _target(t), 248 _pred(digraph) {} 259 249 260 250 /// Destructor. … … 268 258 /// 269 259 /// This function sets the flow map. 270 /// If it is not used before calling \ref run() or \ref init(), 271 /// an instance will be allocated automatically. The destructor 272 /// deallocates this automatically allocated map, of course. 273 /// 274 /// The found flow contains only 0 and 1 values, since it is the 275 /// union of the found arc-disjoint paths. 260 /// 261 /// The found flow contains only 0 and 1 values. It is the union of 262 /// the found arc-disjoint paths. 276 263 /// 277 264 /// \return <tt>(*this)</tt> … … 288 275 /// 289 276 /// This function sets the potential map. 290 /// If it is not used before calling \ref run() or \ref init(), 291 /// an instance will be allocated automatically. The destructor 292 /// deallocates this automatically allocated map, of course. 293 /// 294 /// The node potentials provide the dual solution of the underlying 295 /// \ref min_cost_flow "minimum cost flow problem". 277 /// 278 /// The potentials provide the dual solution of the underlying 279 /// minimum cost flow problem. 296 280 /// 297 281 /// \return <tt>(*this)</tt> … … 318 302 /// This function runs the algorithm. 319 303 /// 320 /// \param s The source node.321 /// \param t The target node.322 304 /// \param k The number of paths to be found. 323 305 /// … … 326 308 /// arc-disjoint paths found. 327 309 /// 328 /// \note Apart from the return value, <tt>s.run( s, t, k)</tt> is329 /// just ashortcut of the following code.310 /// \note Apart from the return value, <tt>s.run(k)</tt> is just a 311 /// shortcut of the following code. 330 312 /// \code 331 /// s.init( s);332 /// s.findFlow( t,k);313 /// s.init(); 314 /// s.findFlow(k); 333 315 /// s.findPaths(); 334 316 /// \endcode 335 int run( const Node& s, const Node& t,int k = 2) {336 init( s);337 findFlow( t,k);317 int run(int k = 2) { 318 init(); 319 findFlow(k); 338 320 findPaths(); 339 321 return _path_num; … … 343 325 /// 344 326 /// This function initializes the algorithm. 345 /// 346 /// \param s The source node. 347 void init(const Node& s) { 348 _source = s; 349 327 void init() { 350 328 // Initialize maps 351 329 if (!_flow) { … … 359 337 for (ArcIt e(_graph); e != INVALID; ++e) (*_flow)[e] = 0; 360 338 for (NodeIt n(_graph); n != INVALID; ++n) (*_potential)[n] = 0; 361 } 362 363 /// \brief Execute the algorithm to find an optimal flow. 339 340 _dijkstra = new ResidualDijkstra( _graph, *_flow, _length, 341 *_potential, _pred, 342 _source, _target ); 343 } 344 345 /// \brief Execute the successive shortest path algorithm to find 346 /// an optimal flow. 364 347 /// 365 348 /// This function executes the successive shortest path algorithm to 366 /// find a minimum cost flow, which is the union of \c k (or less)349 /// find a minimum cost flow, which is the union of \c k or less 367 350 /// arc-disjoint paths. 368 351 /// 369 /// \param t The target node.370 /// \param k The number of paths to be found.371 ///372 352 /// \return \c k if there are at least \c k arc-disjoint paths from 373 /// the source node to the given node \c t in the digraph.374 /// Otherwise it returns the number ofarc-disjoint paths found.353 /// \c s to \c t in the digraph. Otherwise it returns the number of 354 /// arc-disjoint paths found. 375 355 /// 376 356 /// \pre \ref init() must be called before using this function. 377 int findFlow(const Node& t, int k = 2) { 378 _target = t; 379 _dijkstra = 380 new ResidualDijkstra( _graph, *_flow, _length, *_potential, _pred, 381 _source, _target ); 382 357 int findFlow(int k = 2) { 383 358 // Find shortest paths 384 359 _path_num = 0; … … 406 381 /// \brief Compute the paths from the flow. 407 382 /// 408 /// This function computes the paths from the found minimum cost flow, 409 /// which is the union of some arc-disjoint paths. 383 /// This function computes the paths from the flow. 410 384 /// 411 385 /// \pre \ref init() and \ref findFlow() must be called before using 412 386 /// this function. 413 387 void findPaths() { 388 // Create the residual flow map (the union of the paths not found 389 // so far) 414 390 FlowMap res_flow(_graph); 415 391 for(ArcIt a(_graph); a != INVALID; ++a) res_flow[a] = (*_flow)[a]; … … 438 414 /// @{ 439 415 440 /// \brief Return the total length of the found paths. 441 /// 442 /// This function returns the total length of the found paths, i.e. 443 /// the total cost of the found flow. 444 /// The complexity of the function is O(e). 416 /// \brief Return a const reference to the arc map storing the 417 /// found flow. 418 /// 419 /// This function returns a const reference to the arc map storing 420 /// the flow that is the union of the found arc-disjoint paths. 421 /// 422 /// \pre \ref run() or \ref findFlow() must be called before using 423 /// this function. 424 const FlowMap& flowMap() const { 425 return *_flow; 426 } 427 428 /// \brief Return a const reference to the node map storing the 429 /// found potentials (the dual solution). 430 /// 431 /// This function returns a const reference to the node map storing 432 /// the found potentials that provide the dual solution of the 433 /// underlying minimum cost flow problem. 434 /// 435 /// \pre \ref run() or \ref findFlow() must be called before using 436 /// this function. 437 const PotentialMap& potentialMap() const { 438 return *_potential; 439 } 440 441 /// \brief Return the flow on the given arc. 442 /// 443 /// This function returns the flow on the given arc. 444 /// It is \c 1 if the arc is involved in one of the found paths, 445 /// otherwise it is \c 0. 446 /// 447 /// \pre \ref run() or \ref findFlow() must be called before using 448 /// this function. 449 int flow(const Arc& arc) const { 450 return (*_flow)[arc]; 451 } 452 453 /// \brief Return the potential of the given node. 454 /// 455 /// This function returns the potential of the given node. 456 /// 457 /// \pre \ref run() or \ref findFlow() must be called before using 458 /// this function. 459 Length potential(const Node& node) const { 460 return (*_potential)[node]; 461 } 462 463 /// \brief Return the total length (cost) of the found paths (flow). 464 /// 465 /// This function returns the total length (cost) of the found paths 466 /// (flow). The complexity of the function is O(e). 445 467 /// 446 468 /// \pre \ref run() or \ref findFlow() must be called before using … … 453 475 } 454 476 455 /// \brief Return the flow value on the given arc.456 ///457 /// This function returns the flow value on the given arc.458 /// It is \c 1 if the arc is involved in one of the found arc-disjoint459 /// paths, otherwise it is \c 0.460 ///461 /// \pre \ref run() or \ref findFlow() must be called before using462 /// this function.463 int flow(const Arc& arc) const {464 return (*_flow)[arc];465 }466 467 /// \brief Return a const reference to an arc map storing the468 /// found flow.469 ///470 /// This function returns a const reference to an arc map storing471 /// the flow that is the union of the found arc-disjoint paths.472 ///473 /// \pre \ref run() or \ref findFlow() must be called before using474 /// this function.475 const FlowMap& flowMap() const {476 return *_flow;477 }478 479 /// \brief Return the potential of the given node.480 ///481 /// This function returns the potential of the given node.482 /// The node potentials provide the dual solution of the483 /// underlying \ref min_cost_flow "minimum cost flow problem".484 ///485 /// \pre \ref run() or \ref findFlow() must be called before using486 /// this function.487 Length potential(const Node& node) const {488 return (*_potential)[node];489 }490 491 /// \brief Return a const reference to a node map storing the492 /// found potentials (the dual solution).493 ///494 /// This function returns a const reference to a node map storing495 /// the found potentials that provide the dual solution of the496 /// underlying \ref min_cost_flow "minimum cost flow problem".497 ///498 /// \pre \ref run() or \ref findFlow() must be called before using499 /// this function.500 const PotentialMap& potentialMap() const {501 return *_potential;502 }503 504 477 /// \brief Return the number of the found paths. 505 478 /// … … 516 489 /// This function returns a const reference to the specified path. 517 490 /// 518 /// \param i The function returns the <tt>i</tt>-th path.491 /// \param i The function returns the \c i-th path. 519 492 /// \c i must be between \c 0 and <tt>%pathNum()-1</tt>. 520 493 /// -
test/min_cost_flow_test.cc
r615 r609 234 234 typedef int Flow; 235 235 typedef int Cost; 236 typedef concepts::Digraph GR; 236 // TODO: This typedef should be enabled if the standard maps are 237 // reference maps in the graph concepts (See #190). 238 /**/ 239 //typedef concepts::Digraph GR; 240 typedef ListDigraph GR; 241 /**/ 237 242 checkConcept< McfClassConcept<GR, Flow, Cost>, 238 243 NetworkSimplex<GR, Flow, Cost> >(); -
test/suurballe_test.cc
r623 r440 23 23 #include <lemon/path.h> 24 24 #include <lemon/suurballe.h> 25 #include <lemon/concepts/digraph.h>26 25 27 26 #include "test_tools.h" … … 31 30 char test_lgf[] = 32 31 "@nodes\n" 33 "label \n"34 "1 \n"35 "2 \n"36 "3 \n"37 "4 \n"38 "5 \n"39 "6 \n"40 "7 \n"41 "8 \n"42 "9 \n"43 "10 \n"44 "11 \n"45 "12 \n"32 "label supply1 supply2 supply3\n" 33 "1 0 20 27\n" 34 "2 0 -4 0\n" 35 "3 0 0 0\n" 36 "4 0 0 0\n" 37 "5 0 9 0\n" 38 "6 0 -6 0\n" 39 "7 0 0 0\n" 40 "8 0 0 0\n" 41 "9 0 3 0\n" 42 "10 0 -2 0\n" 43 "11 0 0 0\n" 44 "12 0 -20 -27\n" 46 45 "@arcs\n" 47 " length\n"48 " 1 2 70 \n"49 " 1 3 150 \n"50 " 1 4 80 \n"51 " 2 8 80 \n"52 " 3 5 140 \n"53 " 4 6 60 \n"54 " 4 7 80 \n"55 " 4 8 110 \n"56 " 5 7 60 \n"57 " 5 11 120 \n"58 " 6 3 0 \n"59 " 6 9 140 \n"60 " 6 10 90 \n"61 " 7 1 30 \n"62 " 8 12 60 \n"63 " 9 12 50 \n"64 "10 12 70 \n"65 "10 2 100 \n"66 "10 7 60 \n"67 "11 10 20 \n"68 "12 11 30 \n"46 " cost capacity lower1 lower2\n" 47 " 1 2 70 11 0 8\n" 48 " 1 3 150 3 0 1\n" 49 " 1 4 80 15 0 2\n" 50 " 2 8 80 12 0 0\n" 51 " 3 5 140 5 0 3\n" 52 " 4 6 60 10 0 1\n" 53 " 4 7 80 2 0 0\n" 54 " 4 8 110 3 0 0\n" 55 " 5 7 60 14 0 0\n" 56 " 5 11 120 12 0 0\n" 57 " 6 3 0 3 0 0\n" 58 " 6 9 140 4 0 0\n" 59 " 6 10 90 8 0 0\n" 60 " 7 1 30 5 0 0\n" 61 " 8 12 60 16 0 4\n" 62 " 9 12 50 6 0 0\n" 63 "10 12 70 13 0 5\n" 64 "10 2 100 7 0 0\n" 65 "10 7 60 10 0 0\n" 66 "11 10 20 14 0 6\n" 67 "12 11 30 10 0 0\n" 69 68 "@attributes\n" 70 69 "source 1\n" 71 70 "target 12\n" 72 71 "@end\n"; 73 74 // Check the interface of Suurballe75 void checkSuurballeCompile()76 {77 typedef int VType;78 typedef concepts::Digraph Digraph;79 80 typedef Digraph::Node Node;81 typedef Digraph::Arc Arc;82 typedef concepts::ReadMap<Arc, VType> LengthMap;83 84 typedef Suurballe<Digraph, LengthMap> SuurballeType;85 86 Digraph g;87 Node n;88 Arc e;89 LengthMap len;90 SuurballeType::FlowMap flow(g);91 SuurballeType::PotentialMap pi(g);92 93 SuurballeType suurb_test(g, len);94 const SuurballeType& const_suurb_test = suurb_test;95 96 suurb_test97 .flowMap(flow)98 .potentialMap(pi);99 100 int k;101 k = suurb_test.run(n, n);102 k = suurb_test.run(n, n, k);103 suurb_test.init(n);104 k = suurb_test.findFlow(n);105 k = suurb_test.findFlow(n, k);106 suurb_test.findPaths();107 108 int f;109 VType c;110 c = const_suurb_test.totalLength();111 f = const_suurb_test.flow(e);112 const SuurballeType::FlowMap& fm =113 const_suurb_test.flowMap();114 c = const_suurb_test.potential(n);115 const SuurballeType::PotentialMap& pm =116 const_suurb_test.potentialMap();117 k = const_suurb_test.pathNum();118 Path<Digraph> p = const_suurb_test.path(k);119 120 ignore_unused_variable_warning(fm);121 ignore_unused_variable_warning(pm);122 }123 72 124 73 // Check the feasibility of the flow … … 170 119 typename Digraph::Node s, typename Digraph::Node t) 171 120 { 121 // Check the "Complementary Slackness" optimality condition 172 122 TEMPLATE_DIGRAPH_TYPEDEFS(Digraph); 173 123 Node n = s; … … 187 137 ListDigraph digraph; 188 138 ListDigraph::ArcMap<int> length(digraph); 189 Node s ,t;139 Node source, target; 190 140 191 141 std::istringstream input(test_lgf); 192 142 DigraphReader<ListDigraph>(digraph, input). 193 arcMap(" length", length).194 node("source", s ).195 node("target", t ).143 arcMap("cost", length). 144 node("source", source). 145 node("target", target). 196 146 run(); 197 147 198 148 // Find 2 paths 199 149 { 200 Suurballe<ListDigraph> suurballe(digraph, length );201 check(suurballe.run( s, t) == 2, "Wrong number of paths");202 check(checkFlow(digraph, suurballe.flowMap(), s ,t, 2),150 Suurballe<ListDigraph> suurballe(digraph, length, source, target); 151 check(suurballe.run(2) == 2, "Wrong number of paths"); 152 check(checkFlow(digraph, suurballe.flowMap(), source, target, 2), 203 153 "The flow is not feasible"); 204 154 check(suurballe.totalLength() == 510, "The flow is not optimal"); … … 207 157 "Wrong potentials"); 208 158 for (int i = 0; i < suurballe.pathNum(); ++i) 209 check(checkPath(digraph, suurballe.path(i), s, t), "Wrong path"); 159 check(checkPath(digraph, suurballe.path(i), source, target), 160 "Wrong path"); 210 161 } 211 162 212 163 // Find 3 paths 213 164 { 214 Suurballe<ListDigraph> suurballe(digraph, length );215 check(suurballe.run( s, t,3) == 3, "Wrong number of paths");216 check(checkFlow(digraph, suurballe.flowMap(), s ,t, 3),165 Suurballe<ListDigraph> suurballe(digraph, length, source, target); 166 check(suurballe.run(3) == 3, "Wrong number of paths"); 167 check(checkFlow(digraph, suurballe.flowMap(), source, target, 3), 217 168 "The flow is not feasible"); 218 169 check(suurballe.totalLength() == 1040, "The flow is not optimal"); … … 221 172 "Wrong potentials"); 222 173 for (int i = 0; i < suurballe.pathNum(); ++i) 223 check(checkPath(digraph, suurballe.path(i), s, t), "Wrong path"); 174 check(checkPath(digraph, suurballe.path(i), source, target), 175 "Wrong path"); 224 176 } 225 177 226 178 // Find 5 paths (only 3 can be found) 227 179 { 228 Suurballe<ListDigraph> suurballe(digraph, length );229 check(suurballe.run( s, t,5) == 3, "Wrong number of paths");230 check(checkFlow(digraph, suurballe.flowMap(), s ,t, 3),180 Suurballe<ListDigraph> suurballe(digraph, length, source, target); 181 check(suurballe.run(5) == 3, "Wrong number of paths"); 182 check(checkFlow(digraph, suurballe.flowMap(), source, target, 3), 231 183 "The flow is not feasible"); 232 184 check(suurballe.totalLength() == 1040, "The flow is not optimal"); … … 235 187 "Wrong potentials"); 236 188 for (int i = 0; i < suurballe.pathNum(); ++i) 237 check(checkPath(digraph, suurballe.path(i), s, t), "Wrong path"); 189 check(checkPath(digraph, suurballe.path(i), source, target), 190 "Wrong path"); 238 191 } 239 192 -
tools/dimacs-solver.cc
r614 r611 94 94 template<class Value> 95 95 void solve_min(ArgParser &ap, std::istream &is, std::ostream &, 96 Value infty,DimacsDescriptor &desc)96 DimacsDescriptor &desc) 97 97 { 98 98 bool report = !ap.given("q"); … … 101 101 Digraph::NodeMap<Value> sup(g); 102 102 Timer ti; 103 104 ti.restart(); 105 readDimacsMin(is, g, lower, cap, cost, sup, infty, desc); 106 ti.stop(); 107 Value sum_sup = 0; 108 for (Digraph::NodeIt n(g); n != INVALID; ++n) { 109 sum_sup += sup[n]; 110 } 111 if (report) { 112 std::cerr << "Sum of supply values: " << sum_sup << "\n"; 113 if (sum_sup <= 0) 114 std::cerr << "GEQ supply contraints are used for NetworkSimplex\n\n"; 115 else 116 std::cerr << "LEQ supply contraints are used for NetworkSimplex\n\n"; 117 } 103 ti.restart(); 104 readDimacsMin(is, g, lower, cap, cost, sup, 0, desc); 118 105 if (report) std::cerr << "Read the file: " << ti << '\n'; 119 120 106 ti.restart(); 121 107 NetworkSimplex<Digraph, Value> ns(g); 122 108 ns.lowerMap(lower).capacityMap(cap).costMap(cost).supplyMap(sup); 123 if (sum_sup > 0) ns.problemType(ns.LEQ);124 109 if (report) std::cerr << "Setup NetworkSimplex class: " << ti << '\n'; 125 110 ti.restart(); 126 bool res = ns.run(); 127 if (report) { 128 std::cerr << "Run NetworkSimplex: " << ti << "\n\n"; 129 std::cerr << "Feasible flow: " << (res ? "found" : "not found") << '\n'; 130 if (res) std::cerr << "Min flow cost: " << ns.totalCost() << '\n'; 131 } 111 ns.run(); 112 if (report) std::cerr << "Run NetworkSimplex: " << ti << '\n'; 113 if (report) std::cerr << "\nMin flow cost: " << ns.totalCost() << '\n'; 132 114 } 133 115 … … 170 152 { 171 153 case DimacsDescriptor::MIN: 172 solve_min<Value>(ap,is,os, infty,desc);154 solve_min<Value>(ap,is,os,desc); 173 155 break; 174 156 case DimacsDescriptor::MAX: -
tools/lgf-gen.cc
r623 r584 66 66 double tlen=0; 67 67 for(EdgeIt e(g);e!=INVALID;++e) 68 tlen+=s td::sqrt((coords[g.v(e)]-coords[g.u(e)]).normSquare());68 tlen+=sqrt((coords[g.v(e)]-coords[g.u(e)]).normSquare()); 69 69 return tlen; 70 70 } … … 189 189 (r.x * r.x + r.y * r.y) * (p.x * q.y - q.x * p.y); 190 190 191 return d / (2 * a) + s td::sqrt((d * d + e * e) / (4 * a * a) + f / a);191 return d / (2 * a) + sqrt((d * d + e * e) / (4 * a * a) + f / a); 192 192 } 193 193 … … 207 207 double b = (q.x - sx) * p.y - (p.x - sx) * q.y; 208 208 double d = (q.x - sx) * (p.x - sx) * (p - q).normSquare(); 209 return (b - s td::sqrt(d)) / a;209 return (b - sqrt(d)) / a; 210 210 } 211 211 … … 481 481 g.erase(*ei); 482 482 ConstMap<Arc,int> cegy(1); 483 Suurballe<ListGraph,ConstMap<Arc,int> > sur(g,cegy );484 int k=sur.run( a,b,2);483 Suurballe<ListGraph,ConstMap<Arc,int> > sur(g,cegy,a,b); 484 int k=sur.run(2); 485 485 if(k<2 || sur.totalLength()>d) 486 486 g.addEdge(a,b); … … 512 512 if(e==INVALID) { 513 513 ConstMap<Arc,int> cegy(1); 514 Suurballe<ListGraph,ConstMap<Arc,int> > sur(g,cegy); 515 int k=sur.run(pi->a,pi->b,2); 514 Suurballe<ListGraph,ConstMap<Arc,int> > 515 sur(g,cegy,pi->a,pi->b); 516 int k=sur.run(2); 516 517 if(k<2 || sur.totalLength()>d) 517 518 { … … 720 721 721 722 if (ap["rand"]) { 722 int seed = int(time(0));723 int seed = time(0); 723 724 std::cout << "Random number seed: " << seed << std::endl; 724 725 rnd = Random(seed); … … 813 814 double tlen=0; 814 815 for(EdgeIt e(g);e!=INVALID;++e) 815 tlen+=s td::sqrt((coords[g.v(e)]-coords[g.u(e)]).normSquare());816 tlen+=sqrt((coords[g.v(e)]-coords[g.u(e)]).normSquare()); 816 817 std::cout << "Total arc length : " << tlen << std::endl; 817 818
Note: See TracChangeset
for help on using the changeset viewer.