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).
Cheers,
Jeremy
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
tarjei> #include
tarjei>
tarjei> using namespace boost;
tarjei>
tarjei> struct Types
tarjei> {
tarjei> typedef adjacency_list property,
tarjei> property property > > GraphType;
tarjei>
tarjei> typedef std::vector ColorVec;
tarjei> typedef color_traits 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@lists.boost.org
tarjei> http://lists.boost.org/mailman/listinfo.cgi/boost-users
tarjei>
----------------------------------------------------------------------
Jeremy Siek http://php.indiana.edu/~jsiek/
Ph.D. Student, Indiana Univ. B'ton email: jsiek@osl.iu.edu
C++ Booster (http://www.boost.org) office phone: (812) 855-3608
----------------------------------------------------------------------