Boost logo

Boost Users :

Subject: Re: [Boost-users] Using metric_tsp_approx with bundled properties
From: Alexis Praga (alexispraga_at_[hidden])
Date: 2014-04-14 08:58:13


On Mon, Apr 14, 2014 at 10:50:52AM +0100, Albert Yiamakis wrote:
> On 13/04/14 22:02, Alexis Praga wrote:
> > Hi,
> >
> > I am trying to use metric_tsp_approx on a graph defined as :
> >
> > typedef adjacency_list<vecS, vecS, undirectedS, City, Road> Graph;
> >
> > City contains the vertex id and Road the edge weight.
> > After reading the documentation, I arrived to :
> >
> > metric_tsp_approx(g_init,
> > weight_map(get(&Road::length, g_init)).
> > vertex_index_map(get(&City::id, g_init)),
> > make_tsp_tour_visitor(back_inserter(c)));
> >
> > I have compilation errors however. The relevant part seems to be :
> >
> > /usr/include/boost/property_map/property_map.hpp:382:58: error: no
> > type named ‘key_type’ in ‘struct
> > boost::property_traits<boost::bgl_named_params<boost::bundle_property_map<boost::adjacency_list<boost::vecS,
> > boost::vecS, boost::undirectedS, City, Road>, long unsigned int, City,
> > int>, boost::vertex_index_t, boost::no_property> >’
> >
> > Any help appreciated, thanks.
>
> Are City and Road really properties?
> get() looks up properties by tag.
> Supply your adjacency list properties rather than the classes
> themselves. For instance:
>
> typedef property<vertex_index_t, City> CityProperty;
> typedef property<edge_index_t, Road> RoadProperty;
>
> typedef adjacency_list<vecS, vecS, undirectedS, CityProperty,
> RoadProperty> Graph;
>
> Then you can use get(vertex_index_t(), g_init) and get(edge_index_t(),
> g_init).
> These are predefined tags - for more and how to define your own:
>
> http://www.boost.org/doc/libs/1_55_0/libs/graph/doc/using_adjacency_list.html#sec:adjacency-list-properties
>
> Albert
>

Thanks for the answer. I am a bit confused about properties.

From the documentation, I understood you could use any class to create
the graph, as long as you use bundled property and as long as you
create the property map when needed.

I thought it would suffice to create a property map for vertices
index and for the edge index. In my case :
       vertex_index_map(get(&City::id, g_init)),
 and
       weight_map(get(&Road::length, g_init)),

From your answer, I think you want me to use internal properties,
instead of bundled properties.

Am I missing something ?

-- 
Alexis Praga, PhD Student (CERFACS)
GPG key : AD4A AF6D BB5C 042F 9422  1223 06E1 C1BF E287 65D0



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net