Dear all,
I am quite new to the lemon community.

I've been trying to create a NodeFilter adapter to filter some of the  nodes, 
and then iterate through the remaining nodes. I've come across a bug which I 
simply can't understand and would appreciate your help. I use lemon 1.2.2 
(stable).

When running the following code:

SmartGraph g;
for(int i = 0; i < 5; i++) { g.addNode(); }
SmartGraph::NodeMap<bool> filter(g, true);
FilterNodes<SmartGraph> *filtered_g = new FilterNodes<SmartGraph>(g, filter);
for(FilterNodes<SmartGraph>::NodeIt n(*filtered_g); n != INVALID; ++n)
    cout << "I am in node " << g.id(n) << endl;


I get the expected result. HOWEVER, when I replace the line that defines 
filtered_g with:
FilterNodes<SmartGraph> *filtered_g = foo(g);

with:
FilterNodes<SmartGraph>* foo(SmartGraph& g)
{
    SmartGraph::NodeMap<bool> filter(g, true);
    return new FilterNodes<SmartGraph>(g, filter);
}

I get unexpected results (sometimes segmentation errors, sometimes the iterator 
runs only on a subset of the vertices - depends on the input graph I generate).
Can someone please explain to me what's going on here? Shouldn't both pieces of 
code be completely equivalent?

Thanks much,
Pete
_______________________________________________
Lemon-user mailing list
[email protected]
http://lemon.cs.elte.hu/mailman/listinfo/lemon-user

Reply via email to