#include <bfs.h>
GR | The graph type the algorithm runs on. This class does the same as Dijkstra does with constant 1 edge length, but it is faster. |
Definition at line 48 of file bfs.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 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< int > | DistMap |
The type of the map that stores the dists of the nodes. | |
Public Member Functions | |
Bfs (const Graph &_G) | |
Constructor. | |
~Bfs () | |
Destructor. | |
Bfs & | setPredMap (PredMap &m) |
Sets the map storing the predecessor edges. | |
Bfs & | setPredNodeMap (PredNodeMap &m) |
Sets the map storing the predecessor nodes. | |
Bfs & | setDistMap (DistMap &m) |
Sets the map storing the distances calculated by the algorithm. | |
void | run (Node s) |
Runs BFS algorithm from node s . | |
int | dist (Node v) const |
The distance of a node from the root. | |
Edge | pred (Node v) const |
Returns the 'previous edge' of the BFS path tree. | |
Node | predNode (Node v) const |
Returns the 'previous node' of the BFS tree. | |
const DistMap & | distMap () const |
Returns a reference to the NodeMap of distances. | |
const PredMap & | predMap () const |
Returns a reference to the BFS tree map. | |
const PredNodeMap & | predNodeMap () const |
Returns a reference to the map of last but one nodes of shortest paths. | |
bool | reached (Node v) |
Checks if a node is reachable from the root. |
|
References Bfs::Graph. |
|
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 Bfs::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 Bfs::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 Bfs::DistMap. |
|
This method runs the BFS algorithm from a root node
References lemon::INVALID, Bfs::Node, Bfs::NodeIt, and Bfs::OutEdgeIt. |
|
Returns the distance of a node from the root.
References Bfs::Node. |
|
For a node
|
|
For a node
References Bfs::Node. |
|
Returns a reference to the NodeMap of distances.
References Bfs::DistMap. |
|
Returns a reference to the NodeMap of the edges of the BFS tree.
References Bfs::PredMap. |
|
Returns a reference to the NodeMap of the last but one nodes on the BFS tree.
References Bfs::PredNodeMap. |
|
Returns
References lemon::INVALID, and Bfs::Node. |