Skip to content
Snippets Groups Projects
Commit 0e7ef525 authored by Florian Heinrichs's avatar Florian Heinrichs
Browse files

fixed correctness of gp

parent 7d283333
Branches
1 merge request!9Perf optimization
...@@ -6,7 +6,7 @@ bool do_swap = true; ...@@ -6,7 +6,7 @@ bool do_swap = true;
greedy_packing::greedy_packing(graph& g, incremental_bfs& ibfs, bool with_flow) greedy_packing::greedy_packing(graph& g, incremental_bfs& ibfs, bool with_flow)
: graph_(g), i_bfs(ibfs), with_flow_(with_flow){ : graph_(g), i_bfs(ibfs), with_flow_(with_flow){
max_a = (graph_.num_nodes()+1)/2; max_a = (graph_.num_nodes())/2;
}; };
void greedy_packing::reset(std::vector<node_id>& a, std::vector<node_id>& b) { void greedy_packing::reset(std::vector<node_id>& a, std::vector<node_id>& b) {
...@@ -46,10 +46,12 @@ void greedy_packing::bfs(){ ...@@ -46,10 +46,12 @@ void greedy_packing::bfs(){
for(node_id v : neighbors){ for(node_id v : neighbors){
if(visited[v] == false){ if(visited[v] == false){
//falls nicht(mit_flow angegeben und knoten unter den flow_edges ist)dann push in zu x //falls nicht(mit_flow angegeben und knoten unter den flow_edges ist)dann push in zu x
if(!(with_flow_ && (std::find(flow_edges.begin(), flow_edges.end(), graph_.get_edge_id(node, v)) != flow_edges.end()))) if(!(with_flow_ && (std::find(flow_edges.begin(), flow_edges.end(), graph_.get_edge_id(node, v)) != flow_edges.end()))){
x_.push_back(v); x_.push_back(v);
visited[v] = true;
}
} }
visited[v] = true;
} }
} }
...@@ -88,12 +90,15 @@ void greedy_packing::run(){ ...@@ -88,12 +90,15 @@ void greedy_packing::run(){
while (found_new_element) { while (found_new_element) {
found_new_element = false; found_new_element = false;
for (std::vector<node_id>& partition : partitioning) { for (std::vector<node_id>& partition : partitioning) {
for (node_id node : graph_.get_adjacency(partition.back())) { node_id v = partition.back();
for (node_id node : graph_.get_adjacency(v)) {
if (!visited[node]) { if (!visited[node]) {
partition.push_back(node); if(!(with_flow_ && (std::find(flow_edges.begin(), flow_edges.end(), graph_.get_edge_id(node, v)) != flow_edges.end()))){
visited[node] = true; partition.push_back(node);
found_new_element = true; visited[node] = true;
break; found_new_element = true;
break;
}
} }
} }
} }
......
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