
On Wed, 14 Jul 2010, Adam Spargo wrote:
Any tips on the best way to access a subgraph - ideally without the memory overhead of copying the subgraph to a new object.
I want to pass each component of my graph to an algorithm separately, but in some cases the original graph will only have a single or a few component(s), in other cases there will be many.
Maybe I will do it differently depending on how many components I have.
Any tips welcome.
There is a subgraph class in BGL, and also filtered_graph. Are the subgraphs you're working with induced subgraphs (i.e., you do not selectively remove edges other than by filtering out their endpoints)? The subgraph class seems to make the subgraphs look more like normal graphs, while filtered_graph is probably much simpler (it doesn't update num_vertices() to match the subgraph size, for example). If you're passing in something like the connected components of a graph individually, that is an induced subgraph and so either of those classes will work directly. -- Jeremiah Willcock