Boost logo

Boost Users :

Subject: Re: [Boost-users] [BGL] property_map for or with bundled properties
From: Jeremiah Willcock (jewillco_at_[hidden])
Date: 2010-11-12 10:49:33


On Fri, 12 Nov 2010, Cedric Laczny wrote:

> Hi,
>
> I was trying to use an iterator_property_map with bundled properties and ran
> into difficulties. For those having thought about that, I want to post my
> solution and also address a question.
>
> Let's start with the solution:
> Imagine, one uses bundled properties and has defined the following
> EdgeProperty:
> struct EdgeProperty{
> int edge_index;
> }
> and
> typedef adjacency_list<...> Graph;
>
> Whether this makes sense or not may also be discussed but is not important for
> the demonstration purposes.
>
> So if you now want to define an iterator_property_map that is based on the
> edge_index, it get's IMHO a bit more complicated than using internal
> properties:
> typedef property_map<Graph, int EdgeProperty::*>::type EdgeIndexMap;
> EdgeIndexMap e_index = get(&EdgeProperty::edge_index,g);
> std::vector< int > flag_vec(num_edges(g), 0);
> // Create the external property map
> iterator_property_map< std::vector< int >::iterator, EdgeIndexMap >
> flags(flag_vec.begin(), e_index);
>
> versus an example using vertex_index that is automatically created when using
> vecS for the vertices:
> typedef property_map<Graph, vertex_index_t>::type VertexIndexMap;
> VertexIndexMap v_index = get(vertex_index, g);
> std::vector< int > flag_vec(num_vertices(g), 0);
> // Create the external property map
> iterator_property_map< std::vector< int >::iterator, VertexIndexMap >
> flags(flag_vec.begin(), v_index);
>
> So far for the solution.
>
> I have also a question in this place:
> What does the "EdgeProperty::*" exactly do? The EdgeProperty is of course the
> bundle, but what about the "::*" is this some sort of RegEx for "all
> attributes of this bundle"?
> I looked at the code in properties.hpp and was able to generally understand
> the idea, but it did not become clear to me why the "::*" is needed.

"int EdgeProperty::*" is a C++ type (a pointer to member variable) that is
a pointer to an int member of the class EdgeProperty. As a bundled
property, a variable of that type can point to any bundled property of
type int within a graph whose edge bundle type is EdgeProperty.

-- Jeremiah Willcock


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