Boost logo

Boost Users :

From: Tarjei Knapstad (tarjeik_at_[hidden])
Date: 2003-11-14 05:33:06


On Thu, 2003-11-13 at 17:09, Jeremy Siek wrote:
> Hi Tarjei,
>
> You need to initialize the edge index property map (only the vertex index
> map is automatically initialized, and then only for VertexList=vecS).
>

Hmm, ok, but I still don't quite understand. I thought that initializing
the std::vector holding the colors was sufficient...? To my
understanding an iterator_property_map is just a property map which
iterates through some other container (that can provide a
RandomAccessIterator) actually holding the properties?

Obviously there's some connection I don't quite get here... I also don't
quite understand the EColorValue uv_color = get(edge_color, *ei); call
in undir_dfv_impl. It asks for the edge_color at the edge_descriptor
*ei, but from where?

Anyway, I don't really even need an edge_index property here (or do I?),
it was more or less to try to get this working.

Could you please provide a bit more detailed description of how I should
initialize the edge colormap properly?

Thanks a lot,
Tarjei

>
> On Thu, 13 Nov 2003, Tarjei Knapstad wrote:
>
> tarjei> I'm trying to implement a DFS visitor and using it with
> tarjei> undirected_dfs_visit, but I'm getting a segfault which relates to the
> tarjei> edge color map. I've made the following test app for illustration:
> tarjei>
> tarjei> **************** START CODE ****************
> tarjei>
> tarjei> #include <vector>
> tarjei> #include <boost/graph/adjacency_list.hpp>
> tarjei> #include <boost/graph/undirected_dfs.hpp>
> tarjei>
> tarjei> using namespace boost;
> tarjei>
> tarjei> struct Types
> tarjei> {
> tarjei> typedef adjacency_list<vecS, vecS, undirectedS,
> tarjei> property<vertex_color_t, default_color_type>,
> tarjei> property<edge_color_t, default_color_type,
> tarjei> property<edge_index_t, int> > > GraphType;
> tarjei>
> tarjei> typedef std::vector<default_color_type> ColorVec;
> tarjei> typedef color_traits<default_color_type> Color;
> tarjei> };
> tarjei>
> tarjei> int main()
> tarjei> {
> tarjei> Types::GraphType g(6);
> tarjei>
> tarjei> add_edge(0,1,g);
> tarjei> add_edge(1,2,g);
> tarjei> add_edge(2,3,g);
> tarjei> add_edge(2,4,g);
> tarjei> add_edge(4,5,g);
> tarjei>
> tarjei> Types::ColorVec v_colors(num_vertices(g), Types::Color::white());
> tarjei> Types::ColorVec e_colors(num_edges(g), Types::Color::white());
> tarjei>
> tarjei> default_dfs_visitor visitor;
> tarjei> undirected_depth_first_visit(g, 0, visitor,
> tarjei> make_iterator_property_map(&v_colors[0],
> tarjei> get(vertex_index, g)),
> tarjei> make_iterator_property_map(&e_colors[0],
> tarjei> get(edge_index, g)));
> tarjei> };
> tarjei>
> tarjei> **************** END CODE ****************
> tarjei>
> tarjei> The code crashes in undirected_dfs.hpp line 73 the first time it's
> tarjei> trying to access a color from the edge color map:
> tarjei>
> tarjei> EColorValue uv_color = get(edge_color, *ei);
> tarjei>
> tarjei> Valgrind turns up a lot of illegal reads/writes to the edge_color_map as
> tarjei> well, so I'm guessing that I've screwed up on the colormap creation.
> tarjei> Could anyone point out my error? Also, is this an error that could be
> tarjei> caught compile time by adding some sort of concept check?
> tarjei>
> tarjei> Thanks in advance for any help!
> tarjei>
> tarjei> Regards,
> tarjei> --
> tarjei> Tarjei
> tarjei>
> tarjei>
> tarjei> _______________________________________________
> tarjei> Boost-users mailing list
> tarjei> Boost-users_at_[hidden]
> tarjei> http://lists.boost.org/mailman/listinfo.cgi/boost-users
> tarjei>
>


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