Skip to content
Snippets Groups Projects
Commit 1921e455 authored by p-hamann's avatar p-hamann
Browse files

Fix memory leaks

parent fa1c1706
Branches
1 merge request!7Incremental bfs
......@@ -25,7 +25,7 @@ void trail_state::pop() {
// solver implementation.
// --------------------------------------------------------------------------------------
solver::solver(graph& g, lb lb_algorithm) : graph_(g), partition_(partition{g}), lb_algorithm_(lb_algorithm) {
solver::solver(graph& g, lb lb_algorithm) : graph_(g), partition_(partition{g}), lb_algorithm_(lb_algorithm), i_bfs_(incremental_bfs(g)) {
}
unsigned int solver::get_lower(){
......@@ -48,12 +48,9 @@ unsigned int solver::get_lower(){
return ek.get_max_flow();
}
else if(lb_algorithm_ == lb::ibfs){
if (i_bfs_ == nullptr) {
i_bfs_ = new incremental_bfs(graph_);
}
i_bfs_->reset(sources, sinks);
i_bfs_->run();
return i_bfs_->get_max_flow();
i_bfs_.reset(sources, sinks);
i_bfs_.run();
return i_bfs_.get_max_flow();
}
else if(lb_algorithm_ == lb::pr){
auto pr = push_relabel(graph_, sources, sinks);
......
......@@ -17,28 +17,29 @@ int main(int argc, char** argv) {
std::cerr << "Number of nodes: " << g.num_nodes() << std::endl;
auto sol = gp_bnb::solver(g, gp_bnb::lb::none);
std::string current_option;
gp_bnb::lb lb_algo = gp_bnb::lb::none;
for (int i = 2; i < argc; ++i) {
if (i%2 == 0) {
current_option = args[i];
} else {
if (current_option == "-l") {
if (args[i] == "ek") {
sol = gp_bnb::solver(g, gp_bnb::lb::ek);
lb_algo = gp_bnb::lb::ek;
} else if (args[i] == "ibfs") {
sol = gp_bnb::solver(g, gp_bnb::lb::ibfs);
lb_algo = gp_bnb::lb::ibfs;
} else if (args[i] == "pr") {
sol = gp_bnb::solver(g, gp_bnb::lb::pr);
lb_algo = gp_bnb::lb::pr;
} else if (args[i] == "gp") {
sol = gp_bnb::solver(g, gp_bnb::lb::gp);
lb_algo = gp_bnb::lb::gp;
}
}
}
}
auto sol = gp_bnb::solver(g, lb_algo);
sol.solve();
/*
......
......@@ -88,7 +88,7 @@ private:
trail_state trail_;
lb lb_algorithm_;
incremental_bfs* i_bfs_ = nullptr;
incremental_bfs i_bfs_;
// Value of best solution seen so far.
std::vector<subgraph> best_solution_;
......
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