On Thu, Jan 20, 2011 at 09:11:52AM -0500, Richard Heck wrote: > On 01/20/2011 12:34 AM, Andre Poenitz wrote: > >On Thu, Jan 20, 2011 at 06:00:27AM +0100, Peter Kümmel wrote: > >>Rich, you know the Graph code much better than me. Is it possible to have > >>real const functions to get pathes, or it is necessary to always set > >>the visited flag in vertices_. Couldn't the calculation be done in one > >>function call which then would be more expensive as consequence. > >It's not needed, it's just a consequence of the current implementation > >IIRC. The 'visited' information should not be part of the 'static' data > >of the graph, but rather a separate temporary structure that's passed > >around as separate parameter. > > > Unfortunately, we seem to use this as if it were static. This is why > there is the clear_visited boolean that gets passed into routines > like getReachable(). See e.g. Converters::importableFormats(). > Perhaps this is just some kind of optimization that could be > removed? It would be less of an issue if the importableFormats were > cached. I don't myself see why we shouldn't do that. We must decide > what formats we can import over and over and over....
There are two instances or so where it is called with clear_visited == true at the begin of a function and several times with ... == false later in the same function. That looks like a case for a local "visited" vector. I haven't check whether there are more complicated occurences, but if the pattern above is the only one used some refactoring seems in order. Andre'