|
Boost Users : |
From: Aaron Windsor (aaron.windsor_at_[hidden])
Date: 2007-06-04 22:06:13
On 6/4/07, David A. Greene <greened_at_[hidden]> wrote:
> Hi everyone,
>
> I'm having trouble with BGL's (Boost 1.33.1) topological sort. In my
> source code I have this simple call:
>
> std::vector<my_vertex> rev_topo_order;
> topological_sort(*t, std::back_inserter(rev_topo_order));
>
> Here "t" is an iterator to a list of graphs declared like this:
>
> typedef boost::adjacency_list<
> boost::setS, // Out edge list type
> boost::listS, // Vertex list type
> boost::bidirectionalS, // Needed for DAG, topo sort
> my_property_bundle // Vertex properties
> > my_graph_type;
>
<snip>
Hi Dave,
The error you're seeing (both in your code and the example you
included) is caused because the topological sort algorithm expects a
vertex index map - if you don't provide one as a parameter, it uses
whatever interior vertex index map the graph has. Even if you declare
a vertex index map as an interior property of the graph, you still
have to initialize it by mapping each vertex to an integer in the
range 0..num_vertices(g)-1. See #5 in the BGL FAQ
(http://www.boost.org/libs/graph/doc/faq.html) for an example of how
to initialize one.
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