lemon/dfs.h
changeset 1981 81c8efe92706
parent 1956 a055123339d5
child 1993 2115143eceea
     1.1 --- a/lemon/dfs.h	Thu Feb 23 08:55:54 2006 +0000
     1.2 +++ b/lemon/dfs.h	Thu Feb 23 09:03:18 2006 +0000
     1.3 @@ -573,6 +573,34 @@
     1.4        while ( !emptyQueue() && !em[_stack[_stack_head]] ) processNextEdge();
     1.5      }
     1.6  
     1.7 +    ///Runs %DFS algorithm to visit all nodes in the graph.
     1.8 +    
     1.9 +    ///This method runs the %DFS algorithm in order to
    1.10 +    ///compute the
    1.11 +    ///%DFS path to each node. The algorithm computes
    1.12 +    ///- The %DFS tree.
    1.13 +    ///- The distance of each node from the root in the %DFS tree.
    1.14 +    ///
    1.15 +    ///\note d.run() is just a shortcut of the following code.
    1.16 +    ///\code
    1.17 +    ///  d.init();
    1.18 +    ///  for (NodeIt it(graph); it != INVALID; ++it) {
    1.19 +    ///    if (!d.reached(it)) {
    1.20 +    ///      d.addSource(it);
    1.21 +    ///      d.start();
    1.22 +    ///    }
    1.23 +    ///  }
    1.24 +    ///\endcode
    1.25 +    void run() {
    1.26 +      init();
    1.27 +      for (NodeIt it(*G); it != INVALID; ++it) {
    1.28 +        if (!reached(it)) {
    1.29 +          addSource(it);
    1.30 +          start();
    1.31 +        }
    1.32 +      }
    1.33 +    }
    1.34 +
    1.35      ///Runs %DFS algorithm from node \c s.
    1.36      
    1.37      ///This method runs the %DFS algorithm from a root node \c s
    1.38 @@ -651,8 +679,8 @@
    1.39  
    1.40      ///Returns the distance of a node from the root(s).
    1.41      ///\pre \ref run() must be called before using this function.
    1.42 -    ///\warning If node \c v is unreachable from the root(s) then the return value
    1.43 -    ///of this funcion is undefined.
    1.44 +    ///\warning If node \c v is unreachable from the root(s) then the return 
    1.45 +    ///value of this funcion is undefined.
    1.46      int dist(Node v) const { return (*_dist)[v]; }
    1.47  
    1.48      ///Returns the 'previous edge' of the %DFS tree.
    1.49 @@ -1440,7 +1468,7 @@
    1.50        while (!emptyQueue() && !em[_stack[_stack_head]]) processNextEdge();
    1.51      }
    1.52  
    1.53 -    /// \brief Runs %DFS algorithm from node \c s.
    1.54 +    /// \brief Runs %DFSVisit algorithm from node \c s.
    1.55      ///
    1.56      /// This method runs the %DFS algorithm from a root node \c s.
    1.57      /// \note d.run(s) is just a shortcut of the following code.
    1.58 @@ -1454,6 +1482,33 @@
    1.59        addSource(s);
    1.60        start();
    1.61      }
    1.62 +
    1.63 +    /// \brief Runs %DFSVisit algorithm to visit all nodes in the graph.
    1.64 +    
    1.65 +    /// This method runs the %DFS algorithm in order to
    1.66 +    /// compute the %DFS path to each node. The algorithm computes
    1.67 +    /// - The %DFS tree.
    1.68 +    /// - The distance of each node from the root in the %DFS tree.
    1.69 +    ///
    1.70 +    ///\note d.run() is just a shortcut of the following code.
    1.71 +    ///\code
    1.72 +    ///  d.init();
    1.73 +    ///  for (NodeIt it(graph); it != INVALID; ++it) {
    1.74 +    ///    if (!d.reached(it)) {
    1.75 +    ///      d.addSource(it);
    1.76 +    ///      d.start();
    1.77 +    ///    }
    1.78 +    ///  }
    1.79 +    ///\endcode
    1.80 +    void run() {
    1.81 +      init();
    1.82 +      for (NodeIt it(*_graph); it != INVALID; ++it) {
    1.83 +        if (!reached(it)) {
    1.84 +          addSource(it);
    1.85 +          start();
    1.86 +        }
    1.87 +      }
    1.88 +    }
    1.89      ///@}
    1.90  
    1.91      /// \name Query Functions