Boost logo

Boost Users :

Subject: Re: [Boost-users] a vector of subgraphs
From: fabricio (fabricio.olivetti_at_[hidden])
Date: 2009-04-08 10:53:34


Ok, but it still won't work for me.

Let me rephrase my problem:

I have a certain Graph g and I must create several subgraphs from it.
In order to create a subgraph I must declare:

typedef subgraph<adjacency_list> Graph;
Graph g;

and to create the proper subgraphs from g it must be done:

Graph& g1 = g.subgraph();

where the subgraph method returns a Graph&.

The problem is that I must have "n" different subgraphs and I must
have a way to iterate through them. So ideally I should have:

vector< Graph& > subg;

subg.resize(n);
for (i=0;i<n;++i )
    subg[i] = g.subgraph();

I guess the use of the reference is necessary so when I insert an edge
on one of the graphs it reflects on every subgraph.

best regards,
Fabricio

On 8 abr, 00:57, "Damian Coventry" <Damian.Coven..._at_[hidden]>
wrote:
> Agree with James, shared_ptr can help here...
>
> typedef subgraph<adjacency_list> Graph;
> typedef shared_ptr<Graph> GraphPtr;
> typedef vector<GraphPtr> Graphs;
>
> Graphs graphs;
> graphs.push_back(GraphPtr(new Graph));
>
> or perhaps
>
> Graphs graphs;
> graphs.resize(2);
>
> graphs[1].reset(new Graph);
> graphs[1]->DoStuff();
>
> graphs[0] = GraphPtr(new Graph);
> graphs[0]->DoStuff();
>
> ~Damian();
>
>
>
>
>
> > -----Original Message-----
> > From: boost-users-boun..._at_[hidden] [mailto:boost-users-
> > boun..._at_[hidden]] On Behalf Of fabricio
> > Sent: Wednesday, 8 April 2009 2:54 p.m.
> > To: boost-us..._at_[hidden]
> > Subject: Re: [Boost-users] a vector of subgraphs
>
> > oh sorry, forgot to mention, after
>
> > vector< Graph& > subG;
>
> > I should have something like:
>
> > subG.resize(2);
> > subG(0) = G.subgraph();
>
> > and subgraph() returns a Graph&
>
> > On 7 abr, 21:04, "James C. Sutherland" <James.Sutherl..._at_[hidden]>
> > wrote:
> > > On Apr 7, 2009, at 4:59 PM, fabricio wrote:
>
> > > > typedef subgraph< adjacency_list > Graph;
>
> > > > Graph G;
>
> > > > what I want is to create a:
>
> > > > vector< Graph& > subG;
>
> > > > but the usage of & here is illegal.
>
> > > Why not use pointers?
> > >         vector<Graph*> subG;
> > > or
> > >         vector< boost::shared_ptr<Graph> > subG;
> > > _______________________________________________
> > > Boost-users mailing list
> > > Boost-
> > us..._at_[hidden]http://lists.boost.org/mailman/listinfo.cgi/boost-
> > users
> > _______________________________________________
> > Boost-users mailing list
> > Boost-us..._at_[hidden]
> >http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
> * Scanned by MailMarshal - Marshal's comprehensive email content security solution. Download a free evaluation of MailMarshal atwww.marshal.com*
> _______________________________________________
> Boost-users mailing list
> Boost-us..._at_[hidden]http://lists.boost.org/mailman/listinfo.cgi/boost-users


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