Changeset 421:6b9057cdcd8b in lemon for lemon/dijkstra.h
- Timestamp:
- 11/30/08 19:17:51 (16 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/dijkstra.h
r313 r421 203 203 /// 204 204 ///\tparam GR The type of the digraph the algorithm runs on. 205 ///The default value is \ref ListDigraph. 206 ///The value of GR is not used directly by \ref Dijkstra, it is only 207 ///passed to \ref DijkstraDefaultTraits. 208 ///\tparam LM A readable arc map that determines the lengths of the 209 ///arcs. It is read once for each arc, so the map may involve in 205 ///The default type is \ref ListDigraph. 206 ///\tparam LM A \ref concepts::ReadMap "readable" arc map that specifies 207 ///the lengths of the arcs. 208 ///It is read once for each arc, so the map may involve in 210 209 ///relatively time consuming process to compute the arc lengths if 211 210 ///it is necessary. The default map type is \ref 212 ///concepts::Digraph::ArcMap "Digraph::ArcMap<int>". 213 ///The value of LM is not used directly by \ref Dijkstra, it is only 214 ///passed to \ref DijkstraDefaultTraits. 215 ///\tparam TR Traits class to set various data types used by the algorithm. 216 ///The default traits class is \ref DijkstraDefaultTraits 217 ///"DijkstraDefaultTraits<GR,LM>". See \ref DijkstraDefaultTraits 218 ///for the documentation of a Dijkstra traits class. 211 ///concepts::Digraph::ArcMap "GR::ArcMap<int>". 219 212 #ifdef DOXYGEN 220 213 template <typename GR, typename LM, typename TR> … … 250 243 typedef typename TR::OperationTraits OperationTraits; 251 244 252 ///The traits class.245 ///The \ref DijkstraDefaultTraits "traits class" of the algorithm. 253 246 typedef TR Traits; 254 247 … … 332 325 ///\ref named-templ-param "Named parameter" for setting 333 326 ///PredMap type. 327 ///It must meet the \ref concepts::WriteMap "WriteMap" concept. 334 328 template <class T> 335 329 struct SetPredMap … … 352 346 ///\ref named-templ-param "Named parameter" for setting 353 347 ///DistMap type. 348 ///It must meet the \ref concepts::WriteMap "WriteMap" concept. 354 349 template <class T> 355 350 struct SetDistMap … … 372 367 ///\ref named-templ-param "Named parameter" for setting 373 368 ///ProcessedMap type. 369 ///It must meet the \ref concepts::WriteMap "WriteMap" concept. 374 370 template <class T> 375 371 struct SetProcessedMap … … 412 408 }; 413 409 ///\brief \ref named-templ-param "Named parameter" for setting 414 ///heap and cross reference type 410 ///heap and cross reference types 415 411 /// 416 412 ///\ref named-templ-param "Named parameter" for setting heap and cross 417 ///reference type. 413 ///reference types. If this named parameter is used, then external 414 ///heap and cross reference objects must be passed to the algorithm 415 ///using the \ref heap() function before calling \ref run(Node) "run()" 416 ///or \ref init(). 417 ///\sa SetStandardHeap 418 418 template <class H, class CR = typename Digraph::template NodeMap<int> > 419 419 struct SetHeap … … 435 435 }; 436 436 ///\brief \ref named-templ-param "Named parameter" for setting 437 ///heap and cross reference type with automatic allocation437 ///heap and cross reference types with automatic allocation 438 438 /// 439 439 ///\ref named-templ-param "Named parameter" for setting heap and cross 440 ///reference type. It can allocate the heap and the cross reference 441 ///object if the cross reference's constructor waits for the digraph as 442 ///parameter and the heap's constructor waits for the cross reference. 440 ///reference types with automatic allocation. 441 ///They should have standard constructor interfaces to be able to 442 ///automatically created by the algorithm (i.e. the digraph should be 443 ///passed to the constructor of the cross reference and the cross 444 ///reference should be passed to the constructor of the heap). 445 ///However external heap and cross reference objects could also be 446 ///passed to the algorithm using the \ref heap() function before 447 ///calling \ref run(Node) "run()" or \ref init(). 448 ///\sa SetHeap 443 449 template <class H, class CR = typename Digraph::template NodeMap<int> > 444 450 struct SetStandardHeap … … 510 516 511 517 ///Sets the map that stores the predecessor arcs. 512 ///If you don't use this function before calling \ref run(), 513 ///it will allocate one. The destructor deallocates this 514 ///automatically allocated map, of course. 518 ///If you don't use this function before calling \ref run(Node) "run()" 519 ///or \ref init(), an instance will be allocated automatically. 520 ///The destructor deallocates this automatically allocated map, 521 ///of course. 515 522 ///\return <tt> (*this) </tt> 516 523 Dijkstra &predMap(PredMap &m) … … 527 534 528 535 ///Sets the map that indicates which nodes are processed. 529 ///If you don't use this function before calling \ref run(), 530 ///it will allocate one. The destructor deallocates this 531 ///automatically allocated map, of course. 536 ///If you don't use this function before calling \ref run(Node) "run()" 537 ///or \ref init(), an instance will be allocated automatically. 538 ///The destructor deallocates this automatically allocated map, 539 ///of course. 532 540 ///\return <tt> (*this) </tt> 533 541 Dijkstra &processedMap(ProcessedMap &m) … … 545 553 ///Sets the map that stores the distances of the nodes calculated by the 546 554 ///algorithm. 547 ///If you don't use this function before calling \ref run(), 548 ///it will allocate one. The destructor deallocates this 549 ///automatically allocated map, of course. 555 ///If you don't use this function before calling \ref run(Node) "run()" 556 ///or \ref init(), an instance will be allocated automatically. 557 ///The destructor deallocates this automatically allocated map, 558 ///of course. 550 559 ///\return <tt> (*this) </tt> 551 560 Dijkstra &distMap(DistMap &m) … … 562 571 563 572 ///Sets the heap and the cross reference used by algorithm. 564 ///If you don't use this function before calling \ref run(), 565 ///it will allocate one. The destructor deallocates this 566 ///automatically allocated heap and cross reference, of course. 573 ///If you don't use this function before calling \ref run(Node) "run()" 574 ///or \ref init(), heap and cross reference instances will be 575 ///allocated automatically. 576 ///The destructor deallocates these automatically allocated objects, 577 ///of course. 567 578 ///\return <tt> (*this) </tt> 568 579 Dijkstra &heap(Heap& hp, HeapCrossRef &cr) … … 591 602 public: 592 603 593 ///\name Execution control 594 ///The simplest way to execute the algorithm is to use one of the 595 ///member functions called \ref lemon::Dijkstra::run() "run()". 596 ///\n 597 ///If you need more control on the execution, first you must call 598 ///\ref lemon::Dijkstra::init() "init()", then you can add several 599 ///source nodes with \ref lemon::Dijkstra::addSource() "addSource()". 600 ///Finally \ref lemon::Dijkstra::start() "start()" will perform the 601 ///actual path computation. 604 ///\name Execution Control 605 ///The simplest way to execute the %Dijkstra algorithm is to use 606 ///one of the member functions called \ref run(Node) "run()".\n 607 ///If you need more control on the execution, first you have to call 608 ///\ref init(), then you can add several source nodes with 609 ///\ref addSource(). Finally the actual path computation can be 610 ///performed with one of the \ref start() functions. 602 611 603 612 ///@{ 604 613 614 ///\brief Initializes the internal data structures. 615 /// 605 616 ///Initializes the internal data structures. 606 607 ///Initializes the internal data structures.608 ///609 617 void init() 610 618 { … … 682 690 } 683 691 684 ///\brief Returns \c false if there are nodes 685 ///to be processed. 686 /// 687 ///Returns \c false if there are nodes 688 ///to be processed in the priority heap. 692 ///Returns \c false if there are nodes to be processed. 693 694 ///Returns \c false if there are nodes to be processed 695 ///in the priority heap. 689 696 bool emptyQueue() const { return _heap->empty(); } 690 697 691 ///Returns the number of the nodes to be processed in the priority heap692 693 ///Returns the number of the nodes to be processed in the priority heap.694 /// 698 ///Returns the number of the nodes to be processed. 699 700 ///Returns the number of the nodes to be processed 701 ///in the priority heap. 695 702 int queueSize() const { return _heap->size(); } 696 703 … … 813 820 814 821 ///\name Query Functions 815 ///The result of the %Dijkstra algorithm can be obtained using these822 ///The results of the %Dijkstra algorithm can be obtained using these 816 823 ///functions.\n 817 ///Either \ref lemon::Dijkstra::run() "run()" or 818 ///\ref lemon::Dijkstra::start() "start()" must be called before 819 ///using them. 824 ///Either \ref run(Node) "run()" or \ref start() should be called 825 ///before using them. 820 826 821 827 ///@{ … … 825 831 ///Returns the shortest path to a node. 826 832 /// 827 ///\warning \c t should be reach ablefrom the root(s).828 /// 829 ///\pre Either \ref run( ) or \ref start() must be called before830 /// using this function.833 ///\warning \c t should be reached from the root(s). 834 /// 835 ///\pre Either \ref run(Node) "run()" or \ref init() 836 ///must be called before using this function. 831 837 Path path(Node t) const { return Path(*G, *_pred, t); } 832 838 … … 835 841 ///Returns the distance of a node from the root(s). 836 842 /// 837 ///\warning If node \c v is not reach ablefrom the root(s), then843 ///\warning If node \c v is not reached from the root(s), then 838 844 ///the return value of this function is undefined. 839 845 /// 840 ///\pre Either \ref run( ) or \ref start() must be called before841 /// using this function.846 ///\pre Either \ref run(Node) "run()" or \ref init() 847 ///must be called before using this function. 842 848 Value dist(Node v) const { return (*_dist)[v]; } 843 849 … … 846 852 ///This function returns the 'previous arc' of the shortest path 847 853 ///tree for the node \c v, i.e. it returns the last arc of a 848 ///shortest path from the root(s)to \c v. It is \c INVALID if \c v849 ///is not reach ablefrom the root(s) or if \c v is a root.854 ///shortest path from a root to \c v. It is \c INVALID if \c v 855 ///is not reached from the root(s) or if \c v is a root. 850 856 /// 851 857 ///The shortest path tree used here is equal to the shortest path 852 858 ///tree used in \ref predNode(). 853 859 /// 854 ///\pre Either \ref run( ) or \ref start() must be called before855 /// using this function.860 ///\pre Either \ref run(Node) "run()" or \ref init() 861 ///must be called before using this function. 856 862 Arc predArc(Node v) const { return (*_pred)[v]; } 857 863 … … 860 866 ///This function returns the 'previous node' of the shortest path 861 867 ///tree for the node \c v, i.e. it returns the last but one node 862 ///from a shortest path from the root(s)to \c v. It is \c INVALID863 ///if \c v is not reach ablefrom the root(s) or if \c v is a root.868 ///from a shortest path from a root to \c v. It is \c INVALID 869 ///if \c v is not reached from the root(s) or if \c v is a root. 864 870 /// 865 871 ///The shortest path tree used here is equal to the shortest path 866 872 ///tree used in \ref predArc(). 867 873 /// 868 ///\pre Either \ref run( ) or \ref start() must be called before869 /// using this function.874 ///\pre Either \ref run(Node) "run()" or \ref init() 875 ///must be called before using this function. 870 876 Node predNode(Node v) const { return (*_pred)[v]==INVALID ? INVALID: 871 877 G->source((*_pred)[v]); } … … 877 883 ///of the nodes calculated by the algorithm. 878 884 /// 879 ///\pre Either \ref run( )or \ref init()885 ///\pre Either \ref run(Node) "run()" or \ref init() 880 886 ///must be called before using this function. 881 887 const DistMap &distMap() const { return *_dist;} … … 887 893 ///arcs, which form the shortest path tree. 888 894 /// 889 ///\pre Either \ref run( )or \ref init()895 ///\pre Either \ref run(Node) "run()" or \ref init() 890 896 ///must be called before using this function. 891 897 const PredMap &predMap() const { return *_pred;} 892 898 893 ///Checks if a node is reachable from the root(s). 894 895 ///Returns \c true if \c v is reachable from the root(s). 896 ///\pre Either \ref run() or \ref start() 899 ///Checks if a node is reached from the root(s). 900 901 ///Returns \c true if \c v is reached from the root(s). 902 /// 903 ///\pre Either \ref run(Node) "run()" or \ref init() 897 904 ///must be called before using this function. 898 905 bool reached(Node v) const { return (*_heap_cross_ref)[v] != … … 903 910 ///Returns \c true if \c v is processed, i.e. the shortest 904 911 ///path to \c v has already found. 905 ///\pre Either \ref run() or \ref init() 912 /// 913 ///\pre Either \ref run(Node) "run()" or \ref init() 906 914 ///must be called before using this function. 907 915 bool processed(Node v) const { return (*_heap_cross_ref)[v] == … … 912 920 ///Returns the current distance of a node from the root(s). 913 921 ///It may be decreased in the following processes. 914 ///\pre Either \ref run() or \ref init() 922 /// 923 ///\pre Either \ref run(Node) "run()" or \ref init() 915 924 ///must be called before using this function and 916 925 ///node \c v must be reached but not necessarily processed. … … 1095 1104 /// This auxiliary class is created to implement the 1096 1105 /// \ref dijkstra() "function-type interface" of \ref Dijkstra algorithm. 1097 /// It does not have own \ref run( ) method, it uses the functions1098 /// and features of the plain \ref Dijkstra.1106 /// It does not have own \ref run(Node) "run()" method, it uses the 1107 /// functions and features of the plain \ref Dijkstra. 1099 1108 /// 1100 1109 /// This class should only be used through the \ref dijkstra() function, … … 1291 1300 /// bool reached = dijkstra(g,length).path(p).dist(d).run(s,t); 1292 1301 ///\endcode 1293 ///\warning Don't forget to put the \ref DijkstraWizard::run( ) "run()"1302 ///\warning Don't forget to put the \ref DijkstraWizard::run(Node) "run()" 1294 1303 ///to the end of the parameter list. 1295 1304 ///\sa DijkstraWizard
Note: See TracChangeset
for help on using the changeset viewer.