1 #ifndef __DIADES__GRAPH__BFS_HH_ 2 #define __DIADES__GRAPH__BFS_HH_ 19 template<
typename TIncidentEdges,
22 typename TAccumulator,
26 class BFS :
public GraphSearch<TIncidentEdges,TOpposite,TContainer,TAccumulator,
27 TMark,TSolution,TPathCut>
30 typedef GraphSearch<TIncidentEdges,TOpposite,TContainer,TAccumulator,
59 BFS(Graph & graph,
const Container & nodes,
const Opposite & opposite, Solution & s, PathCut & cut, Accumulator & results):
60 Search(graph,nodes,opposite,s,cut,results),_queue(){}
74 while(!_queue.empty())
91 bool finished()
const {
return _queue.empty(); }
102 Node n = _queue.front();
106 if(Search::_s.isSolution(n))
108 Search::_results.push_back(n);
109 Search::_updated =
true;
114 IncidentEdges edges(Search::_graph,n,Search::_cut);
116 for(
typename IncidentEdges::Iterator edgeIt = edges.begin();
117 edgeIt != edges.end();
120 const Node & nextNode = Search::_opposite.next(*edgeIt,n);
121 if(!Search::_m.isMarked(nextNode))
123 Search::_m.mark(nextNode);
124 _queue.push(nextNode);
Search::Opposite Opposite
GraphSearch< TIncidentEdges, TOpposite, TContainer, TAccumulator, TMark, TSolution, TPathCut > Search
std::queue< Node > _queue
TIncidentEdges IncidentEdges
Search::Solution Solution
IncidentEdges::Graph Graph
BFS(Graph &graph, const Container &nodes, const Opposite &opposite, Solution &s, PathCut &cut, Accumulator &results)
Namespace of the Diades project.
virtual void initialize()
Search::Accumulator Accumulator
Search::Container Container
Search::IncidentEdges IncidentEdges