[BGL] how to extract subgraph from existing graph?

I've got an overall adjacency_list built and ran connected_componets on it.
From this output, I want to do more analysis on the subgraphs found.
Is there a slick way to create a new sub adjacency_list by just giving the subset of vertex IDs? template <class EdgeIterator> adjacency_list(EdgeIterator first, EdgeIterator last, vertices_size_type n, edges_size_type m = 0, const GraphProperty& p = GraphProperty()) This looks like the closest one but it requires redefining the edges? Thanks!

template <typename VertexIterator> subgraph<Graph>& create_subgraph(VertexIterator first, VertexIterator last) "Creates a subgraph object with the specified vertex set. The edges of the subgraph are induced by the vertex set. That is, every edge in the parent graph (which is this graph) that connects two vertices in the subgraph will be added to the subgraph." After further digging.....I think subgraph is what I wanted. So I changed everything to a subgraph and ran connected_components on it.
From the result, I've isolated the vertices in the original graph that I am interested in.
I'm thinking the next step is to create a new container and place the desired vertices in it so that I can supply the first and last iterator. Is there a special type of container? Or just a standard vector will work? Thanks!

2007/1/4, Ferng, Andrew D
template <typename VertexIterator> subgraph<Graph>& create_subgraph(VertexIterator first, VertexIterator last) [snip] After further digging.....I think subgraph is what I wanted. So I changed everything to a subgraph and ran connected_components on it. From the result, I've isolated the vertices in the original graph that I am interested in.
I'm thinking the next step is to create a new container and place the desired vertices in it so that I can supply the first and last iterator. Is there a special type of container? Or just a standard vector will work?
Yes, a vector will work. Another idea is to use a filter-iterator on the old vertex-list, where the predicate uses the property map you received from connected_components algorithm. HTH, Stephan

Vector is working great.
When I have time, I'll look into using filter-iterator.
Thanks!
-----Original Message-----
From: Stephan Diederich [mailto:stephan.diederich@googlemail.com]
Sent: Friday, January 05, 2007 1:54 AM
To: boost-users@lists.boost.org
Subject: Re: [Boost-users] [BGL] how to extract subgraph from existing
graph?
2007/1/4, Ferng, Andrew D
template <typename VertexIterator> subgraph<Graph>& create_subgraph(VertexIterator first, VertexIterator last) [snip] After further digging.....I think subgraph is what I wanted. So I changed everything to a subgraph and ran connected_components on it. From the result, I've isolated the vertices in the original graph that
I am interested in.
I'm thinking the next step is to create a new container and place the desired vertices in it so that I can supply the first and last iterator. Is there a special type of container? Or just a standard vector will work?
Yes, a vector will work. Another idea is to use a filter-iterator on the old vertex-list, where the predicate uses the property map you received from connected_components algorithm. HTH, Stephan _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
Ferng, Andrew D
-
Stephan Diederich