diff -r a954b780e3ab -r 81c8efe92706 lemon/dfs.h --- a/lemon/dfs.h Thu Feb 23 08:55:54 2006 +0000 +++ b/lemon/dfs.h Thu Feb 23 09:03:18 2006 +0000 @@ -573,6 +573,34 @@ while ( !emptyQueue() && !em[_stack[_stack_head]] ) processNextEdge(); } + ///Runs %DFS algorithm to visit all nodes in the graph. + + ///This method runs the %DFS algorithm in order to + ///compute the + ///%DFS path to each node. The algorithm computes + ///- The %DFS tree. + ///- The distance of each node from the root in the %DFS tree. + /// + ///\note d.run() is just a shortcut of the following code. + ///\code + /// d.init(); + /// for (NodeIt it(graph); it != INVALID; ++it) { + /// if (!d.reached(it)) { + /// d.addSource(it); + /// d.start(); + /// } + /// } + ///\endcode + void run() { + init(); + for (NodeIt it(*G); it != INVALID; ++it) { + if (!reached(it)) { + addSource(it); + start(); + } + } + } + ///Runs %DFS algorithm from node \c s. ///This method runs the %DFS algorithm from a root node \c s @@ -651,8 +679,8 @@ ///Returns the distance of a node from the root(s). ///\pre \ref run() must be called before using this function. - ///\warning If node \c v is unreachable from the root(s) then the return value - ///of this funcion is undefined. + ///\warning If node \c v is unreachable from the root(s) then the return + ///value of this funcion is undefined. int dist(Node v) const { return (*_dist)[v]; } ///Returns the 'previous edge' of the %DFS tree. @@ -1440,7 +1468,7 @@ while (!emptyQueue() && !em[_stack[_stack_head]]) processNextEdge(); } - /// \brief Runs %DFS algorithm from node \c s. + /// \brief Runs %DFSVisit algorithm from node \c s. /// /// This method runs the %DFS algorithm from a root node \c s. /// \note d.run(s) is just a shortcut of the following code. @@ -1454,6 +1482,33 @@ addSource(s); start(); } + + /// \brief Runs %DFSVisit algorithm to visit all nodes in the graph. + + /// This method runs the %DFS algorithm in order to + /// compute the %DFS path to each node. The algorithm computes + /// - The %DFS tree. + /// - The distance of each node from the root in the %DFS tree. + /// + ///\note d.run() is just a shortcut of the following code. + ///\code + /// d.init(); + /// for (NodeIt it(graph); it != INVALID; ++it) { + /// if (!d.reached(it)) { + /// d.addSource(it); + /// d.start(); + /// } + /// } + ///\endcode + void run() { + init(); + for (NodeIt it(*_graph); it != INVALID; ++it) { + if (!reached(it)) { + addSource(it); + start(); + } + } + } ///@} /// \name Query Functions