On Wed, May 16, 2012 at 11:20 PM, Tobias Pankrath <tob...@pankrath.net> wrote: >> More exotic: >> >> http://svn.dsource.org/projects/dranges/trunk/dranges/docs/recursive.html > > > That looks like a compile time composite pattern and I'd say it's a natural > way to iterate over every form of graph. To be a equivalent to ranges in the > std.algorithm sense, they must also be a good vehicle to implement graph > algorithms effectively. I'd question this for the recursive ranges. How > would you implement Dijkstra with r-ranges?
I don't remember how I did Dijkstra in D. That was 2 years ago (see https://github.com/PhilippeSigaud/dranges/blob/master/graphalgorithm.d ). IIRC That was an algorithm directly acting on the graph, not on a r-range. I have a module to present a graph as a (linear, standard) range, either exploring the graph in a deph-first or breadth-first manner, see: https://github.com/PhilippeSigaud/dranges/blob/master/graphrange.d As for recursive ranges, even two years afterwards I still don't know if exposing a r-range is a good idea or not. The thing is, a r-range preserves the global topology (shape) and as such is awfully near a container. And, as you said, some algorithm do not translate easily into a range function. I haven't think much about it though. I'm still waiting for a definitive word on allocators and seeing the AA implementation to go back to graphs.