Home | Documentation | Download | Platforms | Projects | Mailing Lists | Version History

- Main Page
- Classes
- Files
- Related Pages

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# bid_dijkstra Class Reference

Dijkstra's Algorithm for computing a shortest path from a single source to a single target. More...

Inheritance diagram for bid_dijkstra:

[legend]
Collaboration diagram for bid_dijkstra:

[legend]

List of all members.

## Public Types

typedef list< node > ::const_iterator | shortest_path_node_iterator
| Iterator type for traversing nodes on one shortest path.
typedef list< edge > ::const_iterator | shortest_path_edge_iterator
| Iterator type for traversing edges on one shortest path.

## Public Member Functions

| bid_dijkstra ()
| Default constructor.
virtual | ~bid_dijkstra ()
| Destructor.
void | source_target (const node &s, const node &t)
| Sets source and target node.
void | weights (const edge_map< double > &weight)
| Sets weights of the edges.
void | store_path (bool set)
| Enables or disables the storing of the shortest path.
virtual int | check (graph &G)
| Checks whether the preconditions for bidirectional Dijkstra are satisfied.
int | run (graph &G)
| Runs shortest path algorithm on `G`.
node | source () const
| Returns source node.
node | target () const
| Returns target node if set, `node::node()` else.
bool | store_path () const
| Returns whether the storing of the shortest path is enabled.
bool | reached () const
| Returns whether target is reachable from source.
double | distance () const
| Returns the distance from source node to target node.
shortest_path_node_iterator | shortest_path_nodes_begin ()
| Returns an iterator to the beginning (to the source node) of the shortest node path to target node.
shortest_path_node_iterator | shortest_path_nodes_end ()
| Returns an iterator one after the end (one after target node) of the shortest node path to target node.
shortest_path_edge_iterator | shortest_path_edges_begin ()
| Returns an iterator to the beginning edge of the shortest edge path to target node.
shortest_path_edge_iterator | shortest_path_edges_end ()
| Returns an iterator one after the end of a shortest edge path to target node.
virtual void | reset ()
| Resets Dijkstra's bidirectional algorithm.

## Detailed Description

Dijkstra's Algorithm for computing a shortest path from a single source to a single target.

Date

Revision

This class implements Dijkstra's algorithm in a bidirectional manner for computing a shortest path from a single source to a single target in worst case.

See also:
  dijkstra

  bellman_ford

Author:
  Christian Bachmaier chris@infosun.fmi.uni-passau.de

## Constructor & Destructor Documentation

bid_dijkstra::bid_dijkstra | ( |  | ) |

Default constructor.

Enables only the calculation of shortest paths.

See also:
  algorithm::algorithm

virtual bid_dijkstra::~bid_dijkstra | ( |  | ) | `[virtual]`

Destructor.

See also:
  algorithm::~algorithm

## Member Function Documentation

void bid_dijkstra::source_target | ( | const node & | s,
|  | const node & | t |
| ) |  |  |

Sets source and target node.

Must be executed every time before check and run of this algorithm.

Parameters:

  | s | source node
  | t | target node

void bid_dijkstra::weights | ( | const edge_map< double > & | weight | ) |

Sets weights of the edges.

This method must be called before check and run.

Parameters:

  | weight | weights of the edges

void bid_dijkstra::store_path | ( | bool | set | ) |

Enables or disables the storing of the shortest path.

If enabled for every node and edge on the shortest path from source to target will be stored.

Parameters:

  | set | true if path should be stored

See also:
  dijkstra::predecessor_node

  dijkstra::predecessor_edge

virtual int bid_dijkstra::check | ( | graph & | G | ) | `[virtual]`

Checks whether the preconditions for bidirectional Dijkstra are satisfied.

The Precondition are that the weights of the edges have been set and that the graph has at least one node. Additionally all edge weights must be and and source and target nodes must be found in `G`.

Parameters:

  | G | graph

Return values:

  | algorithm::GTL_OK | if algorithm can be applied
  | algorithm::GTL_ERROR | otherwise

See also:
  dijkstra::source

  dijkstra::weigths

  algorithm::check

Implements algorithm.

int bid_dijkstra::run | ( | graph & | G | ) | `[virtual]`

Runs shortest path algorithm on `G`.

This should return always algorithm::GTL_OK. The return value only tracks errors that might occur. Afterwards the result of the test can be accessed via access methods.

Parameters:

  | G | graph

Return values:

  | algorithm::GTL_OK | on success
  | algorithm::GTL_ERROR | otherwise

See also:
  algorithm::run

Implements algorithm.

node bid_dijkstra::source | ( |  | ) | const

Returns source node.

Returns:
  source node

node bid_dijkstra::target | ( |  | ) | const

Returns target node if set, `node::node()` else.

Returns:
  target node

bool bid_dijkstra::store_path | ( |  | ) | const

Returns whether the storing of the shortest path is enabled.

Returns:
  `true` iff the storing of path is enabled.

See also:
  dijkstra::predecessor

bool bid_dijkstra::reached | ( |  | ) | const

Returns whether target is reachable from source.

Returns:
  `true` iff target was reached from source

double bid_dijkstra::distance | ( |  | ) | const

Returns the distance from source node to target node.

Returns:
  distance if target is bid_dijkstra::reached, `-1.0` else

shortest_path_node_iterator bid_dijkstra::shortest_path_nodes_begin | ( |  | ) |

Returns an iterator to the beginning (to the source node) of the shortest node path to target node.

Returns:
  beginning node iterator of the shortest path

See also:
  bid_dijkstra::store_path

Note:
  The method requires that path calculation option was enabled during last run.

shortest_path_node_iterator bid_dijkstra::shortest_path_nodes_end | ( |  | ) |

Returns an iterator one after the end (one after target node) of the shortest node path to target node.

Returns:
  shortest path end node iterator

See also:
  bid_dijkstra::store_path

Note:
  The method requires that path calculation option was enabled during last run.

shortest_path_edge_iterator bid_dijkstra::shortest_path_edges_begin | ( |  | ) |

Returns an iterator to the beginning edge of the shortest edge path to target node.

See also:
  bid_dijkstra::store_path

Returns:
  beginning edge iterator of the shortest path

Note:
  The method requires that path calculation option was enabled during last run.

shortest_path_edge_iterator bid_dijkstra::shortest_path_edges_end | ( |  | ) |

Returns an iterator one after the end of a shortest edge path to target node.

See also:
  bid_dijkstra::store_path

Returns:
  shortest path end edge iterator

Note:
  The method requires that predecessor calculation option was enabled during last run.

virtual void bid_dijkstra::reset | ( |  | ) | `[virtual]`

Resets Dijkstra's bidirectional algorithm.

It prepares the algorithm to be applied again, possibly to another graph.

Note:
  The weights are not reset. You can apply this algorithms

See also:
  algorithm::reset

Implements algorithm.

University of Passau - FMI - Theoretical Computer Science

Design © 2002, 2003 Marcus Raitner, University of Passau