Commit bfd6600e authored by Jonas Seidel's avatar Jonas Seidel

dfs correction

parent 4230e6f1
......@@ -51,30 +51,31 @@ void Graph::conditional_bfs_all_components(
node_exec need to return true in order to continue traversal over its incident edges
*/
std::set<Node*> uncharted = this->nodes();
std::deque<Node*> active = starting_nodes;
std::deque<std::pair<Edge*, Node*>> active;
for(Node* node : starting_nodes){
active.push_back({nullptr, node});
}
while(!uncharted.empty()){
if(active.empty()){
active.push_back(*uncharted.begin());
active.push_back({nullptr, *uncharted.begin()});
uncharted.erase(*uncharted.begin());
}
for(Node* manually_inserted_node : active){
node_exec(nullptr, manually_inserted_node);
}
while(!active.empty()){
Node* n = active.front(); active.pop_front();
std::pair<Edge*, Node*> next = active.front(); active.pop_front();
bool local_all_paths = node_exec(next.first, next.second);
Node* n = next.second;
uncharted.erase(n);
for(Edge* e : n->incident()){
bool used_in_traversal = false;
if(guide(n, e)){
if(uncharted.find(e->to(n)) != uncharted.end() || all_paths){
if(uncharted.find(e->to(n)) != uncharted.end() || all_paths || local_all_paths) {
used_in_traversal = true;
if(node_exec(e, e->to(n))){
active.push_back(e->to(n));
}
uncharted.erase(e->to(n));
active.push_back({e, e->to(n)});
}
edge_exec(n, e, used_in_traversal);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment