[Lemon-user] vector of pointers to FilterNodes
Cherif Mouaouia Bouzid
cherifmouaouia.bouzid at gmail.com
Fri Dec 3 10:51:19 CET 2010
Salam Aleykoum (Peace be upon u)
This is a simple version of what I would like to do:
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)
cout << "Before : " << endl; //State of the FilterNodes before disabling
a node
for(unsigned int i=0; i<3; i++)
{
cout << " FilterNodes " << i << " : " << endl;
for (FilterNodes<ListGraph>::EdgeIt e(*vClusters[i]); e != INVALID;
++e)
cout << " ( " << label[g.u(e)] <<", "<< label[g.v(e)]<<" )"<<
endl;
}
ListGraph::NodeIt v(g); //Let's take the first node in g. In my case, it
is the node 'c'
vClusters[0]->disable(v); // The node 'c' should be disabled only in the
first FilterNodes
cout << "After : " << endl; //State of the FilterNodes after disabling
the node 'c'
for(unsigned int i=0; i<3; i++)
{
cout << " FilterNodes " << i << " : " << endl;
for (FilterNodes<ListGraph>::EdgeIt e(*vClusters[i]); e != INVALID;
++e)
cout << " ( " << label[g.u(e)] <<", "<< label[g.v(e)]<<" )"<<
endl;
}
for(unsigned int i=0; i<L.size(); i++) // FilterNodes are deleted
delete vClusters[i];
OUTPUT:
Before :
FilterNodes 0 :
( b, c )
( a, c )
( a, b )
FilterNodes 1 :
( b, c )
( a, c )
( a, b )
FilterNodes 2 :
( b, c )
( a, c )
( a, b )
After :
FilterNodes 0 :
( a, b )
FilterNodes 1 :
( a, b )
FilterNodes 2 :
( a, b )
Question:
Why is Node 'c' disabled in every FilterNodes ?
Thanks and Regards
Cherif, Algeria
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lemon.cs.elte.hu/pipermail/lemon-user/attachments/20101203/d79046e0/attachment.html>
More information about the Lemon-user
mailing list