lemon/dfs.h
changeset 1770 657de7e5043c
parent 1763 49045f2d28d4
child 1773 ea5927cef15c
equal deleted inserted replaced
17:3a1dfbbe6de7 18:963b4b6620bf
   190     std::vector<typename Graph::OutEdgeIt> _stack;
   190     std::vector<typename Graph::OutEdgeIt> _stack;
   191     int _stack_head;
   191     int _stack_head;
   192 
   192 
   193     ///Creates the maps if necessary.
   193     ///Creates the maps if necessary.
   194     
   194     
   195     ///\todo Error if \c G are \c NULL.
       
   196     ///\todo Better memory allocation (instead of new).
   195     ///\todo Better memory allocation (instead of new).
   197     void create_maps() 
   196     void create_maps() 
   198     {
   197     {
   199       if(!_pred) {
   198       if(!_pred) {
   200 	local_pred = true;
   199 	local_pred = true;
   506     ///\brief Returns \c false if there are nodes
   505     ///\brief Returns \c false if there are nodes
   507     ///to be processed in the queue
   506     ///to be processed in the queue
   508     ///
   507     ///
   509     ///Returns \c false if there are nodes
   508     ///Returns \c false if there are nodes
   510     ///to be processed in the queue
   509     ///to be processed in the queue
   511     ///
       
   512     ///\todo This should be called emptyStack() or some "neutral" name.
       
   513     bool emptyQueue() { return _stack_head<0; }
   510     bool emptyQueue() { return _stack_head<0; }
   514     ///Returns the number of the nodes to be processed.
   511     ///Returns the number of the nodes to be processed.
   515     
   512     
   516     ///Returns the number of the nodes to be processed in the queue.
   513     ///Returns the number of the nodes to be processed in the queue.
   517     ///
       
   518     ///\todo This should be called stackSize() or some "neutral" name.
       
   519     int queueSize() { return _stack_head+1; }
   514     int queueSize() { return _stack_head+1; }
   520     
   515     
   521     ///Executes the algorithm.
   516     ///Executes the algorithm.
   522 
   517 
   523     ///Executes the algorithm.
   518     ///Executes the algorithm.
   629     ///Copies the path to \c t on the DFS tree into \c p
   624     ///Copies the path to \c t on the DFS tree into \c p
   630     
   625     
   631     ///This function copies the path to \c t on the DFS tree  into \c p.
   626     ///This function copies the path to \c t on the DFS tree  into \c p.
   632     ///If \c t is a source itself or unreachable, then it does not
   627     ///If \c t is a source itself or unreachable, then it does not
   633     ///alter \c p.
   628     ///alter \c p.
   634     ///\todo Is this the right way to handle unreachable nodes?
       
   635     ///
   629     ///
   636     ///\return Returns \c true if a path to \c t was actually copied to \c p,
   630     ///\return Returns \c true if a path to \c t was actually copied to \c p,
   637     ///\c false otherwise.
   631     ///\c false otherwise.
   638     ///\sa DirPath
   632     ///\sa DirPath
   639     template<class P>
   633     template<class P>
   667     ///if \c v is unreachable from the root(s) or \c v is a root. The
   661     ///if \c v is unreachable from the root(s) or \c v is a root. The
   668     ///%DFS tree used here is equal to the %DFS tree used in
   662     ///%DFS tree used here is equal to the %DFS tree used in
   669     ///\ref predNode().
   663     ///\ref predNode().
   670     ///\pre Either \ref run() or \ref start() must be called before using
   664     ///\pre Either \ref run() or \ref start() must be called before using
   671     ///this function.
   665     ///this function.
   672     ///\todo predEdge could be a better name.
       
   673     Edge predEdge(Node v) const { return (*_pred)[v];}
   666     Edge predEdge(Node v) const { return (*_pred)[v];}
   674 
   667 
   675     ///Returns the 'previous node' of the %DFS tree.
   668     ///Returns the 'previous node' of the %DFS tree.
   676 
   669 
   677     ///For a node \c v it returns the 'previous node'
   670     ///For a node \c v it returns the 'previous node'
  1379     /// \brief Returns \c false if there are nodes
  1372     /// \brief Returns \c false if there are nodes
  1380     /// to be processed in the queue
  1373     /// to be processed in the queue
  1381     ///
  1374     ///
  1382     /// Returns \c false if there are nodes
  1375     /// Returns \c false if there are nodes
  1383     /// to be processed in the queue
  1376     /// to be processed in the queue
  1384     ///
       
  1385     /// \todo This should be called emptyStack() or some "neutral" name.
       
  1386     bool emptyQueue() { return _stack_head < 0; }
  1377     bool emptyQueue() { return _stack_head < 0; }
  1387 
  1378 
  1388     /// \brief Returns the number of the nodes to be processed.
  1379     /// \brief Returns the number of the nodes to be processed.
  1389     ///
  1380     ///
  1390     /// Returns the number of the nodes to be processed in the queue.
  1381     /// Returns the number of the nodes to be processed in the queue.
  1391     ///
       
  1392     ///\todo This should be called stackSize() or some "neutral" name.
       
  1393     int queueSize() { return _stack_head + 1; }
  1382     int queueSize() { return _stack_head + 1; }
  1394     
  1383     
  1395     /// \brief Executes the algorithm.
  1384     /// \brief Executes the algorithm.
  1396     ///
  1385     ///
  1397     /// Executes the algorithm.
  1386     /// Executes the algorithm.