Mapselector widget reached its first release, but there are still work to do on it, I know...
2 * lemon/belmann_ford.h - Part of LEMON, a generic C++ optimization library
4 * Copyright (C) 2005 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
5 * (Egervary Research Group on Combinatorial Optimization, 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_BELMANN_FORD_H
18 #define LEMON_BELMANN_FORD_H
22 /// \brief BelmannFord algorithm.
24 /// \todo getPath() should be implemented! (also for BFS and DFS)
26 #include <lemon/list_graph.h>
27 #include <lemon/invalid.h>
28 #include <lemon/error.h>
29 #include <lemon/maps.h>
35 /// \brief Default OperationTraits for the BelmannFord algorithm class.
37 /// It defines all computational operations and constants which are
38 /// used in the belmann ford algorithm. The default implementation
39 /// is based on the numeric_limits class. If the numeric type does not
40 /// have infinity value then the maximum value is used as extremal
44 bool has_infinity = std::numeric_limits<Value>::has_infinity>
45 struct BelmannFordDefaultOperationTraits {
46 /// \brief Gives back the zero value of the type.
48 return static_cast<Value>(0);
50 /// \brief Gives back the positive infinity value of the type.
51 static Value infinity() {
52 return std::numeric_limits<Value>::infinity();
54 /// \brief Gives back the sum of the given two elements.
55 static Value plus(const Value& left, const Value& right) {
58 /// \brief Gives back true only if the first value less than the second.
59 static bool less(const Value& left, const Value& right) {
64 template <typename Value>
65 struct BelmannFordDefaultOperationTraits<Value, false> {
67 return static_cast<Value>(0);
69 static Value infinity() {
70 return std::numeric_limits<Value>::max();
72 static Value plus(const Value& left, const Value& right) {
73 if (left == infinity() || right == infinity()) return infinity();
76 static bool less(const Value& left, const Value& right) {
81 /// \brief Default traits class of BelmannFord class.
83 /// Default traits class of BelmannFord class.
84 /// \param _Graph Graph type.
85 /// \param _LegthMap Type of length map.
86 template<class _Graph, class _LengthMap>
87 struct BelmannFordDefaultTraits {
88 /// The graph type the algorithm runs on.
91 /// \brief The type of the map that stores the edge lengths.
93 /// The type of the map that stores the edge lengths.
94 /// It must meet the \ref concept::ReadMap "ReadMap" concept.
95 typedef _LengthMap LengthMap;
97 // The type of the length of the edges.
98 typedef typename _LengthMap::Value Value;
100 /// \brief Operation traits for belmann-ford algorithm.
102 /// It defines the infinity type on the given Value type
103 /// and the used operation.
104 /// \see BelmannFordDefaultOperationTraits
105 typedef BelmannFordDefaultOperationTraits<Value> OperationTraits;
107 /// \brief The type of the map that stores the last edges of the
110 /// The type of the map that stores the last
111 /// edges of the shortest paths.
112 /// It must meet the \ref concept::WriteMap "WriteMap" concept.
114 typedef typename Graph::template NodeMap<typename _Graph::Edge> PredMap;
116 /// \brief Instantiates a PredMap.
118 /// This function instantiates a \ref PredMap.
119 /// \param G is the graph, to which we would like to define the PredMap.
120 /// \todo The graph alone may be insufficient for the initialization
121 static PredMap *createPredMap(const _Graph& graph) {
122 return new PredMap(graph);
125 /// \brief The type of the map that stores the dists of the nodes.
127 /// The type of the map that stores the dists of the nodes.
128 /// It must meet the \ref concept::WriteMap "WriteMap" concept.
130 typedef typename Graph::template NodeMap<typename _LengthMap::Value>
133 /// \brief Instantiates a DistMap.
135 /// This function instantiates a \ref DistMap.
136 /// \param G is the graph, to which we would like to define the
138 static DistMap *createDistMap(const _Graph& graph) {
139 return new DistMap(graph);
144 /// \brief BelmannFord algorithm class.
146 /// \ingroup flowalgs
147 /// This class provides an efficient implementation of \c Belmann-Ford
148 /// algorithm. The edge lengths are passed to the algorithm using a
149 /// \ref concept::ReadMap "ReadMap", so it is easy to change it to any
152 /// The Belmann-Ford algorithm solves the shortest path from one node
153 /// problem when the edges can have negative length but the graph should
154 /// not contain circle with negative sum of length. If we can assume
155 /// that all edge is non-negative in the graph then the dijkstra algorithm
156 /// should be used rather.
158 /// The complexity of the algorithm is O(n * e).
160 /// The type of the length is determined by the
161 /// \ref concept::ReadMap::Value "Value" of the length map.
163 /// \param _Graph The graph type the algorithm runs on. The default value
164 /// is \ref ListGraph. The value of _Graph is not used directly by
165 /// BelmannFord, it is only passed to \ref BelmannFordDefaultTraits.
166 /// \param _LengthMap This read-only EdgeMap determines the lengths of the
167 /// edges. The default map type is \ref concept::StaticGraph::EdgeMap
168 /// "Graph::EdgeMap<int>". The value of _LengthMap is not used directly
169 /// by BelmannFord, it is only passed to \ref BelmannFordDefaultTraits.
170 /// \param _Traits Traits class to set various data types used by the
171 /// algorithm. The default traits class is \ref BelmannFordDefaultTraits
172 /// "BelmannFordDefaultTraits<_Graph,_LengthMap>". See \ref
173 /// BelmannFordDefaultTraits for the documentation of a BelmannFord traits
176 /// \author Balazs Dezso
179 template <typename _Graph, typename _LengthMap, typename _Traits>
181 template <typename _Graph=ListGraph,
182 typename _LengthMap=typename _Graph::template EdgeMap<int>,
183 typename _Traits=BelmannFordDefaultTraits<_Graph,_LengthMap> >
188 /// \brief \ref Exception for uninitialized parameters.
190 /// This error represents problems in the initialization
191 /// of the parameters of the algorithms.
193 class UninitializedParameter : public lemon::UninitializedParameter {
195 virtual const char* exceptionName() const {
196 return "lemon::BelmannFord::UninitializedParameter";
200 typedef _Traits Traits;
201 ///The type of the underlying graph.
202 typedef typename _Traits::Graph Graph;
204 typedef typename Graph::Node Node;
205 typedef typename Graph::NodeIt NodeIt;
206 typedef typename Graph::Edge Edge;
207 typedef typename Graph::EdgeIt EdgeIt;
209 /// \brief The type of the length of the edges.
210 typedef typename _Traits::LengthMap::Value Value;
211 /// \brief The type of the map that stores the edge lengths.
212 typedef typename _Traits::LengthMap LengthMap;
213 /// \brief The type of the map that stores the last
214 /// edges of the shortest paths.
215 typedef typename _Traits::PredMap PredMap;
216 /// \brief The type of the map that stores the dists of the nodes.
217 typedef typename _Traits::DistMap DistMap;
218 /// \brief The operation traits.
219 typedef typename _Traits::OperationTraits OperationTraits;
221 /// Pointer to the underlying graph.
223 /// Pointer to the length map
224 const LengthMap *length;
225 ///Pointer to the map of predecessors edges.
227 ///Indicates if \ref _pred is locally allocated (\c true) or not.
229 ///Pointer to the map of distances.
231 ///Indicates if \ref _dist is locally allocated (\c true) or not.
234 /// Creates the maps if necessary.
238 _pred = Traits::createPredMap(*graph);
242 _dist = Traits::createDistMap(*graph);
248 typedef BelmannFord Create;
250 /// \name Named template parameters
255 struct DefPredMapTraits : public Traits {
257 static PredMap *createPredMap(const Graph&) {
258 throw UninitializedParameter();
262 /// \brief \ref named-templ-param "Named parameter" for setting PredMap
264 /// \ref named-templ-param "Named parameter" for setting PredMap type
268 typedef BelmannFord< Graph, LengthMap, DefPredMapTraits<T> > Create;
272 struct DefDistMapTraits : public Traits {
274 static DistMap *createDistMap(const Graph& graph) {
275 throw UninitializedParameter();
279 /// \brief \ref named-templ-param "Named parameter" for setting DistMap
282 /// \ref named-templ-param "Named parameter" for setting DistMap type
286 : public BelmannFord< Graph, LengthMap, DefDistMapTraits<T> > {
287 typedef BelmannFord< Graph, LengthMap, DefDistMapTraits<T> > Create;
291 struct DefOperationTraitsTraits : public Traits {
292 typedef T OperationTraits;
295 /// \brief \ref named-templ-param "Named parameter" for setting
296 /// OperationTraits type
298 /// \ref named-templ-param "Named parameter" for setting OperationTraits
301 struct DefOperationTraits
302 : public BelmannFord< Graph, LengthMap, DefOperationTraitsTraits<T> > {
303 typedef BelmannFord< Graph, LengthMap, DefOperationTraitsTraits<T> >
315 /// \brief Constructor.
317 /// \param _graph the graph the algorithm will run on.
318 /// \param _length the length map used by the algorithm.
319 BelmannFord(const Graph& _graph, const LengthMap& _length) :
320 graph(&_graph), length(&_length),
321 _pred(0), local_pred(false),
322 _dist(0), local_dist(false) {}
326 if(local_pred) delete _pred;
327 if(local_dist) delete _dist;
330 /// \brief Sets the length map.
332 /// Sets the length map.
333 /// \return \c (*this)
334 BelmannFord &lengthMap(const LengthMap &m) {
339 /// \brief Sets the map storing the predecessor edges.
341 /// Sets the map storing the predecessor edges.
342 /// If you don't use this function before calling \ref run(),
343 /// it will allocate one. The destuctor deallocates this
344 /// automatically allocated map, of course.
345 /// \return \c (*this)
346 BelmannFord &predMap(PredMap &m) {
355 /// \brief Sets the map storing the distances calculated by the algorithm.
357 /// Sets the map storing the distances calculated by the algorithm.
358 /// If you don't use this function before calling \ref run(),
359 /// it will allocate one. The destuctor deallocates this
360 /// automatically allocated map, of course.
361 /// \return \c (*this)
362 BelmannFord &distMap(DistMap &m) {
371 /// \name Execution control
372 /// The simplest way to execute the algorithm is to use
373 /// one of the member functions called \c run(...).
375 /// If you need more control on the execution,
376 /// first you must call \ref init(), then you can add several source nodes
377 /// with \ref addSource().
378 /// Finally \ref start() will perform the actual path
383 /// \brief Initializes the internal data structures.
385 /// Initializes the internal data structures.
386 void init(const Value value = OperationTraits::infinity()) {
388 for (NodeIt it(*graph); it != INVALID; ++it) {
389 _pred->set(it, INVALID);
390 _dist->set(it, value);
394 /// \brief Adds a new source node.
396 /// The optional second parameter is the initial distance of the node.
397 /// It just sets the distance of the node to the given value.
398 void addSource(Node source, Value dst = OperationTraits::zero()) {
399 _dist->set(source, dst);
402 /// \brief Executes the algorithm.
404 /// \pre init() must be called and at least one node should be added
405 /// with addSource() before using this function.
407 /// This method runs the %BelmannFord algorithm from the root node(s)
408 /// in order to compute the shortest path to each node. The algorithm
410 /// - The shortest path tree.
411 /// - The distance of each node from the root(s).
413 int num = countNodes(*graph) - 1;
414 for (int i = 0; i < num; ++i) {
416 for (EdgeIt it(*graph); it != INVALID; ++it) {
417 Node source = graph->source(it);
418 Node target = graph->target(it);
420 OperationTraits::plus((*_dist)[source], (*length)[it]);
421 if (OperationTraits::less(relaxed, (*_dist)[target])) {
422 _pred->set(target, it);
423 _dist->set(target, relaxed);
431 /// \brief Executes the algorithm and check the negative circles.
433 /// \pre init() must be called and at least one node should be added
434 /// with addSource() before using this function. If there is
435 /// a negative circle in the graph it gives back false.
437 /// This method runs the %BelmannFord algorithm from the root node(s)
438 /// in order to compute the shortest path to each node. The algorithm
440 /// - The shortest path tree.
441 /// - The distance of each node from the root(s).
442 bool checkedStart() {
443 int num = countNodes(*graph);
444 for (int i = 0; i < num; ++i) {
446 for (EdgeIt it(*graph); it != INVALID; ++it) {
447 Node source = graph->source(it);
448 Node target = graph->target(it);
450 OperationTraits::plus((*_dist)[source], (*length)[it]);
451 if (OperationTraits::less(relaxed, (*_dist)[target])) {
452 _pred->set(target, it);
453 _dist->set(target, relaxed);
457 if (ready) return true;
462 /// \brief Runs %BelmannFord algorithm from node \c s.
464 /// This method runs the %BelmannFord algorithm from a root node \c s
465 /// in order to compute the shortest path to each node. The algorithm
467 /// - The shortest path tree.
468 /// - The distance of each node from the root.
470 /// \note d.run(s) is just a shortcut of the following code.
484 /// \name Query Functions
485 /// The result of the %BelmannFord algorithm can be obtained using these
487 /// Before the use of these functions,
488 /// either run() or start() must be called.
492 /// \brief Copies the shortest path to \c t into \c p
494 /// This function copies the shortest path to \c t into \c p.
495 /// If it \c t is a source itself or unreachable, then it does not
497 /// \todo Is it the right way to handle unreachable nodes?
498 /// \return Returns \c true if a path to \c t was actually copied to \c p,
499 /// \c false otherwise.
501 template <typename Path>
502 bool getPath(Path &p, Node t) {
505 typename Path::Builder b(p);
506 for(b.setStartNode(t);pred(t)!=INVALID;t=predNode(t))
507 b.pushFront(pred(t));
514 /// \brief The distance of a node from the root.
516 /// Returns the distance of a node from the root.
517 /// \pre \ref run() must be called before using this function.
518 /// \warning If node \c v in unreachable from the root the return value
519 /// of this funcion is undefined.
520 Value dist(Node v) const { return (*_dist)[v]; }
522 /// \brief Returns the 'previous edge' of the shortest path tree.
524 /// For a node \c v it returns the 'previous edge' of the shortest path
525 /// tree, i.e. it returns the last edge of a shortest path from the root
526 /// to \c v. It is \ref INVALID if \c v is unreachable from the root or
527 /// if \c v=s. The shortest path tree used here is equal to the shortest
528 /// path tree used in \ref predNode().
529 /// \pre \ref run() must be called before using
531 /// \todo predEdge could be a better name.
532 Edge pred(Node v) const { return (*_pred)[v]; }
534 /// \brief Returns the 'previous node' of the shortest path tree.
536 /// For a node \c v it returns the 'previous node' of the shortest path
537 /// tree, i.e. it returns the last but one node from a shortest path from
538 /// the root to \c /v. It is INVALID if \c v is unreachable from the root
539 /// or if \c v=s. The shortest path tree used here is equal to the
540 /// shortest path tree used in \ref pred(). \pre \ref run() must be
541 /// called before using this function.
542 Node predNode(Node v) const {
543 return (*_pred)[v] == INVALID ? INVALID : graph->source((*_pred)[v]);
546 /// \brief Returns a reference to the NodeMap of distances.
548 /// Returns a reference to the NodeMap of distances. \pre \ref run() must
549 /// be called before using this function.
550 const DistMap &distMap() const { return *_dist;}
552 /// \brief Returns a reference to the shortest path tree map.
554 /// Returns a reference to the NodeMap of the edges of the
555 /// shortest path tree.
556 /// \pre \ref run() must be called before using this function.
557 const PredMap &predMap() const { return *_pred; }
559 /// \brief Checks if a node is reachable from the root.
561 /// Returns \c true if \c v is reachable from the root.
562 /// \pre \ref run() must be called before using this function.
564 bool reached(Node v) { return (*_dist)[v] != OperationTraits::infinity(); }
569 /// \brief Default traits class of BelmannFord function.
571 /// Default traits class of BelmannFord function.
572 /// \param _Graph Graph type.
573 /// \param _LengthMap Type of length map.
574 template <typename _Graph, typename _LengthMap>
575 struct BelmannFordWizardDefaultTraits {
576 /// \brief The graph type the algorithm runs on.
577 typedef _Graph Graph;
579 /// \brief The type of the map that stores the edge lengths.
581 /// The type of the map that stores the edge lengths.
582 /// It must meet the \ref concept::ReadMap "ReadMap" concept.
583 typedef _LengthMap LengthMap;
585 /// \brief The value type of the length map.
586 typedef typename _LengthMap::Value Value;
588 /// \brief Operation traits for belmann-ford algorithm.
590 /// It defines the infinity type on the given Value type
591 /// and the used operation.
592 /// \see BelmannFordDefaultOperationTraits
593 typedef BelmannFordDefaultOperationTraits<Value> OperationTraits;
595 /// \brief The type of the map that stores the last
596 /// edges of the shortest paths.
598 /// The type of the map that stores the last
599 /// edges of the shortest paths.
600 /// It must meet the \ref concept::WriteMap "WriteMap" concept.
601 typedef NullMap <typename _Graph::Node,typename _Graph::Edge> PredMap;
603 /// \brief Instantiates a PredMap.
605 /// This function instantiates a \ref PredMap.
606 static PredMap *createPredMap(const _Graph &) {
607 return new PredMap();
609 /// \brief The type of the map that stores the dists of the nodes.
611 /// The type of the map that stores the dists of the nodes.
612 /// It must meet the \ref concept::WriteMap "WriteMap" concept.
613 typedef NullMap<typename Graph::Node, Value> DistMap;
614 /// \brief Instantiates a DistMap.
616 /// This function instantiates a \ref DistMap.
617 static DistMap *createDistMap(const _Graph &) {
618 return new DistMap();
622 /// \brief Default traits used by \ref BelmannFordWizard
624 /// To make it easier to use BelmannFord algorithm
625 /// we have created a wizard class.
626 /// This \ref BelmannFordWizard class needs default traits,
627 /// as well as the \ref BelmannFord class.
628 /// The \ref BelmannFordWizardBase is a class to be the default traits of the
629 /// \ref BelmannFordWizard class.
630 /// \todo More named parameters are required...
631 template<class _Graph,class _LengthMap>
632 class BelmannFordWizardBase
633 : public BelmannFordWizardDefaultTraits<_Graph,_LengthMap> {
635 typedef BelmannFordWizardDefaultTraits<_Graph,_LengthMap> Base;
637 /// Type of the nodes in the graph.
638 typedef typename Base::Graph::Node Node;
640 /// Pointer to the underlying graph.
642 /// Pointer to the length map
644 ///Pointer to the map of predecessors edges.
646 ///Pointer to the map of distances.
648 ///Pointer to the source node.
654 /// This constructor does not require parameters, therefore it initiates
655 /// all of the attributes to default values (0, INVALID).
656 BelmannFordWizardBase() : _graph(0), _length(0), _pred(0),
657 _dist(0), _source(INVALID) {}
661 /// This constructor requires some parameters,
662 /// listed in the parameters list.
663 /// Others are initiated to 0.
664 /// \param graph is the initial value of \ref _graph
665 /// \param length is the initial value of \ref _length
666 /// \param source is the initial value of \ref _source
667 BelmannFordWizardBase(const _Graph& graph,
668 const _LengthMap& length,
669 Node source = INVALID) :
670 _graph((void *)&graph), _length((void *)&length), _pred(0),
671 _dist(0), _source(source) {}
675 /// A class to make the usage of BelmannFord algorithm easier
677 /// This class is created to make it easier to use BelmannFord algorithm.
678 /// It uses the functions and features of the plain \ref BelmannFord,
679 /// but it is much simpler to use it.
681 /// Simplicity means that the way to change the types defined
682 /// in the traits class is based on functions that returns the new class
683 /// and not on templatable built-in classes.
684 /// When using the plain \ref BelmannFord
685 /// the new class with the modified type comes from
686 /// the original class by using the ::
687 /// operator. In the case of \ref BelmannFordWizard only
688 /// a function have to be called and it will
689 /// return the needed class.
691 /// It does not have own \ref run method. When its \ref run method is called
692 /// it initiates a plain \ref BelmannFord class, and calls the \ref
693 /// BelmannFord::run method of it.
694 template<class _Traits>
695 class BelmannFordWizard : public _Traits {
696 typedef _Traits Base;
698 ///The type of the underlying graph.
699 typedef typename _Traits::Graph Graph;
701 typedef typename Graph::Node Node;
702 typedef typename Graph::NodeIt NodeIt;
703 typedef typename Graph::Edge Edge;
704 typedef typename Graph::OutEdgeIt EdgeIt;
706 ///The type of the map that stores the edge lengths.
707 typedef typename _Traits::LengthMap LengthMap;
709 ///The type of the length of the edges.
710 typedef typename LengthMap::Value Value;
712 ///\brief The type of the map that stores the last
713 ///edges of the shortest paths.
714 typedef typename _Traits::PredMap PredMap;
716 ///The type of the map that stores the dists of the nodes.
717 typedef typename _Traits::DistMap DistMap;
721 BelmannFordWizard() : _Traits() {}
723 /// \brief Constructor that requires parameters.
725 /// Constructor that requires parameters.
726 /// These parameters will be the default values for the traits class.
727 BelmannFordWizard(const Graph& graph, const LengthMap& length,
728 Node source = INVALID)
729 : _Traits(graph, length, source) {}
731 /// \brief Copy constructor
732 BelmannFordWizard(const _Traits &b) : _Traits(b) {}
734 ~BelmannFordWizard() {}
736 /// \brief Runs BelmannFord algorithm from a given node.
738 /// Runs BelmannFord algorithm from a given node.
739 /// The node can be given by the \ref source function.
741 if(Base::_source == INVALID) throw UninitializedParameter();
742 BelmannFord<Graph,LengthMap,_Traits>
743 bf(*(Graph*)Base::_graph, *(LengthMap*)Base::_length);
744 if (Base::_pred) bf.predMap(*(PredMap*)Base::_pred);
745 if (Base::_dist) bf.distMap(*(DistMap*)Base::_dist);
746 bf.run(Base::_source);
749 /// \brief Runs BelmannFord algorithm from the given node.
751 /// Runs BelmannFord algorithm from the given node.
752 /// \param s is the given source.
753 void run(Node source) {
754 Base::_source = source;
759 struct DefPredMapBase : public Base {
761 static PredMap *createPredMap(const Graph &) { return 0; };
762 DefPredMapBase(const _Traits &b) : _Traits(b) {}
765 ///\brief \ref named-templ-param "Named parameter"
766 ///function for setting PredMap type
768 /// \ref named-templ-param "Named parameter"
769 ///function for setting PredMap type
772 BelmannFordWizard<DefPredMapBase<T> > predMap(const T &t)
774 Base::_pred=(void *)&t;
775 return BelmannFordWizard<DefPredMapBase<T> >(*this);
779 struct DefDistMapBase : public Base {
781 static DistMap *createDistMap(const Graph &) { return 0; };
782 DefDistMapBase(const _Traits &b) : _Traits(b) {}
785 ///\brief \ref named-templ-param "Named parameter"
786 ///function for setting DistMap type
788 /// \ref named-templ-param "Named parameter"
789 ///function for setting DistMap type
792 BelmannFordWizard<DefDistMapBase<T> > distMap(const T &t) {
793 Base::_dist=(void *)&t;
794 return BelmannFordWizard<DefDistMapBase<T> >(*this);
798 struct DefOperationTraitsBase : public Base {
799 typedef T OperationTraits;
800 DefOperationTraitsBase(const _Traits &b) : _Traits(b) {}
803 ///\brief \ref named-templ-param "Named parameter"
804 ///function for setting OperationTraits type
806 /// \ref named-templ-param "Named parameter"
807 ///function for setting OperationTraits type
810 BelmannFordWizard<DefOperationTraitsBase<T> > distMap() {
811 return BelmannFordWizard<DefDistMapBase<T> >(*this);
814 /// \brief Sets the source node, from which the BelmannFord algorithm runs.
816 /// Sets the source node, from which the BelmannFord algorithm runs.
817 /// \param s is the source node.
818 BelmannFordWizard<_Traits>& source(Node source) {
819 Base::_source = source;
825 /// \brief Function type interface for BelmannFord algorithm.
827 /// \ingroup flowalgs
828 /// Function type interface for BelmannFord algorithm.
830 /// This function also has several \ref named-templ-func-param
831 /// "named parameters", they are declared as the members of class
832 /// \ref BelmannFordWizard.
834 /// example shows how to use these parameters.
836 /// belmannford(g,length,source).predMap(preds).run();
838 /// \warning Don't forget to put the \ref BelmannFordWizard::run() "run()"
839 /// to the end of the parameter list.
840 /// \sa BelmannFordWizard
842 template<class _Graph, class _LengthMap>
843 BelmannFordWizard<BelmannFordWizardBase<_Graph,_LengthMap> >
844 belmannFord(const _Graph& graph,
845 const _LengthMap& length,
846 typename _Graph::Node source = INVALID) {
847 return BelmannFordWizard<BelmannFordWizardBase<_Graph,_LengthMap> >
848 (graph, length, source);
851 } //END OF NAMESPACE LEMON