I am not entirely sure, but if you use vecS as a container for your vertices and edges (rather than listS), then the descriptors are just indices, not pointers to memory. This should mean they are still valid if you copy the graph (but I don't know if this is guaranteed). The downside is that if you add vertices/edges, then all your descriptors might become invalid, because of reallocation upon expansion of the vector. I believe there is no optimal solution to this problem. :-(

AS

On 20 April 2016 at 10:40, Emerson Xu <emersonxsu@gmail.com> wrote:
Hi all, 
I have a boost graph copy problem that has been nagging me for a long time. 
My question is, is there anyway that I can construct a graph once, and reuse it multiple times, each time I may mutate the graph a bit. 
I have a class, which creates a boost graph with bundled vertex and edge properties (my own properties, vertices are routers in a network, while edges are logical links between routers). When creating the graph, some helper unordered maps are also created, like mapping from an edge_descriptor to a logical link name, from a router name to a vertex_descriptor, etc. 
Now there are multiple clients calling some method in the class. Current strategy is to construct a new boost graph instance for every client, and run the service on each graph instance. 
Now I want to improve the performance by avoiding constructing the graph for every client ( >100 clients are calling it simultaneously). So I am thinking that we can initialize only one base graph, and make it a copy for every client. 
Then the problem comes, since in the method the client needs use those helper unordered maps, but the data inside the maps are from that original base graph. Even if I use a copy constructor(deep copy) for each graph copy, some graph data is still inconsistent, like the edge_descriptor, for example, I can't use the hashmap with edge_descriptor as key, because this edge_descriptor only points to the memory address of base graph. 

Best,
Emerson

_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users