[Lemon-user] vector of pointers to FilterNodes

Alpár Jüttner alpar at cs.elte.hu
Fri Dec 3 12:30:25 CET 2010


Dear Cherif,

> Assume a complete graph g with three nodes labelled 'a', 'b' and
> 'c' (a triangle). 
> I would like to construct a vector of pointers to FilterNodes on g. 
> The problem is that when I want to disable a node on one FilterNodes,
> the node is disabled on every FilterNodes. 
> 
> Here is the code:
> 
>     ListGraph::NodeMap<bool> filter(g, true);
>     vector< FilterNodes<ListGraph> * > vClusters; // A vector of
> adresses to FilterNodes on g
>     for(unsigned int i=0; i<3; i++)
>        vClusters.push_back(new FilterNodes<ListGraph> (g,filter) ); //
> Constructing dynamically new FilterNodes (note that every node is
> taken initially)

> [...]
> Question: 
> Why is Node 'c' disabled in every FilterNodes ? 
> 
This is because you use the same NodeMap (filter) for each FilterNodes
adaptor. Note that it is a "virtual graph" thus its behavior immediately
follow the changes in the underlying NodeMap.

To sum up: you have to allocate a separate NodeMap for each of your
FilterNodes if you want them to represent different graphs.

Regards,
Alpar






More information about the Lemon-user mailing list