|
Boost Users : |
From: Jeremy Siek (jsiek_at_[hidden])
Date: 2004-03-31 14:18:59
Hi Doug,
On Mar 31, 2004, at 1:52 PM, Douglas Paul Gregor wrote:
> The only thing I've ever found complex in the BGL is actually forming a
> graph type out of adjacency_list. Every single time I need a graph I
> have
> to read through the adjacency_list documentation to figure out what to
> do,
> although often I just copy the typedef from somewhere else. Simplified
> graph adaptors could really help here.
Right. In particular, the way internal properties are dealt with is
rather
cumbersome.
> There's a lot we could do in the way of syntactic sugar. For instance,
> I'd
> love to be able to easily loop over the edges in a graph without
> dealing
> with iterators directly:
>
> Graph g;
> for(Graph::vertex_descriptor u, v; (u, v) = G; ) {
> // do something with edge (u, v)
> }
>
> The same thing can be applied to, e.g., adjacent vertices:
>
> for(Graph::vertex_descriptor v; v = adj(u, g); ) {
> // v is adjacent to u
> }
>
> Since vertex descriptors tend to be iterators or indices, this could be
> implemented just as efficiently as the corresponding iterator loop, but
> it's a simpler idiom.
Looks neat. How would that be implemented? I hope it doesn't require
storing something in the graph object itself that keeps track of
the progress of the iteration.
BTW, for those who like macros, there's
boost/graph/iteration_macros.hpp.
Cheers,
Jeremy
_______________________________________________
Jeremy Siek <jsiek_at_[hidden]>
http://www.osl.iu.edu/~jsiek
Ph.D. Student, Indiana University Bloomington
Graduating in August 2004 and looking for work
C++ Booster (http://www.boost.org)
_______________________________________________
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