All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Macros Pages
steiner_tree_ir_example.cpp
Go to the documentation of this file.
1 //=======================================================================
2 // Copyright (c)
3 //
4 // Distributed under the Boost Software License, Version 1.0. (See
5 // accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
7 //=======================================================================
16 #include "test/test_utils/sample_graph.hpp"
18 
20 
21 #include <iostream>
22 #include <vector>
23 
24 int main() {
25  using SGM = sample_graphs_metrics;
26  auto metric = SGM::get_graph_metric_steiner();
27 
28  std::vector<int> terminals = {SGM::A, SGM::B, SGM::C, SGM::D};
29  std::vector<int> nonterminals = {SGM::E};
30  std::vector<int> selected_nonterminals;
31 
32  // solve it
34  nonterminals, std::back_inserter(selected_nonterminals));
35 
36  // print result
37  std::cout << "Selected vertices:" << std::endl;
38  for (auto v : terminals) {
39  std::cout << v << std::endl;
40  }
41  for (auto v : selected_nonterminals) {
42  std::cout << v << std::endl;
43  }
44  auto cost = paal::ir::steiner_utils::count_cost(selected_nonterminals,
45  terminals, metric);
46  std::cout << "Cost of the solution: " << cost << std::endl;
47 
48  paal::lp::glp::free_env();
49 }
50 
static data_structures::metric_traits< Metric >::DistanceType count_cost(const Result &steiner_vertices, const Terminals &terminals, const Metric &cost_map)
lp::problem_type steiner_tree_iterative_rounding(const OrigMetric &metric, const Terminals &terminals, const Terminals &steiner_vertices, Result result, Strategy strategy=Strategy{}, IRcomponents comps=IRcomponents{}, Oracle oracle=Oracle{}, Visitor visitor=Visitor{})
Solves the Steiner Tree problem using Iterative Rounding.
int main()
[IR Steiner Tree Example]