|
Boost Users : |
Subject: Re: [Boost-users] Using metric_tsp_approx with bundled properties
From: Albert Yiamakis (vkicefire_at_[hidden])
Date: 2014-04-14 05:50:52
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:
Albert
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