Changes in / [413:d8b87e9b90c3:412:7030149efed2] in lemon-1.2
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/groups.dox
r406 r388 17 17 */ 18 18 19 namespace lemon {20 21 19 /** 22 20 @defgroup datas Data Structures … … 91 89 92 90 This group describes maps that are specifically designed to assign 93 values to the nodes and arcs/edges of graphs. 94 95 If you are looking for the standard graph maps (\c NodeMap, \c ArcMap, 96 \c EdgeMap), see the \ref graph_concepts "Graph Structure Concepts". 91 values to the nodes and arcs of graphs. 97 92 */ 98 93 … … 105 100 maps from other maps. 106 101 107 Most of them are \ref concepts::ReadMap "read-only maps".102 Most of them are \ref lemon::concepts::ReadMap "read-only maps". 108 103 They can make arithmetic and logical operations between one or two maps 109 104 (negation, shifting, addition, multiplication, logical 'and', 'or', … … 207 202 \brief Common graph search algorithms. 208 203 209 This group describes the common graph search algorithms , namely210 \e breadth-first \e search (BFS) and \e depth-first \e search (DFS).204 This group describes the common graph search algorithms like 205 Breadth-First Search (BFS) and Depth-First Search (DFS). 211 206 */ 212 207 … … 216 211 \brief Algorithms for finding shortest paths. 217 212 218 This group describes the algorithms for finding shortest paths in digraphs. 219 220 - \ref Dijkstra algorithm for finding shortest paths from a source node 221 when all arc lengths are non-negative. 222 - \ref BellmanFord "Bellman-Ford" algorithm for finding shortest paths 223 from a source node when arc lenghts can be either positive or negative, 224 but the digraph should not contain directed cycles with negative total 225 length. 226 - \ref FloydWarshall "Floyd-Warshall" and \ref Johnson "Johnson" algorithms 227 for solving the \e all-pairs \e shortest \e paths \e problem when arc 228 lenghts can be either positive or negative, but the digraph should 229 not contain directed cycles with negative total length. 230 - \ref Suurballe A successive shortest path algorithm for finding 231 arc-disjoint paths between two nodes having minimum total length. 213 This group describes the algorithms for finding shortest paths in graphs. 232 214 */ 233 215 … … 240 222 feasible circulations. 241 223 242 The \e maximum \e flow \e problem is to find a flow of maximum value between 243 a single source and a single target. Formally, there is a \f$G=(V,A)\f$ 244 digraph, a \f$cap:A\rightarrow\mathbf{R}^+_0\f$ capacity function and 245 \f$s, t \in V\f$ source and target nodes. 246 A maximum flow is an \f$f:A\rightarrow\mathbf{R}^+_0\f$ solution of the 247 following optimization problem. 248 249 \f[ \max\sum_{a\in\delta_{out}(s)}f(a) - \sum_{a\in\delta_{in}(s)}f(a) \f] 250 \f[ \sum_{a\in\delta_{out}(v)} f(a) = \sum_{a\in\delta_{in}(v)} f(a) 251 \qquad \forall v\in V\setminus\{s,t\} \f] 252 \f[ 0 \leq f(a) \leq cap(a) \qquad \forall a\in A \f] 224 The maximum flow problem is to find a flow between a single source and 225 a single target that is maximum. Formally, there is a \f$G=(V,A)\f$ 226 directed graph, an \f$c_a:A\rightarrow\mathbf{R}^+_0\f$ capacity 227 function and given \f$s, t \in V\f$ source and target node. The 228 maximum flow is the \f$f_a\f$ solution of the next optimization problem: 229 230 \f[ 0 \le f_a \le c_a \f] 231 \f[ \sum_{v\in\delta^{-}(u)}f_{vu}=\sum_{v\in\delta^{+}(u)}f_{uv} 232 \qquad \forall u \in V \setminus \{s,t\}\f] 233 \f[ \max \sum_{v\in\delta^{+}(s)}f_{uv} - \sum_{v\in\delta^{-}(s)}f_{vu}\f] 253 234 254 235 LEMON contains several algorithms for solving maximum flow problems: 255 - \ref EdmondsKarp Edmonds-Karp algorithm.256 - \ref Preflow Goldberg-Tarjan's preflow push-relabel algorithm.257 - \ref DinitzSleatorTarjan Dinitz's blocking flow algorithm with dynamic trees.258 - \ref GoldbergTarjan Preflow push-relabel algorithm with dynamic trees.259 260 In most cases the \ref Preflow "Preflow" algorithm provides the261 fastest method for computing a maximum flow. All implementations262 provides functions to also query the minimum cut, which is the dual263 pro blem of the maximum flow.236 - \ref lemon::EdmondsKarp "Edmonds-Karp" 237 - \ref lemon::Preflow "Goldberg's Preflow algorithm" 238 - \ref lemon::DinitzSleatorTarjan "Dinitz's blocking flow algorithm with dynamic trees" 239 - \ref lemon::GoldbergTarjan "Preflow algorithm with dynamic trees" 240 241 In most cases the \ref lemon::Preflow "Preflow" algorithm provides the 242 fastest method to compute the maximum flow. All impelementations 243 provides functions to query the minimum cut, which is the dual linear 244 programming problem of the maximum flow. 264 245 */ 265 246 … … 272 253 This group describes the algorithms for finding minimum cost flows and 273 254 circulations. 274 275 The \e minimum \e cost \e flow \e problem is to find a feasible flow of276 minimum total cost from a set of supply nodes to a set of demand nodes277 in a network with capacity constraints and arc costs.278 Formally, let \f$G=(V,A)\f$ be a digraph,279 \f$lower, upper: A\rightarrow\mathbf{Z}^+_0\f$ denote the lower and280 upper bounds for the flow values on the arcs,281 \f$cost: A\rightarrow\mathbf{Z}^+_0\f$ denotes the cost per unit flow282 on the arcs, and283 \f$supply: V\rightarrow\mathbf{Z}\f$ denotes the supply/demand values284 of the nodes.285 A minimum cost flow is an \f$f:A\rightarrow\mathbf{R}^+_0\f$ solution of286 the following optimization problem.287 288 \f[ \min\sum_{a\in A} f(a) cost(a) \f]289 \f[ \sum_{a\in\delta_{out}(v)} f(a) - \sum_{a\in\delta_{in}(v)} f(a) =290 supply(v) \qquad \forall v\in V \f]291 \f[ lower(a) \leq f(a) \leq upper(a) \qquad \forall a\in A \f]292 293 LEMON contains several algorithms for solving minimum cost flow problems:294 - \ref CycleCanceling Cycle-canceling algorithms.295 - \ref CapacityScaling Successive shortest path algorithm with optional296 capacity scaling.297 - \ref CostScaling Push-relabel and augment-relabel algorithms based on298 cost scaling.299 - \ref NetworkSimplex Primal network simplex algorithm with various300 pivot strategies.301 255 */ 302 256 … … 309 263 This group describes the algorithms for finding minimum cut in graphs. 310 264 311 The \e minimum \e cut \eproblem is to find a non-empty and non-complete312 \f$X\f$ subset of the nodes with minimum overall capacity on313 outgoing arcs. Formally, there is a \f$G=(V,A)\f$ digraph, a314 \f$c ap:A\rightarrow\mathbf{R}^+_0\f$ capacity function. The minimum265 The minimum cut problem is to find a non-empty and non-complete 266 \f$X\f$ subset of the vertices with minimum overall capacity on 267 outgoing arcs. Formally, there is \f$G=(V,A)\f$ directed graph, an 268 \f$c_a:A\rightarrow\mathbf{R}^+_0\f$ capacity function. The minimum 315 269 cut is the \f$X\f$ solution of the next optimization problem: 316 270 317 271 \f[ \min_{X \subset V, X\not\in \{\emptyset, V\}} 318 \sum_{uv\in A, u\in X, v\not\in X}cap(uv)\f]272 \sum_{uv\in A, u\in X, v\not\in X}c_{uv}\f] 319 273 320 274 LEMON contains several algorithms related to minimum cut problems: 321 275 322 - \ref HaoOrlin "Hao-Orlin algorithm" for calculatingminimum cut323 in directed graphs .324 - \ref NagamochiIbaraki "Nagamochi-Ibaraki algorithm" for325 calculat ing minimum cut in undirected graphs.326 - \ref GomoryHuTree "Gomory-Hu tree computation" for calculating327 all-pairs minimum cut in undirected graphs.276 - \ref lemon::HaoOrlin "Hao-Orlin algorithm" to calculate minimum cut 277 in directed graphs 278 - \ref lemon::NagamochiIbaraki "Nagamochi-Ibaraki algorithm" to 279 calculate minimum cut in undirected graphs 280 - \ref lemon::GomoryHuTree "Gomory-Hu tree computation" to calculate all 281 pairs minimum cut in undirected graphs 328 282 329 283 If you want to find minimum cut just between two distinict nodes, 330 see the \ref max_flow "maximum flow problem".284 please see the \ref max_flow "Maximum Flow page". 331 285 */ 332 286 … … 367 321 graphs. The matching problems in bipartite graphs are generally 368 322 easier than in general graphs. The goal of the matching optimization 369 can be finding maximum cardinality, maximum weight or minimum cost323 can be the finding maximum cardinality, maximum weight or minimum cost 370 324 matching. The search can be constrained to find perfect or 371 325 maximum cardinality matching. 372 326 373 The matching algorithms implemented in LEMON: 374 - \ref MaxBipartiteMatching Hopcroft-Karp augmenting path algorithm 375 for calculating maximum cardinality matching in bipartite graphs. 376 - \ref PrBipartiteMatching Push-relabel algorithm 377 for calculating maximum cardinality matching in bipartite graphs. 378 - \ref MaxWeightedBipartiteMatching 379 Successive shortest path algorithm for calculating maximum weighted 380 matching and maximum weighted bipartite matching in bipartite graphs. 381 - \ref MinCostMaxBipartiteMatching 382 Successive shortest path algorithm for calculating minimum cost maximum 383 matching in bipartite graphs. 384 - \ref MaxMatching Edmond's blossom shrinking algorithm for calculating 385 maximum cardinality matching in general graphs. 386 - \ref MaxWeightedMatching Edmond's blossom shrinking algorithm for calculating 387 maximum weighted matching in general graphs. 388 - \ref MaxWeightedPerfectMatching 389 Edmond's blossom shrinking algorithm for calculating maximum weighted 390 perfect matching in general graphs. 327 LEMON contains the next algorithms: 328 - \ref lemon::MaxBipartiteMatching "MaxBipartiteMatching" Hopcroft-Karp 329 augmenting path algorithm for calculate maximum cardinality matching in 330 bipartite graphs 331 - \ref lemon::PrBipartiteMatching "PrBipartiteMatching" Push-Relabel 332 algorithm for calculate maximum cardinality matching in bipartite graphs 333 - \ref lemon::MaxWeightedBipartiteMatching "MaxWeightedBipartiteMatching" 334 Successive shortest path algorithm for calculate maximum weighted matching 335 and maximum weighted bipartite matching in bipartite graph 336 - \ref lemon::MinCostMaxBipartiteMatching "MinCostMaxBipartiteMatching" 337 Successive shortest path algorithm for calculate minimum cost maximum 338 matching in bipartite graph 339 - \ref lemon::MaxMatching "MaxMatching" Edmond's blossom shrinking algorithm 340 for calculate maximum cardinality matching in general graph 341 - \ref lemon::MaxWeightedMatching "MaxWeightedMatching" Edmond's blossom 342 shrinking algorithm for calculate maximum weighted matching in general 343 graph 344 - \ref lemon::MaxWeightedPerfectMatching "MaxWeightedPerfectMatching" 345 Edmond's blossom shrinking algorithm for calculate maximum weighted 346 perfect matching in general graph 391 347 392 348 \image html bipartite_matching.png … … 400 356 401 357 This group describes the algorithms for finding a minimum cost spanning 402 tree in a graph .358 tree in a graph 403 359 */ 404 360 … … 591 547 \anchor demoprograms 592 548 593 @defgroup demos Demo Programs549 @defgroup demos Demo programs 594 550 595 551 Some demo programs are listed here. Their full source codes can be found in … … 601 557 602 558 /** 603 @defgroup tools Standalone Utility Applications559 @defgroup tools Standalone utility applications 604 560 605 561 Some utility applications are listed here. … … 609 565 */ 610 566 611 } -
lemon/bfs.h
r405 r329 52 52 ///Instantiates a PredMap. 53 53 54 ///This function instantiates a PredMap. 54 ///This function instantiates a PredMap. 55 55 ///\param g is the digraph, to which we would like to define the 56 56 ///PredMap. … … 81 81 ///The type of the map that indicates which nodes are reached. 82 82 83 ///The type of the map that indicates which nodes are reached. 84 ///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept. 83 ///The type of the map that indicates which nodes are reached.///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept. 85 84 typedef typename Digraph::template NodeMap<bool> ReachedMap; 86 85 ///Instantiates a ReachedMap. … … 120 119 /// 121 120 ///\tparam GR The type of the digraph the algorithm runs on. 122 ///The default type is \ref ListDigraph. 121 ///The default value is \ref ListDigraph. The value of GR is not used 122 ///directly by \ref Bfs, it is only passed to \ref BfsDefaultTraits. 123 ///\tparam TR Traits class to set various data types used by the algorithm. 124 ///The default traits class is 125 ///\ref BfsDefaultTraits "BfsDefaultTraits<GR>". 126 ///See \ref BfsDefaultTraits for the documentation of 127 ///a Bfs traits class. 123 128 #ifdef DOXYGEN 124 129 template <typename GR, … … 146 151 typedef PredMapPath<Digraph, PredMap> Path; 147 152 148 ///The \ref BfsDefaultTraits "traits class" of the algorithm.153 ///The traits class. 149 154 typedef TR Traits; 150 155 … … 208 213 typedef Bfs Create; 209 214 210 ///\name Named Template Parameters215 ///\name Named template parameters 211 216 212 217 ///@{ … … 226 231 ///\ref named-templ-param "Named parameter" for setting 227 232 ///PredMap type. 228 ///It must meet the \ref concepts::WriteMap "WriteMap" concept.229 233 template <class T> 230 234 struct SetPredMap : public Bfs< Digraph, SetPredMapTraits<T> > { … … 246 250 ///\ref named-templ-param "Named parameter" for setting 247 251 ///DistMap type. 248 ///It must meet the \ref concepts::WriteMap "WriteMap" concept.249 252 template <class T> 250 253 struct SetDistMap : public Bfs< Digraph, SetDistMapTraits<T> > { … … 266 269 ///\ref named-templ-param "Named parameter" for setting 267 270 ///ReachedMap type. 268 ///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept.269 271 template <class T> 270 272 struct SetReachedMap : public Bfs< Digraph, SetReachedMapTraits<T> > { … … 286 288 ///\ref named-templ-param "Named parameter" for setting 287 289 ///ProcessedMap type. 288 ///It must meet the \ref concepts::WriteMap "WriteMap" concept.289 290 template <class T> 290 291 struct SetProcessedMap : public Bfs< Digraph, SetProcessedMapTraits<T> > { … … 339 340 340 341 ///Sets the map that stores the predecessor arcs. 341 ///If you don't use this function before calling \ref run(Node) "run()" 342 ///or \ref init(), an instance will be allocated automatically. 343 ///The destructor deallocates this automatically allocated map, 344 ///of course. 342 ///If you don't use this function before calling \ref run(), 343 ///it will allocate one. The destructor deallocates this 344 ///automatically allocated map, of course. 345 345 ///\return <tt> (*this) </tt> 346 346 Bfs &predMap(PredMap &m) … … 357 357 358 358 ///Sets the map that indicates which nodes are reached. 359 ///If you don't use this function before calling \ref run(Node) "run()" 360 ///or \ref init(), an instance will be allocated automatically. 361 ///The destructor deallocates this automatically allocated map, 362 ///of course. 359 ///If you don't use this function before calling \ref run(), 360 ///it will allocate one. The destructor deallocates this 361 ///automatically allocated map, of course. 363 362 ///\return <tt> (*this) </tt> 364 363 Bfs &reachedMap(ReachedMap &m) … … 375 374 376 375 ///Sets the map that indicates which nodes are processed. 377 ///If you don't use this function before calling \ref run(Node) "run()" 378 ///or \ref init(), an instance will be allocated automatically. 379 ///The destructor deallocates this automatically allocated map, 380 ///of course. 376 ///If you don't use this function before calling \ref run(), 377 ///it will allocate one. The destructor deallocates this 378 ///automatically allocated map, of course. 381 379 ///\return <tt> (*this) </tt> 382 380 Bfs &processedMap(ProcessedMap &m) … … 394 392 ///Sets the map that stores the distances of the nodes calculated by 395 393 ///the algorithm. 396 ///If you don't use this function before calling \ref run(Node) "run()" 397 ///or \ref init(), an instance will be allocated automatically. 398 ///The destructor deallocates this automatically allocated map, 399 ///of course. 394 ///If you don't use this function before calling \ref run(), 395 ///it will allocate one. The destructor deallocates this 396 ///automatically allocated map, of course. 400 397 ///\return <tt> (*this) </tt> 401 398 Bfs &distMap(DistMap &m) … … 411 408 public: 412 409 413 ///\name Execution Control 414 ///The simplest way to execute the BFS algorithm is to use one of the 415 ///member functions called \ref run(Node) "run()".\n 416 ///If you need more control on the execution, first you have to call 417 ///\ref init(), then you can add several source nodes with 418 ///\ref addSource(). Finally the actual path computation can be 419 ///performed with one of the \ref start() functions. 410 ///\name Execution control 411 ///The simplest way to execute the algorithm is to use 412 ///one of the member functions called \ref lemon::Bfs::run() "run()". 413 ///\n 414 ///If you need more control on the execution, first you must call 415 ///\ref lemon::Bfs::init() "init()", then you can add several source 416 ///nodes with \ref lemon::Bfs::addSource() "addSource()". 417 ///Finally \ref lemon::Bfs::start() "start()" will perform the 418 ///actual path computation. 420 419 421 420 ///@{ 422 421 423 ///\brief Initializes the internal data structures.424 ///425 422 ///Initializes the internal data structures. 423 424 ///Initializes the internal data structures. 425 /// 426 426 void init() 427 427 { … … 557 557 } 558 558 559 ///Returns \c false if there are nodes to be processed. 560 561 ///Returns \c false if there are nodes to be processed 562 ///in the queue. 559 ///\brief Returns \c false if there are nodes 560 ///to be processed. 561 /// 562 ///Returns \c false if there are nodes 563 ///to be processed in the queue. 563 564 bool emptyQueue() const { return _queue_tail==_queue_head; } 564 565 565 566 ///Returns the number of the nodes to be processed. 566 567 567 ///Returns the number of the nodes to be processed 568 ///in the queue. 568 ///Returns the number of the nodes to be processed in the queue. 569 569 int queueSize() const { return _queue_head-_queue_tail; } 570 570 … … 731 731 732 732 ///\name Query Functions 733 ///The result s of theBFS algorithm can be obtained using these733 ///The result of the %BFS algorithm can be obtained using these 734 734 ///functions.\n 735 ///Either \ref run(Node) "run()" or \ref start() should be called736 /// before using them.735 ///Either \ref lemon::Bfs::run() "run()" or \ref lemon::Bfs::start() 736 ///"start()" must be called before using them. 737 737 738 738 ///@{ … … 742 742 ///Returns the shortest path to a node. 743 743 /// 744 ///\warning \c t should be reach edfrom the root(s).745 /// 746 ///\pre Either \ref run( Node) "run()" or \ref init()747 /// must be called beforeusing this function.744 ///\warning \c t should be reachable from the root(s). 745 /// 746 ///\pre Either \ref run() or \ref start() must be called before 747 ///using this function. 748 748 Path path(Node t) const { return Path(*G, *_pred, t); } 749 749 … … 752 752 ///Returns the distance of a node from the root(s). 753 753 /// 754 ///\warning If node \c v is not reach edfrom the root(s), then754 ///\warning If node \c v is not reachable from the root(s), then 755 755 ///the return value of this function is undefined. 756 756 /// 757 ///\pre Either \ref run( Node) "run()" or \ref init()758 /// must be called beforeusing this function.757 ///\pre Either \ref run() or \ref start() must be called before 758 ///using this function. 759 759 int dist(Node v) const { return (*_dist)[v]; } 760 760 … … 763 763 ///This function returns the 'previous arc' of the shortest path 764 764 ///tree for the node \c v, i.e. it returns the last arc of a 765 ///shortest path from a rootto \c v. It is \c INVALID if \c v766 ///is not reach edfrom the root(s) or if \c v is a root.765 ///shortest path from the root(s) to \c v. It is \c INVALID if \c v 766 ///is not reachable from the root(s) or if \c v is a root. 767 767 /// 768 768 ///The shortest path tree used here is equal to the shortest path 769 769 ///tree used in \ref predNode(). 770 770 /// 771 ///\pre Either \ref run( Node) "run()" or \ref init()772 /// must be called beforeusing this function.771 ///\pre Either \ref run() or \ref start() must be called before 772 ///using this function. 773 773 Arc predArc(Node v) const { return (*_pred)[v];} 774 774 … … 777 777 ///This function returns the 'previous node' of the shortest path 778 778 ///tree for the node \c v, i.e. it returns the last but one node 779 ///from a shortest path from a rootto \c v. It is \c INVALID780 ///if \c v is not reach edfrom the root(s) or if \c v is a root.779 ///from a shortest path from the root(s) to \c v. It is \c INVALID 780 ///if \c v is not reachable from the root(s) or if \c v is a root. 781 781 /// 782 782 ///The shortest path tree used here is equal to the shortest path 783 783 ///tree used in \ref predArc(). 784 784 /// 785 ///\pre Either \ref run( Node) "run()" or \ref init()786 /// must be called beforeusing this function.785 ///\pre Either \ref run() or \ref start() must be called before 786 ///using this function. 787 787 Node predNode(Node v) const { return (*_pred)[v]==INVALID ? INVALID: 788 788 G->source((*_pred)[v]); } … … 794 794 ///of the nodes calculated by the algorithm. 795 795 /// 796 ///\pre Either \ref run( Node) "run()"or \ref init()796 ///\pre Either \ref run() or \ref init() 797 797 ///must be called before using this function. 798 798 const DistMap &distMap() const { return *_dist;} … … 804 804 ///arcs, which form the shortest path tree. 805 805 /// 806 ///\pre Either \ref run( Node) "run()"or \ref init()806 ///\pre Either \ref run() or \ref init() 807 807 ///must be called before using this function. 808 808 const PredMap &predMap() const { return *_pred;} 809 809 810 ///Checks if a node is reached from the root(s). 811 812 ///Returns \c true if \c v is reached from the root(s). 813 /// 814 ///\pre Either \ref run(Node) "run()" or \ref init() 810 ///Checks if a node is reachable from the root(s). 811 812 ///Returns \c true if \c v is reachable from the root(s). 813 ///\pre Either \ref run() or \ref start() 815 814 ///must be called before using this function. 816 815 bool reached(Node v) const { return (*_reached)[v]; } … … 958 957 /// This auxiliary class is created to implement the 959 958 /// \ref bfs() "function-type interface" of \ref Bfs algorithm. 960 /// It does not have own \ref run( Node) "run()" method, it uses the961 /// functionsand features of the plain \ref Bfs.959 /// It does not have own \ref run() method, it uses the functions 960 /// and features of the plain \ref Bfs. 962 961 /// 963 962 /// This class should only be used through the \ref bfs() function, … … 1179 1178 /// bool reached = bfs(g).path(p).dist(d).run(s,t); 1180 1179 ///\endcode 1181 ///\warning Don't forget to put the \ref BfsWizard::run( Node) "run()"1180 ///\warning Don't forget to put the \ref BfsWizard::run() "run()" 1182 1181 ///to the end of the parameter list. 1183 1182 ///\sa BfsWizard … … 1365 1364 typedef BfsVisit Create; 1366 1365 1367 /// \name Named Template Parameters1366 /// \name Named template parameters 1368 1367 1369 1368 ///@{ … … 1407 1406 /// 1408 1407 /// Sets the map that indicates which nodes are reached. 1409 /// If you don't use this function before calling \ref run(Node) "run()" 1410 /// or \ref init(), an instance will be allocated automatically. 1411 /// The destructor deallocates this automatically allocated map, 1412 /// of course. 1408 /// If you don't use this function before calling \ref run(), 1409 /// it will allocate one. The destructor deallocates this 1410 /// automatically allocated map, of course. 1413 1411 /// \return <tt> (*this) </tt> 1414 1412 BfsVisit &reachedMap(ReachedMap &m) { … … 1423 1421 public: 1424 1422 1425 /// \name Execution Control 1426 /// The simplest way to execute the BFS algorithm is to use one of the 1427 /// member functions called \ref run(Node) "run()".\n 1428 /// If you need more control on the execution, first you have to call 1429 /// \ref init(), then you can add several source nodes with 1430 /// \ref addSource(). Finally the actual path computation can be 1431 /// performed with one of the \ref start() functions. 1423 /// \name Execution control 1424 /// The simplest way to execute the algorithm is to use 1425 /// one of the member functions called \ref lemon::BfsVisit::run() 1426 /// "run()". 1427 /// \n 1428 /// If you need more control on the execution, first you must call 1429 /// \ref lemon::BfsVisit::init() "init()", then you can add several 1430 /// source nodes with \ref lemon::BfsVisit::addSource() "addSource()". 1431 /// Finally \ref lemon::BfsVisit::start() "start()" will perform the 1432 /// actual path computation. 1432 1433 1433 1434 /// @{ … … 1729 1730 1730 1731 /// \name Query Functions 1731 /// The result s of theBFS algorithm can be obtained using these1732 /// The result of the %BFS algorithm can be obtained using these 1732 1733 /// functions.\n 1733 /// Either \ref run(Node) "run()" or \ref start() should be called1734 /// before using them.1735 1734 /// Either \ref lemon::BfsVisit::run() "run()" or 1735 /// \ref lemon::BfsVisit::start() "start()" must be called before 1736 /// using them. 1736 1737 ///@{ 1737 1738 1738 /// \brief Checks if a node is reached from the root(s). 1739 /// 1740 /// Returns \c true if \c v is reached from the root(s). 1741 /// 1742 /// \pre Either \ref run(Node) "run()" or \ref init() 1739 /// \brief Checks if a node is reachable from the root(s). 1740 /// 1741 /// Returns \c true if \c v is reachable from the root(s). 1742 /// \pre Either \ref run() or \ref start() 1743 1743 /// must be called before using this function. 1744 1744 bool reached(Node v) { return (*_reached)[v]; } -
lemon/dfs.h
r405 r319 120 120 /// 121 121 ///\tparam GR The type of the digraph the algorithm runs on. 122 ///The default type is \ref ListDigraph. 122 ///The default value is \ref ListDigraph. The value of GR is not used 123 ///directly by \ref Dfs, it is only passed to \ref DfsDefaultTraits. 124 ///\tparam TR Traits class to set various data types used by the algorithm. 125 ///The default traits class is 126 ///\ref DfsDefaultTraits "DfsDefaultTraits<GR>". 127 ///See \ref DfsDefaultTraits for the documentation of 128 ///a Dfs traits class. 123 129 #ifdef DOXYGEN 124 130 template <typename GR, … … 146 152 typedef PredMapPath<Digraph, PredMap> Path; 147 153 148 ///The \ref DfsDefaultTraits "traits class" of the algorithm.154 ///The traits class. 149 155 typedef TR Traits; 150 156 … … 225 231 ///\ref named-templ-param "Named parameter" for setting 226 232 ///PredMap type. 227 ///It must meet the \ref concepts::WriteMap "WriteMap" concept.228 233 template <class T> 229 234 struct SetPredMap : public Dfs<Digraph, SetPredMapTraits<T> > { … … 245 250 ///\ref named-templ-param "Named parameter" for setting 246 251 ///DistMap type. 247 ///It must meet the \ref concepts::WriteMap "WriteMap" concept.248 252 template <class T> 249 253 struct SetDistMap : public Dfs< Digraph, SetDistMapTraits<T> > { … … 265 269 ///\ref named-templ-param "Named parameter" for setting 266 270 ///ReachedMap type. 267 ///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept.268 271 template <class T> 269 272 struct SetReachedMap : public Dfs< Digraph, SetReachedMapTraits<T> > { … … 285 288 ///\ref named-templ-param "Named parameter" for setting 286 289 ///ProcessedMap type. 287 ///It must meet the \ref concepts::WriteMap "WriteMap" concept.288 290 template <class T> 289 291 struct SetProcessedMap : public Dfs< Digraph, SetProcessedMapTraits<T> > { … … 337 339 338 340 ///Sets the map that stores the predecessor arcs. 339 ///If you don't use this function before calling \ref run(Node) "run()" 340 ///or \ref init(), an instance will be allocated automatically. 341 ///The destructor deallocates this automatically allocated map, 342 ///of course. 341 ///If you don't use this function before calling \ref run(), 342 ///it will allocate one. The destructor deallocates this 343 ///automatically allocated map, of course. 343 344 ///\return <tt> (*this) </tt> 344 345 Dfs &predMap(PredMap &m) … … 355 356 356 357 ///Sets the map that indicates which nodes are reached. 357 ///If you don't use this function before calling \ref run(Node) "run()" 358 ///or \ref init(), an instance will be allocated automatically. 359 ///The destructor deallocates this automatically allocated map, 360 ///of course. 358 ///If you don't use this function before calling \ref run(), 359 ///it will allocate one. The destructor deallocates this 360 ///automatically allocated map, of course. 361 361 ///\return <tt> (*this) </tt> 362 362 Dfs &reachedMap(ReachedMap &m) … … 373 373 374 374 ///Sets the map that indicates which nodes are processed. 375 ///If you don't use this function before calling \ref run(Node) "run()" 376 ///or \ref init(), an instance will be allocated automatically. 377 ///The destructor deallocates this automatically allocated map, 378 ///of course. 375 ///If you don't use this function before calling \ref run(), 376 ///it will allocate one. The destructor deallocates this 377 ///automatically allocated map, of course. 379 378 ///\return <tt> (*this) </tt> 380 379 Dfs &processedMap(ProcessedMap &m) … … 392 391 ///Sets the map that stores the distances of the nodes calculated by 393 392 ///the algorithm. 394 ///If you don't use this function before calling \ref run(Node) "run()" 395 ///or \ref init(), an instance will be allocated automatically. 396 ///The destructor deallocates this automatically allocated map, 397 ///of course. 393 ///If you don't use this function before calling \ref run(), 394 ///it will allocate one. The destructor deallocates this 395 ///automatically allocated map, of course. 398 396 ///\return <tt> (*this) </tt> 399 397 Dfs &distMap(DistMap &m) … … 409 407 public: 410 408 411 ///\name Execution Control 412 ///The simplest way to execute the DFS algorithm is to use one of the 413 ///member functions called \ref run(Node) "run()".\n 414 ///If you need more control on the execution, first you have to call 415 ///\ref init(), then you can add a source node with \ref addSource() 416 ///and perform the actual computation with \ref start(). 417 ///This procedure can be repeated if there are nodes that have not 418 ///been reached. 409 ///\name Execution control 410 ///The simplest way to execute the algorithm is to use 411 ///one of the member functions called \ref lemon::Dfs::run() "run()". 412 ///\n 413 ///If you need more control on the execution, first you must call 414 ///\ref lemon::Dfs::init() "init()", then you can add a source node 415 ///with \ref lemon::Dfs::addSource() "addSource()". 416 ///Finally \ref lemon::Dfs::start() "start()" will perform the 417 ///actual path computation. 419 418 420 419 ///@{ 421 420 422 ///\brief Initializes the internal data structures.423 ///424 421 ///Initializes the internal data structures. 422 423 ///Initializes the internal data structures. 424 /// 425 425 void init() 426 426 { … … 439 439 ///Adds a new source node to the set of nodes to be processed. 440 440 /// 441 ///\pre The stack must be empty. Otherwise the algorithm gives 442 ///wrong results. (One of the outgoing arcs of all the source nodes 443 ///except for the last one will not be visited and distances will 444 ///also be wrong.) 441 ///\pre The stack must be empty. (Otherwise the algorithm gives 442 ///false results.) 443 /// 444 ///\warning Distances will be wrong (or at least strange) in case of 445 ///multiple sources. 445 446 void addSource(Node s) 446 447 { … … 506 507 } 507 508 508 ///Returns \c false if there are nodes to be processed. 509 510 ///Returns \c false if there are nodes to be processed 511 ///in the queue (stack). 509 ///\brief Returns \c false if there are nodes 510 ///to be processed. 511 /// 512 ///Returns \c false if there are nodes 513 ///to be processed in the queue (stack). 512 514 bool emptyQueue() const { return _stack_head<0; } 513 515 514 516 ///Returns the number of the nodes to be processed. 515 517 516 ///Returns the number of the nodes to be processed 517 ///in the queue (stack). 518 ///Returns the number of the nodes to be processed in the queue (stack). 518 519 int queueSize() const { return _stack_head+1; } 519 520 … … 637 638 /// 638 639 ///The algorithm computes 639 ///- the %DFS tree (forest),640 ///- the distance of each node from the root (s)in the %DFS tree.640 ///- the %DFS tree, 641 ///- the distance of each node from the root in the %DFS tree. 641 642 /// 642 643 ///\note <tt>d.run()</tt> is just a shortcut of the following code. … … 663 664 664 665 ///\name Query Functions 665 ///The result s of theDFS algorithm can be obtained using these666 ///The result of the %DFS algorithm can be obtained using these 666 667 ///functions.\n 667 ///Either \ref run(Node) "run()" or \ref start() should be called668 /// before using them.668 ///Either \ref lemon::Dfs::run() "run()" or \ref lemon::Dfs::start() 669 ///"start()" must be called before using them. 669 670 670 671 ///@{ … … 674 675 ///Returns the DFS path to a node. 675 676 /// 676 ///\warning \c t should be reach ed from the root(s).677 /// 678 ///\pre Either \ref run( Node) "run()" or \ref init()679 /// must be called beforeusing this function.677 ///\warning \c t should be reachable from the root. 678 /// 679 ///\pre Either \ref run() or \ref start() must be called before 680 ///using this function. 680 681 Path path(Node t) const { return Path(*G, *_pred, t); } 681 682 682 ///The distance of a node from the root (s).683 684 ///Returns the distance of a node from the root (s).685 /// 686 ///\warning If node \c v is not reach ed from the root(s), then683 ///The distance of a node from the root. 684 685 ///Returns the distance of a node from the root. 686 /// 687 ///\warning If node \c v is not reachable from the root, then 687 688 ///the return value of this function is undefined. 688 689 /// 689 ///\pre Either \ref run( Node) "run()" or \ref init()690 /// must be called beforeusing this function.690 ///\pre Either \ref run() or \ref start() must be called before 691 ///using this function. 691 692 int dist(Node v) const { return (*_dist)[v]; } 692 693 … … 694 695 695 696 ///This function returns the 'previous arc' of the %DFS tree for the 696 ///node \c v, i.e. it returns the last arc of a %DFS path from a697 ///root to \c v. It is \c INVALID if \c v is not reached from the698 /// root(s) or if \c v is a root.697 ///node \c v, i.e. it returns the last arc of a %DFS path from the 698 ///root to \c v. It is \c INVALID 699 ///if \c v is not reachable from the root(s) or if \c v is a root. 699 700 /// 700 701 ///The %DFS tree used here is equal to the %DFS tree used in 701 702 ///\ref predNode(). 702 703 /// 703 ///\pre Either \ref run( Node) "run()" or \ref init()704 /// must be called before usingthis function.704 ///\pre Either \ref run() or \ref start() must be called before using 705 ///this function. 705 706 Arc predArc(Node v) const { return (*_pred)[v];} 706 707 … … 709 710 ///This function returns the 'previous node' of the %DFS 710 711 ///tree for the node \c v, i.e. it returns the last but one node 711 ///from a %DFS path from aroot to \c v. It is \c INVALID712 ///if \c v is not reach edfrom the root(s) or if \c v is a root.712 ///from a %DFS path from the root to \c v. It is \c INVALID 713 ///if \c v is not reachable from the root(s) or if \c v is a root. 713 714 /// 714 715 ///The %DFS tree used here is equal to the %DFS tree used in 715 716 ///\ref predArc(). 716 717 /// 717 ///\pre Either \ref run( Node) "run()" or \ref init()718 /// must be called beforeusing this function.718 ///\pre Either \ref run() or \ref start() must be called before 719 ///using this function. 719 720 Node predNode(Node v) const { return (*_pred)[v]==INVALID ? INVALID: 720 721 G->source((*_pred)[v]); } … … 726 727 ///distances of the nodes calculated by the algorithm. 727 728 /// 728 ///\pre Either \ref run( Node) "run()"or \ref init()729 ///\pre Either \ref run() or \ref init() 729 730 ///must be called before using this function. 730 731 const DistMap &distMap() const { return *_dist;} … … 736 737 ///arcs, which form the DFS tree. 737 738 /// 738 ///\pre Either \ref run( Node) "run()"or \ref init()739 ///\pre Either \ref run() or \ref init() 739 740 ///must be called before using this function. 740 741 const PredMap &predMap() const { return *_pred;} 741 742 742 ///Checks if a node is reached from the root(s). 743 744 ///Returns \c true if \c v is reached from the root(s). 745 /// 746 ///\pre Either \ref run(Node) "run()" or \ref init() 743 ///Checks if a node is reachable from the root(s). 744 745 ///Returns \c true if \c v is reachable from the root(s). 746 ///\pre Either \ref run() or \ref start() 747 747 ///must be called before using this function. 748 748 bool reached(Node v) const { return (*_reached)[v]; } … … 890 890 /// This auxiliary class is created to implement the 891 891 /// \ref dfs() "function-type interface" of \ref Dfs algorithm. 892 /// It does not have own \ref run( Node) "run()" method, it uses the893 /// functionsand features of the plain \ref Dfs.892 /// It does not have own \ref run() method, it uses the functions 893 /// and features of the plain \ref Dfs. 894 894 /// 895 895 /// This class should only be used through the \ref dfs() function, … … 1111 1111 /// bool reached = dfs(g).path(p).dist(d).run(s,t); 1112 1112 ///\endcode 1113 ///\warning Don't forget to put the \ref DfsWizard::run(Node) "run()" 1113 1114 ///\warning Don't forget to put the \ref DfsWizard::run() "run()" 1114 1115 ///to the end of the parameter list. 1115 1116 ///\sa DfsWizard … … 1309 1310 typedef DfsVisit Create; 1310 1311 1311 /// \name Named Template Parameters1312 /// \name Named template parameters 1312 1313 1313 1314 ///@{ … … 1351 1352 /// 1352 1353 /// Sets the map that indicates which nodes are reached. 1353 /// If you don't use this function before calling \ref run(Node) "run()" 1354 /// or \ref init(), an instance will be allocated automatically. 1355 /// The destructor deallocates this automatically allocated map, 1356 /// of course. 1354 /// If you don't use this function before calling \ref run(), 1355 /// it will allocate one. The destructor deallocates this 1356 /// automatically allocated map, of course. 1357 1357 /// \return <tt> (*this) </tt> 1358 1358 DfsVisit &reachedMap(ReachedMap &m) { … … 1367 1367 public: 1368 1368 1369 /// \name Execution Control 1370 /// The simplest way to execute the DFS algorithm is to use one of the 1371 /// member functions called \ref run(Node) "run()".\n 1372 /// If you need more control on the execution, first you have to call 1373 /// \ref init(), then you can add a source node with \ref addSource() 1374 /// and perform the actual computation with \ref start(). 1375 /// This procedure can be repeated if there are nodes that have not 1376 /// been reached. 1369 /// \name Execution control 1370 /// The simplest way to execute the algorithm is to use 1371 /// one of the member functions called \ref lemon::DfsVisit::run() 1372 /// "run()". 1373 /// \n 1374 /// If you need more control on the execution, first you must call 1375 /// \ref lemon::DfsVisit::init() "init()", then you can add several 1376 /// source nodes with \ref lemon::DfsVisit::addSource() "addSource()". 1377 /// Finally \ref lemon::DfsVisit::start() "start()" will perform the 1378 /// actual path computation. 1377 1379 1378 1380 /// @{ … … 1390 1392 } 1391 1393 1392 /// \brief Adds a new source node. 1393 /// 1394 /// Adds a new source node to the set of nodes to be processed. 1395 /// 1396 /// \pre The stack must be empty. Otherwise the algorithm gives 1397 /// wrong results. (One of the outgoing arcs of all the source nodes 1398 /// except for the last one will not be visited and distances will 1399 /// also be wrong.) 1394 ///Adds a new source node. 1395 1396 ///Adds a new source node to the set of nodes to be processed. 1397 /// 1398 ///\pre The stack must be empty. (Otherwise the algorithm gives 1399 ///false results.) 1400 /// 1401 ///\warning Distances will be wrong (or at least strange) in case of 1402 ///multiple sources. 1400 1403 void addSource(Node s) 1401 1404 { … … 1587 1590 /// 1588 1591 /// The algorithm computes 1589 /// - the %DFS tree (forest),1590 /// - the distance of each node from the root (s)in the %DFS tree.1592 /// - the %DFS tree, 1593 /// - the distance of each node from the root in the %DFS tree. 1591 1594 /// 1592 1595 /// \note <tt>d.run()</tt> is just a shortcut of the following code. … … 1613 1616 1614 1617 /// \name Query Functions 1615 /// The result s of theDFS algorithm can be obtained using these1618 /// The result of the %DFS algorithm can be obtained using these 1616 1619 /// functions.\n 1617 /// Either \ref run(Node) "run()" or \ref start() should be called1618 /// before using them.1619 1620 /// Either \ref lemon::DfsVisit::run() "run()" or 1621 /// \ref lemon::DfsVisit::start() "start()" must be called before 1622 /// using them. 1620 1623 ///@{ 1621 1624 1622 /// \brief Checks if a node is reached from the root(s). 1623 /// 1624 /// Returns \c true if \c v is reached from the root(s). 1625 /// 1626 /// \pre Either \ref run(Node) "run()" or \ref init() 1625 /// \brief Checks if a node is reachable from the root(s). 1626 /// 1627 /// Returns \c true if \c v is reachable from the root(s). 1628 /// \pre Either \ref run() or \ref start() 1627 1629 /// must be called before using this function. 1628 1630 bool reached(Node v) { return (*_reached)[v]; } -
lemon/dijkstra.h
r408 r397 180 180 /// 181 181 ///\tparam GR The type of the digraph the algorithm runs on. 182 ///The default type is \ref ListDigraph. 183 ///\tparam LM A \ref concepts::ReadMap "readable" arc map that specifies 184 ///the lengths of the arcs. 185 ///It is read once for each arc, so the map may involve in 182 ///The default value is \ref ListDigraph. 183 ///The value of GR is not used directly by \ref Dijkstra, it is only 184 ///passed to \ref DijkstraDefaultTraits. 185 ///\tparam LM A readable arc map that determines the lengths of the 186 ///arcs. It is read once for each arc, so the map may involve in 186 187 ///relatively time consuming process to compute the arc lengths if 187 188 ///it is necessary. The default map type is \ref 188 ///concepts::Digraph::ArcMap "GR::ArcMap<int>". 189 ///concepts::Digraph::ArcMap "Digraph::ArcMap<int>". 190 ///The value of LM is not used directly by \ref Dijkstra, it is only 191 ///passed to \ref DijkstraDefaultTraits. 192 ///\tparam TR Traits class to set various data types used by the algorithm. 193 ///The default traits class is \ref DijkstraDefaultTraits 194 ///"DijkstraDefaultTraits<GR,LM>". See \ref DijkstraDefaultTraits 195 ///for the documentation of a Dijkstra traits class. 189 196 #ifdef DOXYGEN 190 197 template <typename GR, typename LM, typename TR> … … 220 227 typedef typename TR::OperationTraits OperationTraits; 221 228 222 ///The \ref DijkstraDefaultTraits "traits class" of the algorithm.229 ///The traits class. 223 230 typedef TR Traits; 224 231 … … 302 309 ///\ref named-templ-param "Named parameter" for setting 303 310 ///PredMap type. 304 ///It must meet the \ref concepts::WriteMap "WriteMap" concept.305 311 template <class T> 306 312 struct SetPredMap … … 323 329 ///\ref named-templ-param "Named parameter" for setting 324 330 ///DistMap type. 325 ///It must meet the \ref concepts::WriteMap "WriteMap" concept.326 331 template <class T> 327 332 struct SetDistMap … … 344 349 ///\ref named-templ-param "Named parameter" for setting 345 350 ///ProcessedMap type. 346 ///It must meet the \ref concepts::WriteMap "WriteMap" concept.347 351 template <class T> 348 352 struct SetProcessedMap … … 385 389 }; 386 390 ///\brief \ref named-templ-param "Named parameter" for setting 387 ///heap and cross reference type s391 ///heap and cross reference type 388 392 /// 389 393 ///\ref named-templ-param "Named parameter" for setting heap and cross 390 ///reference types. If this named parameter is used, then external 391 ///heap and cross reference objects must be passed to the algorithm 392 ///using the \ref heap() function before calling \ref run(Node) "run()" 393 ///or \ref init(). 394 ///\sa SetStandardHeap 394 ///reference type. 395 395 template <class H, class CR = typename Digraph::template NodeMap<int> > 396 396 struct SetHeap … … 412 412 }; 413 413 ///\brief \ref named-templ-param "Named parameter" for setting 414 ///heap and cross reference type swith automatic allocation414 ///heap and cross reference type with automatic allocation 415 415 /// 416 416 ///\ref named-templ-param "Named parameter" for setting heap and cross 417 ///reference types with automatic allocation. 418 ///They should have standard constructor interfaces to be able to 419 ///automatically created by the algorithm (i.e. the digraph should be 420 ///passed to the constructor of the cross reference and the cross 421 ///reference should be passed to the constructor of the heap). 422 ///However external heap and cross reference objects could also be 423 ///passed to the algorithm using the \ref heap() function before 424 ///calling \ref run(Node) "run()" or \ref init(). 425 ///\sa SetHeap 417 ///reference type. It can allocate the heap and the cross reference 418 ///object if the cross reference's constructor waits for the digraph as 419 ///parameter and the heap's constructor waits for the cross reference. 426 420 template <class H, class CR = typename Digraph::template NodeMap<int> > 427 421 struct SetStandardHeap … … 493 487 494 488 ///Sets the map that stores the predecessor arcs. 495 ///If you don't use this function before calling \ref run(Node) "run()" 496 ///or \ref init(), an instance will be allocated automatically. 497 ///The destructor deallocates this automatically allocated map, 498 ///of course. 489 ///If you don't use this function before calling \ref run(), 490 ///it will allocate one. The destructor deallocates this 491 ///automatically allocated map, of course. 499 492 ///\return <tt> (*this) </tt> 500 493 Dijkstra &predMap(PredMap &m) … … 511 504 512 505 ///Sets the map that indicates which nodes are processed. 513 ///If you don't use this function before calling \ref run(Node) "run()" 514 ///or \ref init(), an instance will be allocated automatically. 515 ///The destructor deallocates this automatically allocated map, 516 ///of course. 506 ///If you don't use this function before calling \ref run(), 507 ///it will allocate one. The destructor deallocates this 508 ///automatically allocated map, of course. 517 509 ///\return <tt> (*this) </tt> 518 510 Dijkstra &processedMap(ProcessedMap &m) … … 530 522 ///Sets the map that stores the distances of the nodes calculated by the 531 523 ///algorithm. 532 ///If you don't use this function before calling \ref run(Node) "run()" 533 ///or \ref init(), an instance will be allocated automatically. 534 ///The destructor deallocates this automatically allocated map, 535 ///of course. 524 ///If you don't use this function before calling \ref run(), 525 ///it will allocate one. The destructor deallocates this 526 ///automatically allocated map, of course. 536 527 ///\return <tt> (*this) </tt> 537 528 Dijkstra &distMap(DistMap &m) … … 548 539 549 540 ///Sets the heap and the cross reference used by algorithm. 550 ///If you don't use this function before calling \ref run(Node) "run()" 551 ///or \ref init(), heap and cross reference instances will be 552 ///allocated automatically. 553 ///The destructor deallocates these automatically allocated objects, 554 ///of course. 541 ///If you don't use this function before calling \ref run(), 542 ///it will allocate one. The destructor deallocates this 543 ///automatically allocated heap and cross reference, of course. 555 544 ///\return <tt> (*this) </tt> 556 545 Dijkstra &heap(Heap& hp, HeapCrossRef &cr) … … 579 568 public: 580 569 581 ///\name Execution Control 582 ///The simplest way to execute the %Dijkstra algorithm is to use 583 ///one of the member functions called \ref run(Node) "run()".\n 584 ///If you need more control on the execution, first you have to call 585 ///\ref init(), then you can add several source nodes with 586 ///\ref addSource(). Finally the actual path computation can be 587 ///performed with one of the \ref start() functions. 570 ///\name Execution control 571 ///The simplest way to execute the algorithm is to use one of the 572 ///member functions called \ref lemon::Dijkstra::run() "run()". 573 ///\n 574 ///If you need more control on the execution, first you must call 575 ///\ref lemon::Dijkstra::init() "init()", then you can add several 576 ///source nodes with \ref lemon::Dijkstra::addSource() "addSource()". 577 ///Finally \ref lemon::Dijkstra::start() "start()" will perform the 578 ///actual path computation. 588 579 589 580 ///@{ 590 581 591 ///\brief Initializes the internal data structures.592 ///593 582 ///Initializes the internal data structures. 583 584 ///Initializes the internal data structures. 585 /// 594 586 void init() 595 587 { … … 667 659 } 668 660 669 ///Returns \c false if there are nodes to be processed. 670 671 ///Returns \c false if there are nodes to be processed 672 ///in the priority heap. 661 ///\brief Returns \c false if there are nodes 662 ///to be processed. 663 /// 664 ///Returns \c false if there are nodes 665 ///to be processed in the priority heap. 673 666 bool emptyQueue() const { return _heap->empty(); } 674 667 675 ///Returns the number of the nodes to be processed .676 677 ///Returns the number of the nodes to be processed 678 /// in the priority heap.668 ///Returns the number of the nodes to be processed in the priority heap 669 670 ///Returns the number of the nodes to be processed in the priority heap. 671 /// 679 672 int queueSize() const { return _heap->size(); } 680 673 … … 797 790 798 791 ///\name Query Functions 799 ///The result sof the %Dijkstra algorithm can be obtained using these792 ///The result of the %Dijkstra algorithm can be obtained using these 800 793 ///functions.\n 801 ///Either \ref run(Node) "run()" or \ref start() should be called 802 ///before using them. 794 ///Either \ref lemon::Dijkstra::run() "run()" or 795 ///\ref lemon::Dijkstra::start() "start()" must be called before 796 ///using them. 803 797 804 798 ///@{ … … 808 802 ///Returns the shortest path to a node. 809 803 /// 810 ///\warning \c t should be reach edfrom the root(s).811 /// 812 ///\pre Either \ref run( Node) "run()" or \ref init()813 /// must be called beforeusing this function.804 ///\warning \c t should be reachable from the root(s). 805 /// 806 ///\pre Either \ref run() or \ref start() must be called before 807 ///using this function. 814 808 Path path(Node t) const { return Path(*G, *_pred, t); } 815 809 … … 818 812 ///Returns the distance of a node from the root(s). 819 813 /// 820 ///\warning If node \c v is not reach edfrom the root(s), then814 ///\warning If node \c v is not reachable from the root(s), then 821 815 ///the return value of this function is undefined. 822 816 /// 823 ///\pre Either \ref run( Node) "run()" or \ref init()824 /// must be called beforeusing this function.817 ///\pre Either \ref run() or \ref start() must be called before 818 ///using this function. 825 819 Value dist(Node v) const { return (*_dist)[v]; } 826 820 … … 829 823 ///This function returns the 'previous arc' of the shortest path 830 824 ///tree for the node \c v, i.e. it returns the last arc of a 831 ///shortest path from a rootto \c v. It is \c INVALID if \c v832 ///is not reach edfrom the root(s) or if \c v is a root.825 ///shortest path from the root(s) to \c v. It is \c INVALID if \c v 826 ///is not reachable from the root(s) or if \c v is a root. 833 827 /// 834 828 ///The shortest path tree used here is equal to the shortest path 835 829 ///tree used in \ref predNode(). 836 830 /// 837 ///\pre Either \ref run( Node) "run()" or \ref init()838 /// must be called beforeusing this function.831 ///\pre Either \ref run() or \ref start() must be called before 832 ///using this function. 839 833 Arc predArc(Node v) const { return (*_pred)[v]; } 840 834 … … 843 837 ///This function returns the 'previous node' of the shortest path 844 838 ///tree for the node \c v, i.e. it returns the last but one node 845 ///from a shortest path from a rootto \c v. It is \c INVALID846 ///if \c v is not reach edfrom the root(s) or if \c v is a root.839 ///from a shortest path from the root(s) to \c v. It is \c INVALID 840 ///if \c v is not reachable from the root(s) or if \c v is a root. 847 841 /// 848 842 ///The shortest path tree used here is equal to the shortest path 849 843 ///tree used in \ref predArc(). 850 844 /// 851 ///\pre Either \ref run( Node) "run()" or \ref init()852 /// must be called beforeusing this function.845 ///\pre Either \ref run() or \ref start() must be called before 846 ///using this function. 853 847 Node predNode(Node v) const { return (*_pred)[v]==INVALID ? INVALID: 854 848 G->source((*_pred)[v]); } … … 860 854 ///of the nodes calculated by the algorithm. 861 855 /// 862 ///\pre Either \ref run( Node) "run()"or \ref init()856 ///\pre Either \ref run() or \ref init() 863 857 ///must be called before using this function. 864 858 const DistMap &distMap() const { return *_dist;} … … 870 864 ///arcs, which form the shortest path tree. 871 865 /// 872 ///\pre Either \ref run( Node) "run()"or \ref init()866 ///\pre Either \ref run() or \ref init() 873 867 ///must be called before using this function. 874 868 const PredMap &predMap() const { return *_pred;} 875 869 876 ///Checks if a node is reached from the root(s). 877 878 ///Returns \c true if \c v is reached from the root(s). 879 /// 880 ///\pre Either \ref run(Node) "run()" or \ref init() 870 ///Checks if a node is reachable from the root(s). 871 872 ///Returns \c true if \c v is reachable from the root(s). 873 ///\pre Either \ref run() or \ref start() 881 874 ///must be called before using this function. 882 875 bool reached(Node v) const { return (*_heap_cross_ref)[v] != … … 887 880 ///Returns \c true if \c v is processed, i.e. the shortest 888 881 ///path to \c v has already found. 889 /// 890 ///\pre Either \ref run(Node) "run()" or \ref init() 882 ///\pre Either \ref run() or \ref init() 891 883 ///must be called before using this function. 892 884 bool processed(Node v) const { return (*_heap_cross_ref)[v] == … … 897 889 ///Returns the current distance of a node from the root(s). 898 890 ///It may be decreased in the following processes. 899 /// 900 ///\pre Either \ref run(Node) "run()" or \ref init() 891 ///\pre Either \ref run() or \ref init() 901 892 ///must be called before using this function and 902 893 ///node \c v must be reached but not necessarily processed. … … 1081 1072 /// This auxiliary class is created to implement the 1082 1073 /// \ref dijkstra() "function-type interface" of \ref Dijkstra algorithm. 1083 /// It does not have own \ref run( Node) "run()" method, it uses the1084 /// functionsand features of the plain \ref Dijkstra.1074 /// It does not have own \ref run() method, it uses the functions 1075 /// and features of the plain \ref Dijkstra. 1085 1076 /// 1086 1077 /// This class should only be used through the \ref dijkstra() function, … … 1277 1268 /// bool reached = dijkstra(g,length).path(p).dist(d).run(s,t); 1278 1269 ///\endcode 1279 ///\warning Don't forget to put the \ref DijkstraWizard::run( Node) "run()"1270 ///\warning Don't forget to put the \ref DijkstraWizard::run() "run()" 1280 1271 ///to the end of the parameter list. 1281 1272 ///\sa DijkstraWizard
Note: See TracChangeset
for help on using the changeset viewer.