Boost logo

Boost Users :

Subject: Re: [Boost-users] [graph] compile breadth_first_search error.
From: Jeremiah Willcock (jewillco_at_[hidden])
Date: 2011-10-02 14:17:33


On Sun, 2 Oct 2011, gongyiling wrote:

> i 'm a newbie to boost graph library, I'm trying to compile a sample code as
> following:
>
> struct demo_visitor : public boost::default_bfs_visitor
> {
> template <typename Vertex, typename Graph>
> void discover_vertex(Vertex v, Graph& g)
> {
> //std::cout<<g[v].url<<std::endl;
> }
> };
>
> int main(int argc, char* argv[])
> {
> typedef boost::adjacency_list<boost::vecS,
> boost::listS, //change this to boost::vecS compile ok.
> boost::directedS> graph_t;
> typedef boost::graph_traits<graph_t>::vertex_descriptor
> vertex_descriptor_t;
>
> graph_t g;
> demo_visitor vis;
> boost::breadth_first_search(g, boost::vertex(0, g), boost::visitor(vis));
> return 0;
> }
>
> And it fail to compile will the error in two_bit_color_map.hpp: can't
> transfer boost::detail::error_property_not_found to size_t.
>
> When I change the second type argument(VertexListS) of boost::adjacency_list
> from boost::listS to boost::vecS, it compile ok.
> Is there any implicite constraints on breadth_first_search?
> I also checked that boost::adjacency_list match the VertexListGraph concept
> both, using boost::vecS and boost::listS as it VertexListS type argument.

The breadth_first_search algorithm requires a property map for vertex
indexes; that is supplied automatically when you use vecS as the vertex
container but is not when you use listS. If you truly need listS, you
will need to create a new vertex property named vertex_index
(boost::vertex_index_t in graph declarations) and fill it in before you
call the algorithm. You can fill it using a simple loop over the
vertices, assigning consecutive numbers to them.

-- Jeremiah Willcock


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