equal
deleted
inserted
replaced
562 /// |
562 /// |
563 ///\pre init() must be called and at least one node should be added |
563 ///\pre init() must be called and at least one node should be added |
564 ///with addSource() before using this function. |
564 ///with addSource() before using this function. |
565 /// |
565 /// |
566 ///\param em must be a bool (or convertible) edge map. The algorithm |
566 ///\param em must be a bool (or convertible) edge map. The algorithm |
567 ///will stop when it reaches an edge \c e with \code em[e]==true \endcode. |
567 ///will stop when it reaches an edge \c e with <tt>em[e]==true<\tt>. |
568 /// |
568 /// |
569 ///\warning Contrary to \ref Dfs and \ref Dijkstra, \c em is an edge map, |
569 ///\return The reached edge \c e with <tt>em[e]==true<\tt> or |
|
570 ///\c INVALID if no such edge was found. |
|
571 /// |
|
572 ///\warning Contrary to \ref Bfs and \ref Dijkstra, \c em is an edge map, |
570 ///not a node map. |
573 ///not a node map. |
571 template<class EM> |
574 template<class EM> |
572 void start(const EM &em) |
575 Edge start(const EM &em) |
573 { |
576 { |
574 while ( !emptyQueue() && !em[_stack[_stack_head]] ) processNextEdge(); |
577 while ( !emptyQueue() && !em[_stack[_stack_head]] ) |
|
578 processNextEdge(); |
|
579 return emptyQueue() ? INVALID : _stack[_stack_head]; |
575 } |
580 } |
576 |
581 |
577 ///Runs %DFS algorithm to visit all nodes in the graph. |
582 ///Runs %DFS algorithm to visit all nodes in the graph. |
578 |
583 |
579 ///This method runs the %DFS algorithm in order to |
584 ///This method runs the %DFS algorithm in order to |
1439 /// Executes the algorithm until \c dest is reached. |
1444 /// Executes the algorithm until \c dest is reached. |
1440 /// |
1445 /// |
1441 /// \pre init() must be called and at least one node should be added |
1446 /// \pre init() must be called and at least one node should be added |
1442 /// with addSource() before using this function. |
1447 /// with addSource() before using this function. |
1443 void start(Node dest) { |
1448 void start(Node dest) { |
1444 while ( !emptyQueue() && _graph->target(_stack[_stack_head]) != dest) |
1449 while ( !emptyQueue() && _graph->target(_stack[_stack_head]) != dest ) |
1445 processNextEdge(); |
1450 processNextEdge(); |
1446 } |
1451 } |
1447 |
1452 |
1448 /// \brief Executes the algorithm until a condition is met. |
1453 /// \brief Executes the algorithm until a condition is met. |
1449 /// |
1454 /// |
1451 /// |
1456 /// |
1452 /// \pre init() must be called and at least one node should be added |
1457 /// \pre init() must be called and at least one node should be added |
1453 /// with addSource() before using this function. |
1458 /// with addSource() before using this function. |
1454 /// |
1459 /// |
1455 /// \param em must be a bool (or convertible) edge map. The algorithm |
1460 /// \param em must be a bool (or convertible) edge map. The algorithm |
1456 /// will stop when it reaches an edge \c e with \code nm[e]==true \endcode. |
1461 /// will stop when it reaches an edge \c e with <tt>em[e]==true<\tt>. |
1457 /// |
1462 /// |
1458 /// \warning Contrary to \ref Dfs and \ref Dijkstra, \c em is an edge map, |
1463 ///\return The reached edge \c e with <tt>em[e]==true<\tt> or |
|
1464 ///\c INVALID if no such edge was found. |
|
1465 /// |
|
1466 /// \warning Contrary to \ref Bfs and \ref Dijkstra, \c em is an edge map, |
1459 /// not a node map. |
1467 /// not a node map. |
1460 template <typename EM> |
1468 template <typename EM> |
1461 void start(const EM &em) { |
1469 Edge start(const EM &em) { |
1462 while (!emptyQueue() && !em[_stack[_stack_head]]) processNextEdge(); |
1470 while ( !emptyQueue() && !em[_stack[_stack_head]] ) |
|
1471 processNextEdge(); |
|
1472 return emptyQueue() ? INVALID : _stack[_stack_head]; |
1463 } |
1473 } |
1464 |
1474 |
1465 /// \brief Runs %DFSVisit algorithm from node \c s. |
1475 /// \brief Runs %DFSVisit algorithm from node \c s. |
1466 /// |
1476 /// |
1467 /// This method runs the %DFS algorithm from a root node \c s. |
1477 /// This method runs the %DFS algorithm from a root node \c s. |