[Graph] edge list cache
Hello all, I'm working on implicitly defined graphs using the graph boost library. The out_edges function (for example) generates the list of out edges on the fly and returns a shared_container_iterator. Creating this list takes a non-trivial amount of time and so I'd like to cache the result of out_edges so that future calls don't duplicate. But I'm not sure how to do this and still fit within the "BGL way." My first instinct was to add the cache as a member of the graph. But this means that out_edges has to take a non-const reference so that it can update the graph and this causes problems for filtered_graph and reverse_graph. Right now I'm toying with making my cache global and keyed to the address of the graph but this seems inelegant. Anyone have any suggestions? -krish
boost-users-bounces@lists.boost.org <> wrote:
Hello all,
I'm working on implicitly defined graphs using the graph boost library. The out_edges function (for example) generates the list of out edges on the fly and returns a shared_container_iterator. Creating this list takes a non-trivial amount of time and so I'd like to cache the result of out_edges so that future calls don't duplicate.
But I'm not sure how to do this and still fit within the "BGL way." My first instinct was to add the cache as a member of the graph. But this means that out_edges has to take a non-const reference so that it can update the graph and this causes problems for filtered_graph and reverse_graph.
Right now I'm toying with making my cache global and keyed to the address of the graph but this seems inelegant.
Anyone have any suggestions?
-krish _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Have you considered making the cache a mutable member of the graph? This would allow you to update the cache, even if you have a constant reference to the graph.
On 10/18/07, Andrew Holden
boost-users-bounces@lists.boost.org <> wrote:
My first instinct was to add the cache as a member of the graph. But this means that out_edges has to take a non-const reference so that it can update the graph and this causes problems for filtered_graph and reverse_graph.
Have you considered making the cache a mutable member of the graph? This would allow you to update the cache, even if you have a constant reference to the graph.
Hehe. Ask an easy question, get an easy answer. Thanks Andrew! -krish
participants (2)
-
Andrew Holden
-
Krishna Roskin