Dijkstra Class Template Reference
[Path and Flow Algorithms]

#include <dijkstra.h>

List of all members.


Detailed Description

template<typename GR, typename LM, typename Heap>
class lemon::Dijkstra< GR, LM, Heap >

This class provides an efficient implementation of Dijkstra algorithm. The edge lengths are passed to the algorithm using a ReadMap, so it is easy to change it to any kind of length.

The type of the length is determined by the ValueType of the length map.

It is also possible to change the underlying priority heap.

Parameters:
GR The graph type the algorithm runs on.
LM This read-only EdgeMap determines the lengths of the edges. It is read once for each edge, so the map may involve in relatively time consuming process to compute the edge length if it is necessary. The default map type is Graph::EdgeMap<int>
Heap The heap type used by the Dijkstra algorithm. The default is using binary heap.
Author:
Jacint Szabo and Alpar Juttner
Todo:
We need a typedef-names should be standardized. (-:

Type of PredMap, PredNodeMap and DistMap should not be fixed. (Problematic to solve).

Definition at line 70 of file dijkstra.h.

Public Types

typedef GR Graph
 The type of the underlying graph.
typedef Graph::Node Node
 
typedef Graph::NodeIt NodeIt
 
typedef Graph::Edge Edge
 
typedef Graph::OutEdgeIt OutEdgeIt
 
typedef LM::ValueType ValueType
 The type of the length of the edges.
typedef LM LengthMap
 The type of the map that stores the edge lengths.
typedef Graph::template NodeMap<
Edge
PredMap
 The type of the map that stores the last edges of the shortest paths.
typedef Graph::template NodeMap<
Node
PredNodeMap
 The type of the map that stores the last but one nodes of the shortest paths.
typedef Graph::template NodeMap<
ValueType
DistMap
 The type of the map that stores the dists of the nodes.

Public Member Functions

 Dijkstra (const Graph &_G, const LM &_length)
 Constructor.
 ~Dijkstra ()
 Destructor.
DijkstrasetLengthMap (const LM &m)
 Sets the length map.
DijkstrasetPredMap (PredMap &m)
 Sets the map storing the predecessor edges.
DijkstrasetPredNodeMap (PredNodeMap &m)
 Sets the map storing the predecessor nodes.
DijkstrasetDistMap (DistMap &m)
 Sets the map storing the distances calculated by the algorithm.
void run (Node s)
 Runs Dijkstra algorithm from node s.
ValueType dist (Node v) const
 The distance of a node from the root.
Edge pred (Node v) const
 Returns the 'previous edge' of the shortest path tree.
Node predNode (Node v) const
 Returns the 'previous node' of the shortest path tree.
const DistMapdistMap () const
 Returns a reference to the NodeMap of distances.
const PredMappredMap () const
 Returns a reference to the shortest path tree map.
const PredNodeMappredNodeMap () const
 Returns a reference to the map of nodes of shortest paths.
bool reached (Node v)
 Checks if a node is reachable from the root.


Constructor & Destructor Documentation

Dijkstra const Graph _G,
const LM &  _length
[inline]
 

Parameters:
_G the graph the algorithm will run on.
_length the length map used by the algorithm.
Definition at line 142 of file dijkstra.h.

References Dijkstra::Graph.


Member Function Documentation

Dijkstra& setLengthMap const LM &  m  )  [inline]
 

Sets the length map.

Returns:
(*this)
Definition at line 161 of file dijkstra.h.

Dijkstra& setPredMap PredMap m  )  [inline]
 

Sets the map storing the predecessor edges. If you don't use this function before calling run(), it will allocate one. The destuctor deallocates this automatically allocated map, of course.

Returns:
(*this)
Definition at line 174 of file dijkstra.h.

References Dijkstra::PredMap.

Dijkstra& setPredNodeMap PredNodeMap m  )  [inline]
 

Sets the map storing the predecessor nodes. If you don't use this function before calling run(), it will allocate one. The destuctor deallocates this automatically allocated map, of course.

Returns:
(*this)
Definition at line 191 of file dijkstra.h.

References Dijkstra::PredNodeMap.

Dijkstra& setDistMap DistMap m  )  [inline]
 

Sets the map storing the distances calculated by the algorithm. If you don't use this function before calling run(), it will allocate one. The destuctor deallocates this automatically allocated map, of course.

Returns:
(*this)
Definition at line 208 of file dijkstra.h.

References Dijkstra::DistMap.

void run Node  s  )  [inline]
 

This method runs the Dijkstra algorithm from a root node 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.
Definition at line 227 of file dijkstra.h.

References lemon::INVALID, Dijkstra::Node, Dijkstra::NodeIt, Dijkstra::OutEdgeIt, and Dijkstra::ValueType.

ValueType dist Node  v  )  const [inline]
 

Returns the distance of a node from the root.

Precondition:
run() must be called before using this function.
Warning:
If node v in unreachable from the root the return value of this funcion is undefined.
Definition at line 284 of file dijkstra.h.

References Dijkstra::Node, and Dijkstra::ValueType.

Edge pred Node  v  )  const [inline]
 

For a node v it returns the 'previous edge' of the shortest path tree, i.e. it returns the last edge of a shortest path from the root to v. It is INVALID if v is unreachable from the root or if v=s. The shortest path tree used here is equal to the shortest path tree used in predNode(Node v).

Precondition:
run() must be called before using this function.
Todo:
predEdge could be a better name.
Definition at line 296 of file dijkstra.h.

References Dijkstra::Edge, and Dijkstra::Node.

Node predNode Node  v  )  const [inline]
 

For a node v it returns the 'previous node' of the shortest path tree, i.e. it returns the last but one node from a shortest path from the root to /v. It is INVALID if v is unreachable from the root or if v=s. The shortest path tree used here is equal to the shortest path tree used in pred(Node v).

Precondition:
run() must be called before using this function.
Definition at line 306 of file dijkstra.h.

References Dijkstra::Node.

const DistMap& distMap  )  const [inline]
 

Returns a reference to the NodeMap of distances.

Precondition:
run() must be called before using this function.
Definition at line 312 of file dijkstra.h.

References Dijkstra::DistMap.

const PredMap& predMap  )  const [inline]
 

Returns a reference to the NodeMap of the edges of the shortest path tree.

Precondition:
run() must be called before using this function.
Definition at line 319 of file dijkstra.h.

References Dijkstra::PredMap.

const PredNodeMap& predNodeMap  )  const [inline]
 

Returns a reference to the NodeMap of the last but one nodes of the shortest path tree.

Precondition:
run() must be called before using this function.
Definition at line 326 of file dijkstra.h.

References Dijkstra::PredNodeMap.

bool reached Node  v  )  [inline]
 

Returns true if v is reachable from the root.

Note:
The root node is reported to be reached!
Precondition:
run() must be called before using this function.
Definition at line 334 of file dijkstra.h.

References lemon::INVALID, and Dijkstra::Node.


The documentation for this class was generated from the following file:
Generated on Thu Sep 30 12:18:36 2004 for LEMON by doxygen 1.3.8