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);
    
    add_edge(0,1,g);
    add_edge(1,2,g);
    add_edge(2,3,g);
    add_edge(2,4,g);
    add_edge(4,5,g);
    
    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,
                   make_iterator_property_map(&v_colors[0],
                                              get(vertex_index, g)),
                   make_iterator_property_map(&e_colors[0],
                                              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!

Regards,

--
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