All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Macros Pages
steiner_tree_greedy_example.cpp
Go to the documentation of this file.
1 //=======================================================================
2 // Copyright (c) 2013 Piotr Wygocki
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 
23 int main() {
24  typedef sample_graphs_metrics SGM;
25  auto g = SGM::get_graph_steiner();
26  auto index = get(boost::vertex_index, g);
27  typedef boost::graph_traits<decltype(g)>::edge_descriptor Edge;
28  std::set<Edge> steinerEdges;
29  std::vector<int> color(num_vertices(g));
30  {
31  auto c = &color[0];
32  put(c, SGM::A, paal::Terminals::TERMINAL);
33  put(c, SGM::B, paal::Terminals::TERMINAL);
34  put(c, SGM::C, paal::Terminals::TERMINAL);
35  put(c, SGM::D, paal::Terminals::TERMINAL);
36  put(c, SGM::E, paal::Terminals::NONTERMINAL);
37  }
38 
40  g, std::inserter(steinerEdges, steinerEdges.begin()),
41  boost::vertex_color_map(
42  boost::make_iterator_property_map(color.begin(), index)));
43  auto weight = get(boost::edge_weight, g);
44  auto sum = 0;
45  for (auto e : steinerEdges) {
46  sum += get(weight, e);
47  }
48  std::cout << "result " << sum << std::endl;
49 }
int main()
[steiner tree greedy Example]
auto steiner_tree_greedy(const Graph &g, OutputIterator out, EdgeWeightMap edge_weight, ColorMap color_map) -> typename std::pair< typename boost::property_traits< EdgeWeightMap >::value_type, typename boost::property_traits< EdgeWeightMap >::value_type >
non-named version of steiner_tree_greedy