Boost logo

Boost :

From: Wang Weiwei (wwwang_at_[hidden])
Date: 2006-07-18 10:43:39


Hello,

I'm coloring my graph with the following code:

        typedef std::set<std::pair<int, int> > panel_conn_set_t;
        panel_conn_set_t panel_conn_set;

        for(...)
        {
                // get the information of vertices connectivities
                // vertices are referred to with int
                panel_conn_set.insert(std::make_pair([some int], [some int]));
        }

        typedef boost::adjacency_list<boost::vecS, boost::vecS,
                boost::undirectedS,
                // use the default color map
                property<vertex_color_t, default_color_type>,
                no_property> graph_t;
        typedef property_map<graph_t, vertex_color_t>::type vertex_color_map_t;
        typedef boost::graph_traits<graph_t>::vertex_descriptor vertex_descriptor;
        typedef boost::graph_traits<graph_t>::edge_descriptor edge_descriptor;
        typedef boost::graph_traits<graph_t>::vertex_iterator vertex_iterator;
        typedef boost::graph_traits<graph_t>::vertices_size_type vertices_size_type;

        // the only graph object
        graph_t g;

        vertex_color_map_t& vertex_color_map = boost::get(vertex_color, g);

        for(panel_conn_set_t::const_iterator it=panel_conn_set.begin(); it!=panel_conn_set.end(); ++it)
        {
                // using int directly as vecter descriptor
                boost::add_edge((*it).first, (*it).second, g);
        }

        // ****** method A ******
        vertices_size_type num_colors = boost::sequential_vertex_coloring(g, vertex_color_map);

        // ****** method B ******
        std::vector<vertices_size_type> color_vec(boost::num_vertices(g));
        boost::iterator_property_map<vertices_size_type*, vertex_index_map>
                color(&color_vec.front(), get(vertex_index, g));
        vertices_size_type num_colors = boost::sequential_vertex_coloring(g, color);

The code for 'method A' does not compile, but those for 'method B'(borrowed from the BGL doc,
seems to be an exterior property map implementation) works well.

Why? Any help will be appreciated.

Max


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk