Commit e57f4aa5 authored by Jonas Seidel's avatar Jonas Seidel

Correction to dfs_all_components

(previously nodes may be visited multiple times)
parent a4f2dfd8
......@@ -10,8 +10,9 @@ void Graph<N,E>::conditional_bfs_all_components(std::function<void(Node<N,E>* fr
while(!uncharted.empty()){
active.push(*uncharted.begin());
uncharted.erase(*uncharted.begin());
while(!active.empty()){
Node<N,E>* n = active.front(); active.pop(); uncharted.erase(n);
Node<N,E>* n = active.front(); active.pop();
node_exec(n);
for(Edge<N,E>* e : n->incident()){
......@@ -20,7 +21,9 @@ void Graph<N,E>::conditional_bfs_all_components(std::function<void(Node<N,E>* fr
if(guide(n, e)){
if(uncharted.find(e->to(n)) != uncharted.end()){
used_in_traversal = true;
active.push(e->to(n));
uncharted.erase(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