Boost logo

Boost Users :

From: Loïc Joly (loic.joly_at_[hidden])
Date: 2006-07-11 11:19:55


Hello,
I'm new to the graph library, but I'm missing some algorithms that I
believe are quite low level, and that I expected to find.

For instance, I'd like to be able to remove nodes from a graph that meet
some criterion. The closest I could find to remove_if was :
- Iterate on each node manually:

for (tie(vi, viend) = boost::vertices(myGraph) ;
        vi != viend;
        ++vi)
{
        if (criterion(vi)
        {
                clear_vertex(*vi, myGraph);
                remove_vertex(*vi, myGraph);
        }
}

But I'm afraid of iterator invalidity

- Filter, copy, swap:

Graph tempGraph;
{
        filtered_graph<Graph, keep_all, Criterion> fg
                (myGraph, criterion);
        copy_graph(fg, tempGraph);
}
copy_graph(tempGraph, myGraph);

Will one of my attempts work ? Is there any other solution I missed ?

Best regards,

-- 
Loïc

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