Boost logo

Boost Users :

Subject: [Boost-users] boost::filtered_graph filtering on vertex color... if I only had a colormap
From: Brian Davis (bitminer_at_[hidden])
Date: 2017-11-17 00:37:28


Lets say I have a graph g (of type graph_t)

and a color map (boy I wish I had a colormap):

typedef boost::property_map<graph_t, boost::vertex_color_t>::type
color_map_t;

or is it?

auto indexmap = boost::get(boost::vertex_index, g);
auto colors =
boost::make_vector_property_map<boost::default_color_type>(indexmap);

or maybe?

auto indexmap = boost::get(boost::vertex_index, g);
auto colors =
boost::make_vector_property_map<boost::vertex_color_t>(indexmap);

or possibly some goop found on the internet?

boost::make_iterator_property_map(color_map.begin(),
boost::get(boost::vertex_index, data_->g), color_map[0])

or other internet goop?

typedef boost::property_map<GraphType, boost::vertex_color_t>::type
color_map_t;
color_map_t colorMap;
boost::color_map(colorMap))

or other internet goop??

std::vector<int> colorMap(num_vertices(g), boost::white_color);

so confused... (certainly not surprised why bgl is not a part of stl) Can
someone help explain the various types and ways of specifying colormaps and
the logic for each way and means?

and a function (if I could get that far without VS syntax highlighter going
bonkers and gobs of compiler errors.. you know the type):

make_pretty(g, colormap )

which colors the graph colormap

and a filter struct for boost::filtered_graph<Graph, EdgePredicate,
VertexPredicate> (where I wonder why if I only want to filter vertices I
have to set boost::keep_all for EdgePredicate... sigh... I know the
answer... and also know how long it found me to find/figure out
boost::keep_all - and if you are looking for boost::keep_all and found it
here... your welcome ;-) )

and modifying (probably incorrectly) boost::filtered_graph example to:

template <typename ColorMap>
struct vertex_color_filter_eq {
    vertex_color_filter_eq() { }
    vertex_color_filter_eq(ColorMap colormap/*, boost::default_color_type
c*/) : m_colormap(colormap)/*, m_c(c)*/ { }

    template <typename Vertex>
    bool operator()(const Vertex& v) const {
        return 0 < get(m_colormap, v);
        //return c < get(m_colormap, v);
    }
    ColorMap m_colormap;
    //boost::default_color_type m_c;
};

auto indexmap = boost::get(boost::vertex_index, g);
auto colors =
boost::make_vector_property_map<boost::default_color_type>(indexmap);

// some where here I would call make_pretty(g, colors)

typedef property_map<graph_t, boost::vertex_color_t>::type ColorMap_t;
vertex_color_filter<ColorMap_t> filter(colors);

// boost::filtered_graph<graph_t, boost::keep_all, VertexPredicate>
boost::filtered_graph<graph_t, boost::keep_all, vertex_color_filter> fg(g,
filter);

// Later say if I could get it compile and better if it compiled and worked
I could move on and

auto color = boost::red_color;

typedef property_map<graph_t, boost::vertex_color_t>::type ColorMap_t;
vertex_color_filter<ColorMap_t> filter(colors, color);
boost::filtered_graph<graph_t, boost::keep_all, vertex_color_filter> fg(g,
filter);

Maybe if I color them yellow, I can then reach the wizard pull back the
curtain and ask how to create a color map... If I only had a color map.



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