Boost logo

Boost Users :

From: Chris Russell (cdr_at_[hidden])
Date: 2003-09-01 15:33:35

Tarjei, I do quite a bit of this sort of thing in my project. Here's what I

Enumerate all the vertices in the source graph. For each source vertex:
- create new vertex in target graph
- save new target vertex descriptor in temporary
map<vertex_descriptor_t/*source*/, vertex_descriptor_t/*target*/>
- manually initialize target vertex properties

Enumerate all the edges in the source graph. For each source edge:
- create a new edge in the target (this is where the temporary map comes
into play)
- manually initialize target edge properties

Nothing fancy but it works and is efficient.

- Chris

P.S. you could stuff this algorithm into an operator+ implementation if it's
aesthetically pleasing to you ;-)

"Tarjei Knapstad" <tarjeik_at_[hidden]> wrote in message
> On Mon, 2003-09-01 at 18:25, Tarjei Knapstad wrote:
> > I need to add/copy one graph into another, both completely connected,
> > and then create an edge between one vertex in the original graph and a
> > vertex in the one copied into it. The edge/vertex properties needs to be
> > copied as well, and this needs to be fairly efficient.
> >
> > The new edge is straightforward, but is there any functionality for the
> > copy/add operation? (Something like an "add_component" algorithm I
> > guess...) To my understanding both the copy_graph and copy_component
> > algorithms both replace all the content in the target graph.
> >
> > If not, what would be the most efficient way to solve this sort of
> > problem?
> >
> Forgot to say that my graph type is
> adjacency_list<vecS, vecS, undirectedS, VertexProperties,
> EdgeProperties>
> where Vertex/EdgeProperties are a set of defined properties.
> Regards,
> --
> Tarjei Knapstad

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at