|
Boost Users : |
Subject: Re: [Boost-users] [boost] Create Graph in Function
From: Sandeep Gupta (gupta.sandeep_at_[hidden])
Date: 2009-10-28 21:57:30
On Wed, Oct 28, 2009 at 6:12 PM, James Thunes <j.thunes_at_[hidden]> wrote:
> Perhaps an easy answer, but I am working on adding a boost graph to an
> existing code. I would like to create the graph in a function (not main) and
> then read/modify it in a separate function. I am unsure as to what I need to
> pass between the functions to allow this to work.
>
> In other words, I am able to correctly create the graph in a function and
> modify as necessary. This function will be called many times as the code
> runs and it is inefficient to recreate the graph every time. I want to
> create the graph once when the code is run and pass the created graph to the
> function.
>
> Due to the structure of the code (mostly Fortran), I can not define the
> graph in the main function of the code.
>
> My graph is defined as:
> adjacency_list<vecS, vecS, bidirectionalS, no_property, EdgeProperty>
> Graph;
>
> Thank you for any help you can give,
> James
>
> Try shared_ptr. Something like.
>
function(){
typedef adjacency_list<vecS, vecS, bidirectionalS, no_property,
EdgeProperty> Graph;
shared_ptr< Graph > gptr( new Graph(n) );
return gptr;
}
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