Description of the LEMON directories.
2 * src/lemon/dijkstra.h - Part of LEMON, a generic C++ optimization library
4 * Copyright (C) 2004 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
5 * (Egervary Combinatorial Optimization Research Group, EGRES).
7 * Permission to use, modify and distribute this software is granted
8 * provided that this copyright notice appears in all copies. For
9 * precise terms see the accompanying LICENSE file.
11 * This software is provided "AS IS" with no warranty of any kind,
12 * express or implied, and with no claim as to its suitability for any
17 #ifndef LEMON_DIJKSTRA_H
18 #define LEMON_DIJKSTRA_H
22 ///\brief Dijkstra algorithm.
24 #include <lemon/list_graph.h>
25 #include <lemon/bin_heap.h>
26 #include <lemon/invalid.h>
27 #include <lemon/error.h>
28 #include <lemon/maps.h>
34 ///Default traits class of Dijkstra class.
36 ///Default traits class of Dijkstra class.
37 ///\param GR Graph type.
38 ///\param LM Type of length map.
39 template<class GR, class LM>
40 struct DijkstraDefaultTraits
42 ///The graph type the algorithm runs on.
44 ///The type of the map that stores the edge lengths.
46 ///The type of the map that stores the edge lengths.
47 ///It must meet the \ref concept::ReadMap "ReadMap" concept.
49 //The type of the length of the edges.
50 typedef typename LM::Value Value;
51 ///The heap type used by Dijkstra algorithm.
53 ///The heap type used by Dijkstra algorithm.
57 typedef BinHeap<typename Graph::Node,
59 typename GR::template NodeMap<int>,
60 std::less<Value> > Heap;
62 ///\brief The type of the map that stores the last
63 ///edges of the shortest paths.
65 ///The type of the map that stores the last
66 ///edges of the shortest paths.
67 ///It must meet the \ref concept::WriteMap "WriteMap" concept.
69 typedef typename Graph::template NodeMap<typename GR::Edge> PredMap;
70 ///Instantiates a PredMap.
72 ///This function instantiates a \ref PredMap.
73 ///\param G is the graph, to which we would like to define the PredMap.
74 ///\todo The graph alone may be insufficient for the initialization
75 static PredMap *createPredMap(const GR &G)
77 return new PredMap(G);
79 ///\brief The type of the map that stores the last but one
80 ///nodes of the shortest paths.
82 ///The type of the map that stores the last but one
83 ///nodes of the shortest paths.
84 ///It must meet the \ref concept::WriteMap "WriteMap" concept.
86 typedef NullMap<typename Graph::Node,typename Graph::Node> PredNodeMap;
87 ///Instantiates a PredNodeMap.
89 ///This function instantiates a \ref PredNodeMap.
90 ///\param G is the graph, to which we would like to define the \ref PredNodeMap
91 static PredNodeMap *createPredNodeMap(const GR &G)
93 return new PredNodeMap();
96 ///The type of the map that stores whether a nodes is reached.
98 ///The type of the map that stores whether a nodes is reached.
99 ///It must meet the \ref concept::WriteMap "WriteMap" concept.
100 ///By default it is a NullMap.
101 ///\todo If it is set to a real map, Dijkstra::reached() should read this.
102 ///\todo named parameter to set this type, function to read and write.
103 typedef NullMap<typename Graph::Node,bool> ReachedMap;
104 ///Instantiates a ReachedMap.
106 ///This function instantiates a \ref ReachedMap.
107 ///\param G is the graph, to which we would like to define the \ref ReachedMap
108 static ReachedMap *createReachedMap(const GR &G)
110 return new ReachedMap();
112 ///The type of the map that stores the dists of the nodes.
114 ///The type of the map that stores the dists of the nodes.
115 ///It must meet the \ref concept::WriteMap "WriteMap" concept.
117 typedef typename Graph::template NodeMap<typename LM::Value> DistMap;
118 ///Instantiates a DistMap.
120 ///This function instantiates a \ref DistMap.
121 ///\param G is the graph, to which we would like to define the \ref DistMap
122 static DistMap *createDistMap(const GR &G)
124 return new DistMap(G);
128 ///%Dijkstra algorithm class.
130 /// \ingroup flowalgs
131 ///This class provides an efficient implementation of %Dijkstra algorithm.
132 ///The edge lengths are passed to the algorithm using a
133 ///\ref concept::ReadMap "ReadMap",
134 ///so it is easy to change it to any kind of length.
136 ///The type of the length is determined by the
137 ///\ref concept::ReadMap::Value "Value" of the length map.
139 ///It is also possible to change the underlying priority heap.
141 ///\param GR The graph type the algorithm runs on. The default value is
142 ///\ref ListGraph. The value of GR is not used directly by Dijkstra, it
143 ///is only passed to \ref DijkstraDefaultTraits.
144 ///\param LM This read-only
147 ///lengths of the edges. It is read once for each edge, so the map
148 ///may involve in relatively time consuming process to compute the edge
149 ///length if it is necessary. The default map type is
150 ///\ref concept::StaticGraph::EdgeMap "Graph::EdgeMap<int>".
151 ///The value of LM is not used directly by Dijkstra, it
152 ///is only passed to \ref DijkstraDefaultTraits.
153 ///\param TR Traits class to set various data types used by the algorithm.
154 ///The default traits class is
155 ///\ref DijkstraDefaultTraits "DijkstraDefaultTraits<GR,LM>".
156 ///See \ref DijkstraDefaultTraits for the documentation of
157 ///a Dijkstra traits class.
159 ///\author Jacint Szabo and Alpar Juttner
160 ///\todo A compare object would be nice.
163 template <typename GR,
167 template <typename GR=ListGraph,
168 typename LM=typename GR::template EdgeMap<int>,
169 typename TR=DijkstraDefaultTraits<GR,LM> >
174 * \brief \ref Exception for uninitialized parameters.
176 * This error represents problems in the initialization
177 * of the parameters of the algorithms.
179 class UninitializedParameter : public lemon::UninitializedParameter {
181 virtual const char* exceptionName() const {
182 return "lemon::Dijsktra::UninitializedParameter";
187 ///The type of the underlying graph.
188 typedef typename TR::Graph Graph;
190 typedef typename Graph::Node Node;
192 typedef typename Graph::NodeIt NodeIt;
194 typedef typename Graph::Edge Edge;
196 typedef typename Graph::OutEdgeIt OutEdgeIt;
198 ///The type of the length of the edges.
199 typedef typename TR::LengthMap::Value Value;
200 ///The type of the map that stores the edge lengths.
201 typedef typename TR::LengthMap LengthMap;
202 ///\brief The type of the map that stores the last
203 ///edges of the shortest paths.
204 typedef typename TR::PredMap PredMap;
205 ///\brief The type of the map that stores the last but one
206 ///nodes of the shortest paths.
207 typedef typename TR::PredNodeMap PredNodeMap;
208 ///The type of the map indicating if a node is reached.
209 typedef typename TR::ReachedMap ReachedMap;
210 ///The type of the map that stores the dists of the nodes.
211 typedef typename TR::DistMap DistMap;
212 ///The heap type used by the dijkstra algorithm.
213 typedef typename TR::Heap Heap;
215 /// Pointer to the underlying graph.
217 /// Pointer to the length map
218 const LengthMap *length;
219 ///Pointer to the map of predecessors edges.
221 ///Indicates if \ref _pred is locally allocated (\c true) or not.
223 ///Pointer to the map of predecessors nodes.
224 PredNodeMap *_predNode;
225 ///Indicates if \ref _predNode is locally allocated (\c true) or not.
227 ///Pointer to the map of distances.
229 ///Indicates if \ref _dist is locally allocated (\c true) or not.
231 ///Pointer to the map of reached status of the nodes.
232 ReachedMap *_reached;
233 ///Indicates if \ref _reached is locally allocated (\c true) or not.
236 ///The source node of the last execution.
239 ///Creates the maps if necessary.
241 ///\todo Error if \c G or are \c NULL. What about \c length?
242 ///\todo Better memory allocation (instead of new).
247 _pred = Traits::createPredMap(*G);
250 local_predNode = true;
251 _predNode = Traits::createPredNodeMap(*G);
255 _dist = Traits::createDistMap(*G);
258 local_reached = true;
259 _reached = Traits::createReachedMap(*G);
265 ///\name Named template parameters
270 struct DefPredMapTraits : public Traits {
272 static PredMap *createPredMap(const Graph &G)
274 throw UninitializedParameter();
277 ///\ref named-templ-param "Named parameter" for setting PredMap type
279 ///\ref named-templ-param "Named parameter" for setting PredMap type
282 class DefPredMap : public Dijkstra< Graph,
284 DefPredMapTraits<T> > { };
287 struct DefPredNodeMapTraits : public Traits {
288 typedef T PredNodeMap;
289 static PredNodeMap *createPredNodeMap(const Graph &G)
291 throw UninitializedParameter();
294 ///\ref named-templ-param "Named parameter" for setting PredNodeMap type
296 ///\ref named-templ-param "Named parameter" for setting PredNodeMap type
299 class DefPredNodeMap : public Dijkstra< Graph,
301 DefPredNodeMapTraits<T> > { };
304 struct DefDistMapTraits : public Traits {
306 static DistMap *createDistMap(const Graph &G)
308 throw UninitializedParameter();
311 ///\ref named-templ-param "Named parameter" for setting DistMap type
313 ///\ref named-templ-param "Named parameter" for setting DistMap type
316 class DefDistMap : public Dijkstra< Graph,
318 DefDistMapTraits<T> > { };
321 struct DefReachedMapTraits : public Traits {
322 typedef T ReachedMap;
323 static ReachedMap *createReachedMap(const Graph &G)
325 throw UninitializedParameter();
328 ///\ref named-templ-param "Named parameter" for setting ReachedMap type
330 ///\ref named-templ-param "Named parameter" for setting ReachedMap type
333 class DefReachedMap : public Dijkstra< Graph,
335 DefReachedMapTraits<T> > { };
337 struct DefGraphReachedMapTraits : public Traits {
338 typedef typename Graph::NodeMap<bool> ReachedMap;
339 static ReachedMap *createReachedMap(const Graph &G)
341 return new ReachedMap(G);
344 ///\brief \ref named-templ-param "Named parameter"
345 ///for setting the ReachedMap type to be Graph::NodeMap<bool>.
347 ///\ref named-templ-param "Named parameter"
348 ///for setting the ReachedMap type to be Graph::NodeMap<bool>.
349 ///If you don't set it explicitely, it will be automatically allocated.
351 class DefReachedMapToBeDefaultMap :
352 public Dijkstra< Graph,
354 DefGraphReachedMapTraits> { };
360 typename Graph::template NodeMap<int> _heap_map;
366 ///\param _G the graph the algorithm will run on.
367 ///\param _length the length map used by the algorithm.
368 Dijkstra(const Graph& _G, const LengthMap& _length) :
369 G(&_G), length(&_length),
370 _pred(NULL), local_pred(false),
371 _predNode(NULL), local_predNode(false),
372 _dist(NULL), local_dist(false),
373 _reached(NULL), local_reached(false),
374 _heap_map(*G,-1),_heap(_heap_map)
380 if(local_pred) delete _pred;
381 if(local_predNode) delete _predNode;
382 if(local_dist) delete _dist;
383 if(local_reached) delete _reached;
386 ///Sets the length map.
388 ///Sets the length map.
389 ///\return <tt> (*this) </tt>
390 Dijkstra &lengthMap(const LengthMap &m)
396 ///Sets the map storing the predecessor edges.
398 ///Sets the map storing the predecessor edges.
399 ///If you don't use this function before calling \ref run(),
400 ///it will allocate one. The destuctor deallocates this
401 ///automatically allocated map, of course.
402 ///\return <tt> (*this) </tt>
403 Dijkstra &predMap(PredMap &m)
413 ///Sets the map storing the predecessor nodes.
415 ///Sets the map storing the predecessor nodes.
416 ///If you don't use this function before calling \ref run(),
417 ///it will allocate one. The destuctor deallocates this
418 ///automatically allocated map, of course.
419 ///\return <tt> (*this) </tt>
420 Dijkstra &predNodeMap(PredNodeMap &m)
424 local_predNode=false;
430 ///Sets the map storing the distances calculated by the algorithm.
432 ///Sets the map storing the distances calculated by the algorithm.
433 ///If you don't use this function before calling \ref run(),
434 ///it will allocate one. The destuctor deallocates this
435 ///automatically allocated map, of course.
436 ///\return <tt> (*this) </tt>
437 Dijkstra &distMap(DistMap &m)
448 void finalizeNodeData(Node v,Value dst)
450 _reached->set(v,true);
452 _predNode->set(v,G->source((*_pred)[v]));
456 ///\name Excetution control
457 ///The simplest way to execute the algorithm is to use
460 ///It you need more control on the execution,
461 ///first you must call \ref init(), then you can add several source nodes
462 ///with \ref addSource(). Finally \ref start() will perform the actual path
467 ///Initializes the internal data structures.
469 ///Initializes the internal data structures.
471 ///\todo _heap_map's type could also be in the traits class.
476 for ( NodeIt u(*G) ; u!=INVALID ; ++u ) {
477 _pred->set(u,INVALID);
478 _predNode->set(u,INVALID);
479 ///\todo *_reached is not set to false.
480 _heap_map.set(u,Heap::PRE_HEAP);
484 ///Adds a new source node.
486 ///Adds a new source node the the priority heap.
487 ///It checks if the node has already been added to the heap.
489 ///The optional second parameter is the initial distance of the node.
491 ///\todo Do we really want to check it?
492 void addSource(Node s,Value dst=0)
495 if(_heap.state(s) != Heap::IN_HEAP) _heap.push(s,dst);
498 void processNextNode()
501 Value oldvalue=_heap[v];
503 finalizeNodeData(v,oldvalue);
505 for(OutEdgeIt e(*G,v); e!=INVALID; ++e) {
507 switch(_heap.state(w)) {
509 _heap.push(w,oldvalue+(*length)[e]);
511 // _predNode->set(w,v);
514 if ( oldvalue+(*length)[e] < _heap[w] ) {
515 _heap.decrease(w, oldvalue+(*length)[e]);
517 // _predNode->set(w,v);
520 case Heap::POST_HEAP:
526 ///Executes the algorithm.
528 ///Executes the algorithm.
530 ///\pre init() must be called and at least one node should be added
531 ///with addSource() before using this function.
533 ///This method runs the %Dijkstra algorithm from the root node(s)
536 ///shortest path to each node. The algorithm computes
537 ///- The shortest path tree.
538 ///- The distance of each node from the root(s).
542 while ( !_heap.empty() ) processNextNode();
545 ///Executes the algorithm until \c dest is reached.
547 ///Executes the algorithm until \c dest is reached.
549 ///\pre init() must be called and at least one node should be added
550 ///with addSource() before using this function.
552 ///This method runs the %Dijkstra algorithm from the root node(s)
555 ///shortest path to \c dest. The algorithm computes
556 ///- The shortest path to \c dest.
557 ///- The distance of \c dest from the root(s).
559 void start(Node dest)
561 while ( !_heap.empty() && _heap.top()!=dest ) processNextNode();
562 if ( _heap.top()==dest ) finalizeNodeData(_heap.top());
565 ///Executes the algorithm until a condition is met.
567 ///Executes the algorithm until a condition is met.
569 ///\pre init() must be called and at least one node should be added
570 ///with addSource() before using this function.
572 ///\param nm must be a bool (or convertible) node map. The algorithm
573 ///will stop when it reaches a node \c v with <tt>nm[v]==true</tt>.
575 void start(const NM &nm)
577 while ( !_heap.empty() && !mn[_heap.top()] ) processNextNode();
578 if ( !_heap.empty() ) finalizeNodeData(_heap.top());
581 ///Runs %Dijkstra algorithm from node \c s.
583 ///This method runs the %Dijkstra algorithm from a root node \c s
586 ///shortest path to each node. The algorithm computes
587 ///- The shortest path tree.
588 ///- The distance of each node from the root.
590 ///\note d.run(s) is just a shortcut of the following code.
602 ///Finds the shortest path between \c s and \c t.
604 ///Finds the shortest path between \c s and \c t.
606 ///\return The length of the shortest s---t path if there exists one,
608 ///\note Apart from the return value, d.run(s) is
609 ///just a shortcut of the following code.
615 Value run(Node s,Node t) {
619 return (*_pred)[t]==INVALID?0:(*_dist)[t];
624 ///\name Query Functions
625 ///The result of the %Dijkstra algorithm can be obtained using these
627 ///Before the use of these functions,
628 ///either run() or start() must be called.
632 ///The distance of a node from the root.
634 ///Returns the distance of a node from the root.
635 ///\pre \ref run() must be called before using this function.
636 ///\warning If node \c v in unreachable from the root the return value
637 ///of this funcion is undefined.
638 Value dist(Node v) const { return (*_dist)[v]; }
640 ///Returns the 'previous edge' of the shortest path tree.
642 ///For a node \c v it returns the 'previous edge' of the shortest path tree,
643 ///i.e. it returns the last edge of a shortest path from the root to \c
644 ///v. It is \ref INVALID
645 ///if \c v is unreachable from the root or if \c v=s. The
646 ///shortest path tree used here is equal to the shortest path tree used in
647 ///\ref predNode(Node v). \pre \ref run() must be called before using
649 ///\todo predEdge could be a better name.
650 Edge pred(Node v) const { return (*_pred)[v]; }
652 ///Returns the 'previous node' of the shortest path tree.
654 ///For a node \c v it returns the 'previous node' of the shortest path tree,
655 ///i.e. it returns the last but one node from a shortest path from the
656 ///root to \c /v. It is INVALID if \c v is unreachable from the root or if
657 ///\c v=s. The shortest path tree used here is equal to the shortest path
658 ///tree used in \ref pred(Node v). \pre \ref run() must be called before
659 ///using this function.
660 Node predNode(Node v) const { return (*_pred)[v]==INVALID ? INVALID:
661 G->source((*_pred)[v]); }
663 ///Returns a reference to the NodeMap of distances.
665 ///Returns a reference to the NodeMap of distances. \pre \ref run() must
666 ///be called before using this function.
667 const DistMap &distMap() const { return *_dist;}
669 ///Returns a reference to the shortest path tree map.
671 ///Returns a reference to the NodeMap of the edges of the
672 ///shortest path tree.
673 ///\pre \ref run() must be called before using this function.
674 const PredMap &predMap() const { return *_pred;}
676 ///Returns a reference to the map of nodes of shortest paths.
678 ///Returns a reference to the NodeMap of the last but one nodes of the
679 ///shortest path tree.
680 ///\pre \ref run() must be called before using this function.
681 const PredNodeMap &predNodeMap() const { return *_predNode;}
683 ///Checks if a node is reachable from the root.
685 ///Returns \c true if \c v is reachable from the root.
686 ///\warning If the algorithm is started from multiple nodes,
687 ///this function may give false result for the source nodes.
688 ///\pre \ref run() must be called before using this function.
690 bool reached(Node v) { return v==source || (*_pred)[v]!=INVALID; }
695 /// Default traits used by \ref DijkstraWizard
697 /// To make it easier to use Dijkstra algorithm
698 ///we have created a wizard class.
699 /// This \ref DijkstraWizard class needs default traits,
700 ///as well as the \ref Dijkstra class.
701 /// The \ref DijkstraWizardBase is a class to be the default traits of the
702 /// \ref DijkstraWizard class.
703 template<class GR,class LM>
704 class DijkstraWizardBase : public DijkstraDefaultTraits<GR,LM>
707 typedef DijkstraDefaultTraits<GR,LM> Base;
709 /// Pointer to the underlying graph.
711 /// Pointer to the length map
713 ///Pointer to the map of predecessors edges.
715 ///Pointer to the map of predecessors nodes.
717 ///Pointer to the map of distances.
719 ///Pointer to the source node.
722 /// Type of the nodes in the graph.
723 typedef typename Base::Graph::Node Node;
728 /// This constructor does not require parameters, therefore it initiates
729 /// all of the attributes to default values (0, INVALID).
730 DijkstraWizardBase() : _g(0), _length(0), _pred(0), _predNode(0),
731 _dist(0), _source(INVALID) {}
735 /// This constructor requires some parameters, listed in the parameters list.
736 /// Others are initiated to 0.
737 /// \param g is the initial value of \ref _g
738 /// \param l is the initial value of \ref _length
739 /// \param s is the initial value of \ref _source
740 DijkstraWizardBase(const GR &g,const LM &l, Node s=INVALID) :
741 _g((void *)&g), _length((void *)&l), _pred(0), _predNode(0),
742 _dist(0), _source((void *)&s) {}
746 /// A class to make easier the usage of Dijkstra algorithm
748 /// \ingroup flowalgs
749 /// This class is created to make it easier to use Dijkstra algorithm.
750 /// It uses the functions and features of the plain \ref Dijkstra,
751 /// but it is much simpler to use it.
753 /// Simplicity means that the way to change the types defined
754 /// in the traits class is based on functions that returns the new class
755 /// and not on templatable built-in classes.
756 /// When using the plain \ref Dijkstra
757 /// the new class with the modified type comes from
758 /// the original class by using the ::
759 /// operator. In the case of \ref DijkstraWizard only
760 /// a function have to be called and it will
761 /// return the needed class.
763 /// It does not have own \ref run method. When its \ref run method is called
764 /// it initiates a plain \ref Dijkstra class, and calls the \ref Dijkstra::run
767 class DijkstraWizard : public TR
771 ///The type of the underlying graph.
772 typedef typename TR::Graph Graph;
774 typedef typename Graph::Node Node;
776 typedef typename Graph::NodeIt NodeIt;
778 typedef typename Graph::Edge Edge;
780 typedef typename Graph::OutEdgeIt OutEdgeIt;
782 ///The type of the map that stores the edge lengths.
783 typedef typename TR::LengthMap LengthMap;
784 ///The type of the length of the edges.
785 typedef typename LengthMap::Value Value;
786 ///\brief The type of the map that stores the last
787 ///edges of the shortest paths.
788 typedef typename TR::PredMap PredMap;
789 ///\brief The type of the map that stores the last but one
790 ///nodes of the shortest paths.
791 typedef typename TR::PredNodeMap PredNodeMap;
792 ///The type of the map that stores the dists of the nodes.
793 typedef typename TR::DistMap DistMap;
795 ///The heap type used by the dijkstra algorithm.
796 typedef typename TR::Heap Heap;
799 DijkstraWizard() : TR() {}
801 /// Constructor that requires parameters.
803 /// Constructor that requires parameters.
804 /// These parameters will be the default values for the traits class.
805 DijkstraWizard(const Graph &g,const LengthMap &l, Node s=INVALID) :
809 DijkstraWizard(const TR &b) : TR(b) {}
813 ///Runs Dijkstra algorithm from a given node.
815 ///Runs Dijkstra algorithm from a given node.
816 ///The node can be given by the \ref source function.
819 if(_source==0) throw UninitializedParameter();
820 Dijkstra<Graph,LengthMap,TR> Dij(*(Graph*)_g,*(LengthMap*)_length);
821 if(_pred) Dij.predMap(*(PredMap*)_pred);
822 if(_predNode) Dij.predNodeMap(*(PredNodeMap*)_predNode);
823 if(_dist) Dij.distMap(*(DistMap*)_dist);
824 Dij.run(*(Node*)_source);
827 ///Runs Dijkstra algorithm from the given node.
829 ///Runs Dijkstra algorithm from the given node.
830 ///\param s is the given source.
838 struct DefPredMapBase : public Base {
840 static PredMap *createPredMap(const Graph &G) { return 0; };
841 DefPredMapBase(const Base &b) : Base(b) {}
844 /// \ref named-templ-param "Named parameter" function for setting PredMap type
846 /// \ref named-templ-param "Named parameter" function for setting PredMap type
849 DijkstraWizard<DefPredMapBase<T> > predMap(const T &t)
852 return DijkstraWizard<DefPredMapBase<T> >(*this);
857 struct DefPredNodeMapBase : public Base {
858 typedef T PredNodeMap;
859 static PredNodeMap *createPredNodeMap(const Graph &G) { return 0; };
860 DefPredNodeMapBase(const Base &b) : Base(b) {}
863 /// \ref named-templ-param "Named parameter" function for setting PredNodeMap type
865 /// \ref named-templ-param "Named parameter" function for setting PredNodeMap type
868 DijkstraWizard<DefPredNodeMapBase<T> > predNodeMap(const T &t)
870 _predNode=(void *)&t;
871 return DijkstraWizard<DefPredNodeMapBase<T> >(*this);
875 struct DefDistMapBase : public Base {
877 static DistMap *createDistMap(const Graph &G) { return 0; };
878 DefDistMapBase(const Base &b) : Base(b) {}
881 /// \ref named-templ-param "Named parameter" function for setting DistMap type
883 /// \ref named-templ-param "Named parameter" function for setting DistMap type
886 DijkstraWizard<DefDistMapBase<T> > distMap(const T &t)
889 return DijkstraWizard<DefDistMapBase<T> >(*this);
892 /// Sets the source node, from which the Dijkstra algorithm runs.
894 /// Sets the source node, from which the Dijkstra algorithm runs.
895 /// \param s is the source node.
896 DijkstraWizard<TR> &source(Node s)
906 /// \ingroup flowalgs
907 ///\todo Please document...
909 template<class GR, class LM>
910 DijkstraWizard<DijkstraWizardBase<GR,LM> >
911 dijkstra(const GR &g,const LM &l,typename GR::Node s=INVALID)
913 return DijkstraWizard<DijkstraWizardBase<GR,LM> >(g,l,s);
918 } //END OF NAMESPACE LEMON