Boost logo

Boost Users :

Subject: Re: [Boost-users] boost::filtered_graph filtering on vertex color... if I only had a colormap
From: Brian Davis (bitminer_at_[hidden])
Date: 2017-11-18 18:46:07


Since my graph, g, of type graph_t is:

    typedef boost::property <boost::edge_weight_t, float > edge_properties;
    //typedef boost::property<boost::vertex_first_name_t, std::string>
vertex_properties;

    typedef boost::property<boost::vertex_index1_t, size_t,
        boost::property<boost::vertex_component_t, int> > vertex_properties;

    typedef boost::property<boost::vertex_color_t,
boost::default_color_type> color_properties;

    //typedef boost::property<boost::vertex_index1_t, size_t,
    // boost::property<boost::vertex_component_t, int,
    // boost::property<boost::vertex_color_t,
boost::default_color_type>> > vertex_properties;

#define USE_BOOST_GRAPH_VECS

    typedef boost::adjacency_list<
#ifdef USE_BOOST_GRAPH_VECS
        // !NOTE: see:https://stackoverflow.com/
questions/15649166/bgl-depth-first-search-error-with-color-map#15654246
        // This is the important part of the "sea of errors".
        // Only adjacency_list that have vecS as the VertexList
        // template parameter have a default internal vertex_index
        // property and this property is used by the default color
        // map(you are using listS).
        boost::vecS, boost::vecS,
        //boost::vecS, boost::listS,
        //boost::setS, boost::listS,
#else
        // !Note: See http://www.boost.org/doc/libs/1_62_0/libs/graph/doc/
adjacency_list.html
        // Iterator and Descriptor Stability/Invalidation regarding
iterator stability when using
        // the vector and list containers.
        boost::listS, boost::listS,
#endif
        boost::undirectedS,
        //boost::bidirectionalS,
        //boost::no_property,
        vertex_properties,
        edge_properties,
        //color_properties,
        boost::vecS
> graph_t;
    graph_t g;

and is/was created without color properties (color_properties or
vertex_color_t). When trying to create a colormap with:

property_map<graph_t, boost::vertex_color_t>::type colors =
get(vertex_color_t(), g);

the error is generated by VS:

boost-1_60\boost/graph/detail/adjacency_list.hpp(2584): error C2182:
'reference' : illegal use of type 'void'

which is ofcourse not real clear what is generating the error but after
finding the actual offending line 5 lines later in the error console as is
the power of template meta programing. The "illegal use of type 'void'"
error is a result of the graph not having an internal property that can be
accessed by get:

template <class PropertyTag>
property_map<filtered_graph, PropertyTag>::type get(PropertyTag,
filtered_graph& g)

Adding the property internal to the graph by commenting out:

    typedef boost::property<boost::vertex_index1_t, size_t,
        boost::property<boost::vertex_component_t, int> > vertex_properties;

And uncommenting (putting it it place of above):

    typedef boost::property<boost::vertex_index1_t, size_t,
        boost::property<boost::vertex_component_t, int,
            boost::property<boost::vertex_color_t,
boost::default_color_type>> > vertex_properties

The property is now internal and so a vertex colormap can be generated
using:

property_map<graph_t, boost::vertex_color_t>::type colors =
get(vertex_color_t(), g);

However an external colormap could be used:

    typedef std::vector<int> ColorMap_t;
    ColorMap_t colors(num_vertices(g));

    vertex_color_filter_eq<ColorMap_t> filter(colors);

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

Note now the successful attempt to use boost::keep_all and boost::keep_all()



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