|
Boost Users : |
From: Aaron Windsor (aaron.windsor_at_[hidden])
Date: 2006-07-20 06:26:46
On 7/20/06, Loïc Joly <loic.joly_at_[hidden]> wrote:
> Hello,
>
> When I run the example code of topo_sort.cpp in the BGL examples folder,
> it works perfectly. However, if I replace in this example:
>
> typedef adjacency_list<vecS, vecS, directedS,
> property<vertex_color_t, default_color_type> > Graph;
>
>
> By:
>
>
> typedef adjacency_list<listS, listS, directedS,
> property<vertex_color_t, default_color_type,
> property<vertex_index_t, int > >
> > Graph;
>
>
> It compiles, but during execution, some assert occurs.
<snip>
> Does anybody have any idea of what the problem might be ?
>
> Best regards,
>
> --
> Loïc
Hi Loïc,
Did you initialize the vertex index map? If you're using a std::vector
to store the vertices, you get a vertex index map for free, but if you
use anything else, (a std::list, for example) you must actually go
through all of the vertices and set their index, like so:
property_map<graph_t, vertex_index_t>::type index = get(vertex_index, G);
graph_traits<graph_t>::vertex_iterator vi, vend;
graph_traits<graph_t>::vertices_size_type cnt = 0;
for(tie(vi,vend) = vertices(G); vi != vend; ++vi)
put(index, *vi, cnt++);
Regards,
Aaron
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