[Lemon-commits] [lemon_svn] alpar: r944 - hugo/trunk/src/hugo
Lemon SVN
svn at lemon.cs.elte.hu
Mon Nov 6 20:42:21 CET 2006
Author: alpar
Date: Tue Jul 6 12:07:48 2004
New Revision: 944
Modified:
hugo/trunk/src/hugo/dijkstra.h
Log:
I moved run() into the body of class Dijkstra, because Doxygen handles
external member function definitions very poorly.
Modified: hugo/trunk/src/hugo/dijkstra.h
==============================================================================
--- hugo/trunk/src/hugo/dijkstra.h (original)
+++ hugo/trunk/src/hugo/dijkstra.h Tue Jul 6 12:07:48 2004
@@ -84,7 +84,7 @@
///Initialize maps
- ///\todo Error if \c G or are \c NULL. What about \c length
+ ///\todo Error if \c G or are \c NULL. What about \c length?
///\todo Better memory allocation (instead of new).
void init_maps()
{
@@ -196,7 +196,64 @@
return *this;
}
- void run(Node s);
+ ///Runs %Dijkstra algorithm from node \c s.
+
+ ///This method runs the %Dijkstra algorithm from a root node \c s
+ ///in order to
+ ///compute the
+ ///shortest path to each node. The algorithm computes
+ ///- The shortest path tree.
+ ///- The distance of each node from the root.
+
+ void run(Node s) {
+
+ init_maps();
+
+ for ( NodeIt u(*G) ; G->valid(u) ; G->next(u) ) {
+ predecessor->set(u,INVALID);
+ pred_node->set(u,INVALID);
+ }
+
+ typename GR::template NodeMap<int> heap_map(*G,-1);
+
+ typedef Heap<Node, ValueType, typename GR::template NodeMap<int>,
+ std::less<ValueType> >
+ HeapType;
+
+ HeapType heap(heap_map);
+
+ heap.push(s,0);
+
+ while ( !heap.empty() ) {
+
+ Node v=heap.top();
+ ValueType oldvalue=heap[v];
+ heap.pop();
+ distance->set(v, oldvalue);
+
+
+ for(OutEdgeIt e(*G,v); G->valid(e); G->next(e)) {
+ Node w=G->bNode(e);
+
+ switch(heap.state(w)) {
+ case HeapType::PRE_HEAP:
+ heap.push(w,oldvalue+(*length)[e]);
+ predecessor->set(w,e);
+ pred_node->set(w,v);
+ break;
+ case HeapType::IN_HEAP:
+ if ( oldvalue+(*length)[e] < heap[w] ) {
+ heap.decrease(w, oldvalue+(*length)[e]);
+ predecessor->set(w,e);
+ pred_node->set(w,v);
+ }
+ break;
+ case HeapType::POST_HEAP:
+ break;
+ }
+ }
+ }
+ }
///The distance of a node from the root.
@@ -263,66 +320,6 @@
// IMPLEMENTATIONS
// **********************************************************************
- ///Runs %Dijkstra algorithm from node the root.
-
- ///This method runs the %Dijkstra algorithm from a root node \c s
- ///in order to
- ///compute the
- ///shortest path to each node. The algorithm computes
- ///- The shortest path tree.
- ///- The distance of each node from the root.
- template <typename GR, typename LM,
- template<class,class,class,class> class Heap >
- void Dijkstra<GR,LM,Heap>::run(Node s) {
-
- init_maps();
-
- for ( NodeIt u(*G) ; G->valid(u) ; G->next(u) ) {
- predecessor->set(u,INVALID);
- pred_node->set(u,INVALID);
- }
-
- typename GR::template NodeMap<int> heap_map(*G,-1);
-
- typedef Heap<Node, ValueType, typename GR::template NodeMap<int>,
- std::less<ValueType> >
- HeapType;
-
- HeapType heap(heap_map);
-
- heap.push(s,0);
-
- while ( !heap.empty() ) {
-
- Node v=heap.top();
- ValueType oldvalue=heap[v];
- heap.pop();
- distance->set(v, oldvalue);
-
-
- for(OutEdgeIt e(*G,v); G->valid(e); G->next(e)) {
- Node w=G->bNode(e);
-
- switch(heap.state(w)) {
- case HeapType::PRE_HEAP:
- heap.push(w,oldvalue+(*length)[e]);
- predecessor->set(w,e);
- pred_node->set(w,v);
- break;
- case HeapType::IN_HEAP:
- if ( oldvalue+(*length)[e] < heap[w] ) {
- heap.decrease(w, oldvalue+(*length)[e]);
- predecessor->set(w,e);
- pred_node->set(w,v);
- }
- break;
- case HeapType::POST_HEAP:
- break;
- }
- }
- }
- }
-
/// @}
} //END OF NAMESPACE HUGO
More information about the Lemon-commits
mailing list