equal
deleted
inserted
replaced
539 if(!(*_reached)[m=G->target(e)]) { |
539 if(!(*_reached)[m=G->target(e)]) { |
540 _queue[_queue_head++]=m; |
540 _queue[_queue_head++]=m; |
541 _reached->set(m,true); |
541 _reached->set(m,true); |
542 _pred->set(m,e); |
542 _pred->set(m,e); |
543 _dist->set(m,_curr_dist); |
543 _dist->set(m,_curr_dist); |
544 reached = reach || nm[m]; |
544 reach = reach || nm[m]; |
545 } |
545 } |
546 return n; |
546 return n; |
547 } |
547 } |
548 |
548 |
549 ///Next node to be processed. |
549 ///Next node to be processed. |
603 ///- The distance of \c dest from the root(s). |
603 ///- The distance of \c dest from the root(s). |
604 /// |
604 /// |
605 void start(Node dest) |
605 void start(Node dest) |
606 { |
606 { |
607 bool reach = false; |
607 bool reach = false; |
608 while ( !emptyQueue() && !reach) processNextNode(dest, reach); |
608 while ( !emptyQueue() && !reach ) processNextNode(dest, reach); |
609 } |
609 } |
610 |
610 |
611 ///Executes the algorithm until a condition is met. |
611 ///Executes the algorithm until a condition is met. |
612 |
612 |
613 ///Executes the algorithm until a condition is met. |
613 ///Executes the algorithm until a condition is met. |
621 ///\todo query the reached target |
621 ///\todo query the reached target |
622 template<class NM> |
622 template<class NM> |
623 void start(const NM &nm) |
623 void start(const NM &nm) |
624 { |
624 { |
625 bool reach = false; |
625 bool reach = false; |
626 while ( !emptyQueue() && !reach) processNextNode(nm, reach); |
626 while ( !emptyQueue() && !reach ) processNextNode(nm, reach); |
627 } |
627 } |
628 |
628 |
629 ///Runs %BFS algorithm from node \c s. |
629 ///Runs %BFS algorithm from node \c s. |
630 |
630 |
631 ///This method runs the %BFS algorithm from a root node \c s |
631 ///This method runs the %BFS algorithm from a root node \c s |
662 ///\endcode |
662 ///\endcode |
663 int run(Node s,Node t) { |
663 int run(Node s,Node t) { |
664 init(); |
664 init(); |
665 addSource(s); |
665 addSource(s); |
666 start(t); |
666 start(t); |
667 return reached(t)? _curr_dist : 0; |
667 return reached(t) ? _curr_dist : 0; |
668 } |
668 } |
669 |
669 |
670 ///@} |
670 ///@} |
671 |
671 |
672 ///\name Query Functions |
672 ///\name Query Functions |
1501 /// |
1501 /// |
1502 /// \pre init() must be called and at least one node should be added |
1502 /// \pre init() must be called and at least one node should be added |
1503 /// with addSource() before using this function. |
1503 /// with addSource() before using this function. |
1504 void start(Node dest) { |
1504 void start(Node dest) { |
1505 bool reach = false; |
1505 bool reach = false; |
1506 while (!emptyQueue() && !reach) { |
1506 while ( !emptyQueue() && !reach ) processNextNode(dest, reach); |
1507 processNextNode(dest, reach); |
|
1508 } |
|
1509 } |
1507 } |
1510 |
1508 |
1511 /// \brief Executes the algorithm until a condition is met. |
1509 /// \brief Executes the algorithm until a condition is met. |
1512 /// |
1510 /// |
1513 /// Executes the algorithm until a condition is met. |
1511 /// Executes the algorithm until a condition is met. |
1519 ///algorithm will stop when it reached a node \c v with |
1517 ///algorithm will stop when it reached a node \c v with |
1520 /// <tt>nm[v]</tt> true. |
1518 /// <tt>nm[v]</tt> true. |
1521 template <typename NM> |
1519 template <typename NM> |
1522 void start(const NM &nm) { |
1520 void start(const NM &nm) { |
1523 bool reach = false; |
1521 bool reach = false; |
1524 while (!emptyQueue() && !reach) { |
1522 while ( !emptyQueue() && !reach ) processNextNode(nm, reach); |
1525 processNextNode(nm, reach); |
|
1526 } |
|
1527 } |
1523 } |
1528 |
1524 |
1529 /// \brief Runs %BFSVisit algorithm from node \c s. |
1525 /// \brief Runs %BFSVisit algorithm from node \c s. |
1530 /// |
1526 /// |
1531 /// This method runs the %BFS algorithm from a root node \c s. |
1527 /// This method runs the %BFS algorithm from a root node \c s. |