...
Details:
I am using a filtered_graph over Boost::adjacency_list as my graph type (Graph_t). The vertex_iterator (from graph_traits<Graph_t> .. provides iterator range to iterate over graph vertices. I have to assign each graph vertex an id (using property_maps) and group them together by applying filter_iterator over
vertex iterator.
example: suppose I want to create 4 subgroups of vertices. So I create a filter predicate which is passed to filter iterator which gives me iterators <fbegin, fend> satisfying the predicate.
For FOUR such groups, I get 4 pairs of filter iterators.
A vector stores such filter_iterator pairs.
std::vector < pair <filter_iterator_t, filter_iterator_t> > my_vector //stores iterator pair.
Here is the code:
vertex_iterator vbegin, vend;
boost::tie(vbegin, vend) = boost::vertices(G);
for (int i=0; i<4; ++i)
{
//for each i, create a filter_pred object
my_filter_pred <Graph> filter_pred(G, i)
//now create begin and end filter iterators as follows
auto fbegin = boost::make_filter_iterator< my_filter_pred<Graph>,
vertex_iterator> (filter_pred, vbegin, vend)
auto fend = boost::make_filter_iterator< my_filter_pred<Graph>,
vertex_iterator> (filter_pred, vend, vend)
//fbegin, fend are of type filter iterator
//insert the iterator pair into vector
my_vector.push_back( std::make_pair (fbegin, fend) );
}
The predicate is below :
template<typename Graph>
struct my_filter_pred {
public:
my_filter_pred() { }
my_filter_pred(Graph& _G, int _value) : G(_G), value(_value) { }
template<typename vertex_t>
bool operator() (vertex_t vertex) {
//get property "p" of vertex in graph G
auto p = get (mypropertytype, vertex, G);
return (p.val == value);
}
private:
Graph& G;
}
ERROR :
error: implicitly generated assignment operator cannot copy:
reference member "my_filter_pred <Graph>::G [with ... ]"
I tried to provide my own assignment operator as below:
my_filter_pred& operator=(const my_filter_pred& other) {
if (this != &other)
G = other.G;
return *this;
}
But it gave the same icpc error for actual typedef graph which is below :
error: implicitly generated assignment operator cannot copy:
" implicit generation of boost::filtered_graph_base<Graph_t> " ....
Please help what should I do in this case to work.
main motive : is to have a container which stores <iterator, iterator> pair which satisfies a predicate. Filter iterator was the best choice i could have to apply different filter predicate to same vertex_iterator range vbegin, vend;
Thanks
Aniket Pugaonkar
Aniket Pugaonkar