154 { |
154 { |
155 return new ProcessedMap(); |
155 return new ProcessedMap(); |
156 } |
156 } |
157 |
157 |
158 /// \brief The type of the map that stores the cardinalities of the nodes. |
158 /// \brief The type of the map that stores the cardinalities of the nodes. |
159 /// |
159 /// |
160 /// The type of the map that stores the cardinalities of the nodes. |
160 /// The type of the map that stores the cardinalities of the nodes. |
161 /// It must meet the \ref concepts::WriteMap "WriteMap" concept. |
161 /// It must meet the \ref concepts::WriteMap "WriteMap" concept. |
162 typedef typename Digraph::template NodeMap<Value> CardinalityMap; |
162 typedef typename Digraph::template NodeMap<Value> CardinalityMap; |
163 |
163 |
164 /// \brief Instantiates a CardinalityMap. |
164 /// \brief Instantiates a CardinalityMap. |
165 /// |
165 /// |
166 /// This function instantiates a \ref CardinalityMap. |
166 /// This function instantiates a \ref CardinalityMap. |
167 /// \param digraph is the digraph, to which we would like to define the \ref |
167 /// \param digraph is the digraph, to which we would like to define the \ref |
168 /// CardinalityMap |
168 /// CardinalityMap |
169 static CardinalityMap *createCardinalityMap(const Digraph &digraph) { |
169 static CardinalityMap *createCardinalityMap(const Digraph &digraph) { |
170 return new CardinalityMap(digraph); |
170 return new CardinalityMap(digraph); |
171 } |
171 } |
172 |
172 |
173 |
173 |
174 }; |
174 }; |
175 |
175 |
176 /// \ingroup search |
176 /// \ingroup search |
177 /// |
177 /// |
178 /// \brief Maximum Cardinality Search algorithm class. |
178 /// \brief Maximum Cardinality Search algorithm class. |
179 /// |
179 /// |
180 /// This class provides an efficient implementation of Maximum Cardinality |
180 /// This class provides an efficient implementation of Maximum Cardinality |
181 /// Search algorithm. The maximum cardinality search first chooses any |
181 /// Search algorithm. The maximum cardinality search first chooses any |
182 /// node of the digraph. Then every time it chooses one unprocessed node |
182 /// node of the digraph. Then every time it chooses one unprocessed node |
183 /// with maximum cardinality, i.e the sum of capacities on out arcs to the nodes |
183 /// with maximum cardinality, i.e the sum of capacities on out arcs to the nodes |
184 /// which were previusly processed. |
184 /// which were previusly processed. |
185 /// If there is a cut in the digraph the algorithm should choose |
185 /// If there is a cut in the digraph the algorithm should choose |
186 /// again any unprocessed node of the digraph. |
186 /// again any unprocessed node of the digraph. |
187 |
187 |
188 /// The arc capacities are passed to the algorithm using a |
188 /// The arc capacities are passed to the algorithm using a |
189 /// \ref concepts::ReadMap "ReadMap", so it is easy to change it to any |
189 /// \ref concepts::ReadMap "ReadMap", so it is easy to change it to any |
190 /// kind of capacity. |
190 /// kind of capacity. |
191 /// |
191 /// |
192 /// The type of the capacity is determined by the \ref |
192 /// The type of the capacity is determined by the \ref |
193 /// concepts::ReadMap::Value "Value" of the capacity map. |
193 /// concepts::ReadMap::Value "Value" of the capacity map. |
194 /// |
194 /// |
195 /// It is also possible to change the underlying priority heap. |
195 /// It is also possible to change the underlying priority heap. |
196 /// |
196 /// |
197 /// |
197 /// |
198 /// \param GR The digraph type the algorithm runs on. The value of |
198 /// \param GR The digraph type the algorithm runs on. The value of |
199 /// Digraph is not used directly by the search algorithm, it |
199 /// Digraph is not used directly by the search algorithm, it |
200 /// is only passed to \ref MaxCardinalitySearchDefaultTraits. |
200 /// is only passed to \ref MaxCardinalitySearchDefaultTraits. |
201 /// \param CAP This read-only ArcMap determines the capacities of |
201 /// \param CAP This read-only ArcMap determines the capacities of |
202 /// the arcs. It is read once for each arc, so the map may involve in |
202 /// the arcs. It is read once for each arc, so the map may involve in |
203 /// relatively time consuming process to compute the arc capacity if |
203 /// relatively time consuming process to compute the arc capacity if |
204 /// it is necessary. The default map type is \ref |
204 /// it is necessary. The default map type is \ref |
205 /// ConstMap "ConstMap<concepts::Digraph::Arc, Const<int,1> >". The value |
205 /// ConstMap "ConstMap<concepts::Digraph::Arc, Const<int,1> >". The value |
206 /// of CapacityMap is not used directly by search algorithm, it is only |
206 /// of CapacityMap is not used directly by search algorithm, it is only |
207 /// passed to \ref MaxCardinalitySearchDefaultTraits. |
207 /// passed to \ref MaxCardinalitySearchDefaultTraits. |
208 /// \param TR Traits class to set various data types used by the |
208 /// \param TR Traits class to set various data types used by the |
209 /// algorithm. The default traits class is |
209 /// algorithm. The default traits class is |
210 /// \ref MaxCardinalitySearchDefaultTraits |
210 /// \ref MaxCardinalitySearchDefaultTraits |
211 /// "MaxCardinalitySearchDefaultTraits<GR, CAP>". |
211 /// "MaxCardinalitySearchDefaultTraits<GR, CAP>". |
212 /// See \ref MaxCardinalitySearchDefaultTraits |
212 /// See \ref MaxCardinalitySearchDefaultTraits |
213 /// for the documentation of a MaxCardinalitySearch traits class. |
213 /// for the documentation of a MaxCardinalitySearch traits class. |
214 |
214 |
215 #ifdef DOXYGEN |
215 #ifdef DOXYGEN |
216 template <typename GR, typename CAP, typename TR> |
216 template <typename GR, typename CAP, typename TR> |
217 #else |
217 #else |
218 template <typename GR, typename CAP = |
218 template <typename GR, typename CAP = |
219 ConstMap<typename GR::Arc, Const<int,1> >, |
219 ConstMap<typename GR::Arc, Const<int,1> >, |
220 typename TR = |
220 typename TR = |
221 MaxCardinalitySearchDefaultTraits<GR, CAP> > |
221 MaxCardinalitySearchDefaultTraits<GR, CAP> > |
222 #endif |
222 #endif |
223 class MaxCardinalitySearch { |
223 class MaxCardinalitySearch { |
224 public: |
224 public: |
225 |
225 |
226 typedef TR Traits; |
226 typedef TR Traits; |
227 ///The type of the underlying digraph. |
227 ///The type of the underlying digraph. |
228 typedef typename Traits::Digraph Digraph; |
228 typedef typename Traits::Digraph Digraph; |
229 |
229 |
230 ///The type of the capacity of the arcs. |
230 ///The type of the capacity of the arcs. |
231 typedef typename Traits::CapacityMap::Value Value; |
231 typedef typename Traits::CapacityMap::Value Value; |
232 ///The type of the map that stores the arc capacities. |
232 ///The type of the map that stores the arc capacities. |
233 typedef typename Traits::CapacityMap CapacityMap; |
233 typedef typename Traits::CapacityMap CapacityMap; |
234 ///The type of the map indicating if a node is processed. |
234 ///The type of the map indicating if a node is processed. |
264 bool local_heap; |
264 bool local_heap; |
265 |
265 |
266 public : |
266 public : |
267 |
267 |
268 typedef MaxCardinalitySearch Create; |
268 typedef MaxCardinalitySearch Create; |
269 |
269 |
270 ///\name Named template parameters |
270 ///\name Named template parameters |
271 |
271 |
272 ///@{ |
272 ///@{ |
273 |
273 |
274 template <class T> |
274 template <class T> |
275 struct DefCapacityMapTraits : public Traits { |
275 struct DefCapacityMapTraits : public Traits { |
276 typedef T CapacityMap; |
276 typedef T CapacityMap; |
277 static CapacityMap *createCapacityMap(const Digraph &) { |
277 static CapacityMap *createCapacityMap(const Digraph &) { |
278 LEMON_ASSERT(false,"Uninitialized parameter."); |
278 LEMON_ASSERT(false,"Uninitialized parameter."); |
279 return 0; |
279 return 0; |
280 } |
280 } |
281 }; |
281 }; |
282 /// \brief \ref named-templ-param "Named parameter" for setting |
282 /// \brief \ref named-templ-param "Named parameter" for setting |
283 /// CapacityMap type |
283 /// CapacityMap type |
284 /// |
284 /// |
285 /// \ref named-templ-param "Named parameter" for setting CapacityMap type |
285 /// \ref named-templ-param "Named parameter" for setting CapacityMap type |
286 /// for the algorithm. |
286 /// for the algorithm. |
287 template <class T> |
287 template <class T> |
288 struct SetCapacityMap |
288 struct SetCapacityMap |
289 : public MaxCardinalitySearch<Digraph, CapacityMap, |
289 : public MaxCardinalitySearch<Digraph, CapacityMap, |
290 DefCapacityMapTraits<T> > { |
290 DefCapacityMapTraits<T> > { |
291 typedef MaxCardinalitySearch<Digraph, CapacityMap, |
291 typedef MaxCardinalitySearch<Digraph, CapacityMap, |
292 DefCapacityMapTraits<T> > Create; |
292 DefCapacityMapTraits<T> > Create; |
293 }; |
293 }; |
294 |
294 |
295 template <class T> |
295 template <class T> |
296 struct DefCardinalityMapTraits : public Traits { |
296 struct DefCardinalityMapTraits : public Traits { |
297 typedef T CardinalityMap; |
297 typedef T CardinalityMap; |
298 static CardinalityMap *createCardinalityMap(const Digraph &) |
298 static CardinalityMap *createCardinalityMap(const Digraph &) |
299 { |
299 { |
300 LEMON_ASSERT(false,"Uninitialized parameter."); |
300 LEMON_ASSERT(false,"Uninitialized parameter."); |
301 return 0; |
301 return 0; |
302 } |
302 } |
303 }; |
303 }; |
304 /// \brief \ref named-templ-param "Named parameter" for setting |
304 /// \brief \ref named-templ-param "Named parameter" for setting |
305 /// CardinalityMap type |
305 /// CardinalityMap type |
306 /// |
306 /// |
307 /// \ref named-templ-param "Named parameter" for setting CardinalityMap |
307 /// \ref named-templ-param "Named parameter" for setting CardinalityMap |
308 /// type for the algorithm. |
308 /// type for the algorithm. |
309 template <class T> |
309 template <class T> |
310 struct SetCardinalityMap |
310 struct SetCardinalityMap |
311 : public MaxCardinalitySearch<Digraph, CapacityMap, |
311 : public MaxCardinalitySearch<Digraph, CapacityMap, |
312 DefCardinalityMapTraits<T> > { |
312 DefCardinalityMapTraits<T> > { |
313 typedef MaxCardinalitySearch<Digraph, CapacityMap, |
313 typedef MaxCardinalitySearch<Digraph, CapacityMap, |
314 DefCardinalityMapTraits<T> > Create; |
314 DefCardinalityMapTraits<T> > Create; |
315 }; |
315 }; |
316 |
316 |
317 template <class T> |
317 template <class T> |
318 struct DefProcessedMapTraits : public Traits { |
318 struct DefProcessedMapTraits : public Traits { |
319 typedef T ProcessedMap; |
319 typedef T ProcessedMap; |
320 static ProcessedMap *createProcessedMap(const Digraph &) { |
320 static ProcessedMap *createProcessedMap(const Digraph &) { |
321 LEMON_ASSERT(false,"Uninitialized parameter."); |
321 LEMON_ASSERT(false,"Uninitialized parameter."); |
322 return 0; |
322 return 0; |
323 } |
323 } |
324 }; |
324 }; |
325 /// \brief \ref named-templ-param "Named parameter" for setting |
325 /// \brief \ref named-templ-param "Named parameter" for setting |
326 /// ProcessedMap type |
326 /// ProcessedMap type |
327 /// |
327 /// |
328 /// \ref named-templ-param "Named parameter" for setting ProcessedMap type |
328 /// \ref named-templ-param "Named parameter" for setting ProcessedMap type |
329 /// for the algorithm. |
329 /// for the algorithm. |
330 template <class T> |
330 template <class T> |
331 struct SetProcessedMap |
331 struct SetProcessedMap |
332 : public MaxCardinalitySearch<Digraph, CapacityMap, |
332 : public MaxCardinalitySearch<Digraph, CapacityMap, |
333 DefProcessedMapTraits<T> > { |
333 DefProcessedMapTraits<T> > { |
334 typedef MaxCardinalitySearch<Digraph, CapacityMap, |
334 typedef MaxCardinalitySearch<Digraph, CapacityMap, |
335 DefProcessedMapTraits<T> > Create; |
335 DefProcessedMapTraits<T> > Create; |
336 }; |
336 }; |
337 |
337 |
338 template <class H, class CR> |
338 template <class H, class CR> |
339 struct DefHeapTraits : public Traits { |
339 struct DefHeapTraits : public Traits { |
340 typedef CR HeapCrossRef; |
340 typedef CR HeapCrossRef; |
341 typedef H Heap; |
341 typedef H Heap; |
342 static HeapCrossRef *createHeapCrossRef(const Digraph &) { |
342 static HeapCrossRef *createHeapCrossRef(const Digraph &) { |
343 LEMON_ASSERT(false,"Uninitialized parameter."); |
343 LEMON_ASSERT(false,"Uninitialized parameter."); |
344 return 0; |
344 return 0; |
345 } |
345 } |
346 static Heap *createHeap(HeapCrossRef &) { |
346 static Heap *createHeap(HeapCrossRef &) { |
347 LEMON_ASSERT(false,"Uninitialized parameter."); |
347 LEMON_ASSERT(false,"Uninitialized parameter."); |
348 return 0; |
348 return 0; |
349 } |
349 } |
350 }; |
350 }; |
351 /// \brief \ref named-templ-param "Named parameter" for setting heap |
351 /// \brief \ref named-templ-param "Named parameter" for setting heap |
352 /// and cross reference type |
352 /// and cross reference type |
353 /// |
353 /// |
354 /// \ref named-templ-param "Named parameter" for setting heap and cross |
354 /// \ref named-templ-param "Named parameter" for setting heap and cross |
355 /// reference type for the algorithm. |
355 /// reference type for the algorithm. |
356 template <class H, class CR = typename Digraph::template NodeMap<int> > |
356 template <class H, class CR = typename Digraph::template NodeMap<int> > |
357 struct SetHeap |
357 struct SetHeap |
358 : public MaxCardinalitySearch<Digraph, CapacityMap, |
358 : public MaxCardinalitySearch<Digraph, CapacityMap, |
359 DefHeapTraits<H, CR> > { |
359 DefHeapTraits<H, CR> > { |
360 typedef MaxCardinalitySearch< Digraph, CapacityMap, |
360 typedef MaxCardinalitySearch< Digraph, CapacityMap, |
361 DefHeapTraits<H, CR> > Create; |
361 DefHeapTraits<H, CR> > Create; |
362 }; |
362 }; |
363 |
363 |
364 template <class H, class CR> |
364 template <class H, class CR> |
365 struct DefStandardHeapTraits : public Traits { |
365 struct DefStandardHeapTraits : public Traits { |
366 typedef CR HeapCrossRef; |
366 typedef CR HeapCrossRef; |
367 typedef H Heap; |
367 typedef H Heap; |
368 static HeapCrossRef *createHeapCrossRef(const Digraph &digraph) { |
368 static HeapCrossRef *createHeapCrossRef(const Digraph &digraph) { |
369 return new HeapCrossRef(digraph); |
369 return new HeapCrossRef(digraph); |
370 } |
370 } |
371 static Heap *createHeap(HeapCrossRef &crossref) { |
371 static Heap *createHeap(HeapCrossRef &crossref) { |
372 return new Heap(crossref); |
372 return new Heap(crossref); |
373 } |
373 } |
374 }; |
374 }; |
375 |
375 |
376 /// \brief \ref named-templ-param "Named parameter" for setting heap and |
376 /// \brief \ref named-templ-param "Named parameter" for setting heap and |
377 /// cross reference type with automatic allocation |
377 /// cross reference type with automatic allocation |
378 /// |
378 /// |
379 /// \ref named-templ-param "Named parameter" for setting heap and cross |
379 /// \ref named-templ-param "Named parameter" for setting heap and cross |
380 /// reference type. It can allocate the heap and the cross reference |
380 /// reference type. It can allocate the heap and the cross reference |
381 /// object if the cross reference's constructor waits for the digraph as |
381 /// object if the cross reference's constructor waits for the digraph as |
382 /// parameter and the heap's constructor waits for the cross reference. |
382 /// parameter and the heap's constructor waits for the cross reference. |
383 template <class H, class CR = typename Digraph::template NodeMap<int> > |
383 template <class H, class CR = typename Digraph::template NodeMap<int> > |
384 struct SetStandardHeap |
384 struct SetStandardHeap |
385 : public MaxCardinalitySearch<Digraph, CapacityMap, |
385 : public MaxCardinalitySearch<Digraph, CapacityMap, |
386 DefStandardHeapTraits<H, CR> > { |
386 DefStandardHeapTraits<H, CR> > { |
387 typedef MaxCardinalitySearch<Digraph, CapacityMap, |
387 typedef MaxCardinalitySearch<Digraph, CapacityMap, |
388 DefStandardHeapTraits<H, CR> > |
388 DefStandardHeapTraits<H, CR> > |
389 Create; |
389 Create; |
390 }; |
390 }; |
391 |
391 |
392 ///@} |
392 ///@} |
393 |
393 |
394 |
394 |
395 protected: |
395 protected: |
396 |
396 |
397 MaxCardinalitySearch() {} |
397 MaxCardinalitySearch() {} |
398 |
398 |
399 public: |
399 public: |
400 |
400 |
401 /// \brief Constructor. |
401 /// \brief Constructor. |
402 /// |
402 /// |
403 ///\param digraph the digraph the algorithm will run on. |
403 ///\param digraph the digraph the algorithm will run on. |
404 ///\param capacity the capacity map used by the algorithm. |
404 ///\param capacity the capacity map used by the algorithm. |
405 MaxCardinalitySearch(const Digraph& digraph, |
405 MaxCardinalitySearch(const Digraph& digraph, |
406 const CapacityMap& capacity) : |
406 const CapacityMap& capacity) : |
407 _graph(&digraph), |
407 _graph(&digraph), |
408 _capacity(&capacity), local_capacity(false), |
408 _capacity(&capacity), local_capacity(false), |
409 _cardinality(0), local_cardinality(false), |
409 _cardinality(0), local_cardinality(false), |
410 _processed(0), local_processed(false), |
410 _processed(0), local_processed(false), |
411 _heap_cross_ref(0), local_heap_cross_ref(false), |
411 _heap_cross_ref(0), local_heap_cross_ref(false), |
587 /// Initializes the internal data structures, and clears the heap. |
587 /// Initializes the internal data structures, and clears the heap. |
588 void init() { |
588 void init() { |
589 create_maps(); |
589 create_maps(); |
590 _heap->clear(); |
590 _heap->clear(); |
591 for (NodeIt it(*_graph) ; it != INVALID ; ++it) { |
591 for (NodeIt it(*_graph) ; it != INVALID ; ++it) { |
592 _processed->set(it, false); |
592 _processed->set(it, false); |
593 _heap_cross_ref->set(it, Heap::PRE_HEAP); |
593 _heap_cross_ref->set(it, Heap::PRE_HEAP); |
594 } |
594 } |
595 } |
595 } |
596 |
596 |
597 /// \brief Adds a new source node. |
597 /// \brief Adds a new source node. |
598 /// |
598 /// |
599 /// Adds a new source node to the priority heap. |
599 /// Adds a new source node to the priority heap. |
600 /// |
600 /// |
601 /// It checks if the node has not yet been added to the heap. |
601 /// It checks if the node has not yet been added to the heap. |
602 void addSource(Node source, Value capacity = 0) { |
602 void addSource(Node source, Value capacity = 0) { |
603 if(_heap->state(source) == Heap::PRE_HEAP) { |
603 if(_heap->state(source) == Heap::PRE_HEAP) { |
604 _heap->push(source, capacity); |
604 _heap->push(source, capacity); |
605 } |
605 } |
606 } |
606 } |
607 |
607 |
608 /// \brief Processes the next node in the priority heap |
608 /// \brief Processes the next node in the priority heap |
609 /// |
609 /// |
610 /// Processes the next node in the priority heap. |
610 /// Processes the next node in the priority heap. |
611 /// |
611 /// |
612 /// \return The processed node. |
612 /// \return The processed node. |
613 /// |
613 /// |
614 /// \warning The priority heap must not be empty! |
614 /// \warning The priority heap must not be empty! |
615 Node processNextNode() { |
615 Node processNextNode() { |
616 Node node = _heap->top(); |
616 Node node = _heap->top(); |
617 finalizeNodeData(node, _heap->prio()); |
617 finalizeNodeData(node, _heap->prio()); |
618 _heap->pop(); |
618 _heap->pop(); |
619 |
619 |
620 for (InArcIt it(*_graph, node); it != INVALID; ++it) { |
620 for (InArcIt it(*_graph, node); it != INVALID; ++it) { |
621 Node source = _graph->source(it); |
621 Node source = _graph->source(it); |
622 switch (_heap->state(source)) { |
622 switch (_heap->state(source)) { |
623 case Heap::PRE_HEAP: |
623 case Heap::PRE_HEAP: |
624 _heap->push(source, (*_capacity)[it]); |
624 _heap->push(source, (*_capacity)[it]); |
625 break; |
625 break; |
626 case Heap::IN_HEAP: |
626 case Heap::IN_HEAP: |
627 _heap->decrease(source, (*_heap)[source] + (*_capacity)[it]); |
627 _heap->decrease(source, (*_heap)[source] + (*_capacity)[it]); |
628 break; |
628 break; |
629 case Heap::POST_HEAP: |
629 case Heap::POST_HEAP: |
630 break; |
630 break; |
631 } |
631 } |
632 } |
632 } |
633 return node; |
633 return node; |
634 } |
634 } |
635 |
635 |
636 /// \brief Next node to be processed. |
636 /// \brief Next node to be processed. |
637 /// |
637 /// |
638 /// Next node to be processed. |
638 /// Next node to be processed. |
639 /// |
639 /// |
640 /// \return The next node to be processed or INVALID if the |
640 /// \return The next node to be processed or INVALID if the |
641 /// priority heap is empty. |
641 /// priority heap is empty. |
642 Node nextNode() { |
642 Node nextNode() { |
643 return !_heap->empty() ? _heap->top() : INVALID; |
643 return !_heap->empty() ? _heap->top() : INVALID; |
644 } |
644 } |
645 |
645 |
646 /// \brief Returns \c false if there are nodes |
646 /// \brief Returns \c false if there are nodes |
647 /// to be processed in the priority heap |
647 /// to be processed in the priority heap |
648 /// |
648 /// |
649 /// Returns \c false if there are nodes |
649 /// Returns \c false if there are nodes |
650 /// to be processed in the priority heap |
650 /// to be processed in the priority heap |
651 bool emptyQueue() { return _heap->empty(); } |
651 bool emptyQueue() { return _heap->empty(); } |
652 /// \brief Returns the number of the nodes to be processed |
652 /// \brief Returns the number of the nodes to be processed |
653 /// in the priority heap |
653 /// in the priority heap |
654 /// |
654 /// |
655 /// Returns the number of the nodes to be processed in the priority heap |
655 /// Returns the number of the nodes to be processed in the priority heap |
656 int emptySize() { return _heap->size(); } |
656 int emptySize() { return _heap->size(); } |
657 |
657 |
658 /// \brief Executes the algorithm. |
658 /// \brief Executes the algorithm. |
659 /// |
659 /// |
660 /// Executes the algorithm. |
660 /// Executes the algorithm. |
661 /// |
661 /// |
662 ///\pre init() must be called and at least one node should be added |
662 ///\pre init() must be called and at least one node should be added |
663 /// with addSource() before using this function. |
663 /// with addSource() before using this function. |
664 /// |
664 /// |
665 /// This method runs the Maximum Cardinality Search algorithm from the |
665 /// This method runs the Maximum Cardinality Search algorithm from the |
666 /// source node(s). |
666 /// source node(s). |
667 void start() { |
667 void start() { |
668 while ( !_heap->empty() ) processNextNode(); |
668 while ( !_heap->empty() ) processNextNode(); |
669 } |
669 } |
670 |
670 |
671 /// \brief Executes the algorithm until \c dest is reached. |
671 /// \brief Executes the algorithm until \c dest is reached. |
672 /// |
672 /// |
673 /// Executes the algorithm until \c dest is reached. |
673 /// Executes the algorithm until \c dest is reached. |
674 /// |
674 /// |
675 /// \pre init() must be called and at least one node should be added |
675 /// \pre init() must be called and at least one node should be added |
676 /// with addSource() before using this function. |
676 /// with addSource() before using this function. |
677 /// |
677 /// |
678 /// This method runs the %MaxCardinalitySearch algorithm from the source |
678 /// This method runs the %MaxCardinalitySearch algorithm from the source |
679 /// nodes. |
679 /// nodes. |
680 void start(Node dest) { |
680 void start(Node dest) { |
681 while ( !_heap->empty() && _heap->top()!=dest ) processNextNode(); |
681 while ( !_heap->empty() && _heap->top()!=dest ) processNextNode(); |
682 if ( !_heap->empty() ) finalizeNodeData(_heap->top(), _heap->prio()); |
682 if ( !_heap->empty() ) finalizeNodeData(_heap->top(), _heap->prio()); |
683 } |
683 } |
684 |
684 |
685 /// \brief Executes the algorithm until a condition is met. |
685 /// \brief Executes the algorithm until a condition is met. |
686 /// |
686 /// |
687 /// Executes the algorithm until a condition is met. |
687 /// Executes the algorithm until a condition is met. |
688 /// |
688 /// |
689 /// \pre init() must be called and at least one node should be added |
689 /// \pre init() must be called and at least one node should be added |