#include <dijkstra.h>
The type of the length is determined by the ValueType of the length map.
It is also possible to change the underlying priority heap.
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. |
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. | |
Dijkstra & | setLengthMap (const LM &m) |
Sets the length map. | |
Dijkstra & | setPredMap (PredMap &m) |
Sets the map storing the predecessor edges. | |
Dijkstra & | setPredNodeMap (PredNodeMap &m) |
Sets the map storing the predecessor nodes. | |
Dijkstra & | setDistMap (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 DistMap & | distMap () const |
Returns a reference to the NodeMap of distances. | |
const PredMap & | predMap () const |
Returns a reference to the shortest path tree map. | |
const PredNodeMap & | predNodeMap () 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. |
|
References Dijkstra::Graph. |
|
Sets the length map.
|
|
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.
References Dijkstra::PredMap. |
|
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.
References Dijkstra::PredNodeMap. |
|
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.
References Dijkstra::DistMap. |
|
This method runs the Dijkstra algorithm from a root node
References lemon::INVALID, Dijkstra::Node, Dijkstra::NodeIt, Dijkstra::OutEdgeIt, and Dijkstra::ValueType. |
|
Returns the distance of a node from the root.
References Dijkstra::Node, and Dijkstra::ValueType. |
|
For a node
References Dijkstra::Edge, and Dijkstra::Node. |
|
For a node
References Dijkstra::Node. |
|
Returns a reference to the NodeMap of distances.
References Dijkstra::DistMap. |
|
Returns a reference to the NodeMap of the edges of the shortest path tree.
References Dijkstra::PredMap. |
|
Returns a reference to the NodeMap of the last but one nodes of the shortest path tree.
References Dijkstra::PredNodeMap. |
|
Returns
References lemon::INVALID, and Dijkstra::Node. |