1 #ifndef __DIADES__GRAPH__DFS_HH_ 2 #define __DIADES__GRAPH__DFS_HH_ 19 template<
typename TIncidentEdges,
22 typename TAccumulator,
26 class DFS :
public GraphSearch<TIncidentEdges,TOpposite,TContainer,TAccumulator,
27 TMark,TSolution,TPathCut>
30 typedef GraphSearch<TIncidentEdges,TOpposite,TContainer,TAccumulator,
61 DFS(Graph & graph,
const Container & nodes,
const Opposite & opposite, Solution & s, PathCut & cut, Accumulator & results):
62 Search(graph,nodes,opposite,s,cut,results),_stack(){}
76 while(!_stack.empty())
80 for(
const Node & n : Search::_nodes)
93 bool finished()
const {
return _stack.empty(); }
105 Node n = _stack.top();
108 if(Search::_s.isSolution(n))
110 Search::_results.push_back(n);
111 Search::_updated =
true;
116 IncidentEdges edges(Search::_graph,n,Search::_cut);
118 for(
typename IncidentEdges::Iterator edgeIt = edges.begin();
119 edgeIt != edges.end();
122 const Node & nextNode = Search::_opposite.next(*edgeIt,n);
124 if(!Search::_m.isMarked(nextNode))
126 Search::_m.mark(nextNode);
128 _stack.push(nextNode);
Search::Opposite Opposite
GraphSearch< TIncidentEdges, TOpposite, TContainer, TAccumulator, TMark, TSolution, TPathCut > Search
TIncidentEdges IncidentEdges
Search::IncidentEdges IncidentEdges
Search::Container Container
Search::Accumulator Accumulator
IncidentEdges::Graph Graph
std::stack< Node > _stack
Search::Solution Solution
Namespace of the Diades project.
boost::adjacency_list Graph
virtual void initialize()
DFS(Graph &graph, const Container &nodes, const Opposite &opposite, Solution &s, PathCut &cut, Accumulator &results)