Boost logo

Boost Users :

From: Tarjei Knapstad (tarjeik_at_[hidden])
Date: 2003-11-13 04:46:26

I'm trying to implement a DFS visitor and using it with
undirected_dfs_visit, but I'm getting a segfault which relates to the
edge color map. I've made the following test app for illustration:

**************** START CODE ****************

#include <vector>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/undirected_dfs.hpp>

using namespace boost;

struct Types
    typedef adjacency_list<vecS, vecS, undirectedS,
                           property<vertex_color_t, default_color_type>,
                           property<edge_color_t, default_color_type,
                                    property<edge_index_t, int> > > GraphType;

    typedef std::vector<default_color_type> ColorVec;
    typedef color_traits<default_color_type> Color;

int main()
    Types::GraphType g(6);
    Types::ColorVec v_colors(num_vertices(g), Types::Color::white());
    Types::ColorVec e_colors(num_edges(g), Types::Color::white());

    default_dfs_visitor visitor;
    undirected_depth_first_visit(g, 0, visitor,
                                              get(vertex_index, g)),
                                              get(edge_index, g)));

**************** END CODE ****************

The code crashes in undirected_dfs.hpp line 73 the first time it's
trying to access a color from the edge color map:
    EColorValue uv_color = get(edge_color, *ei);

Valgrind turns up a lot of illegal reads/writes to the edge_color_map as
well, so I'm guessing that I've screwed up on the colormap creation.
Could anyone point out my error? Also, is this an error that could be
caught compile time by adding some sort of concept check?

Thanks in advance for any help!



Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at