|
Boost Users : |
From: Douglas Paul Gregor (gregod_at_[hidden])
Date: 2004-03-31 13:52:32
On Wed, 31 Mar 2004, Jeremy Siek wrote:
> > #include <less_than_10_graph_headers>
> > ...
> > digraph<some_node_type,some_edge_context_type> g;
> > g << "vertex" << make_pair("vertex",
> > "implicit_vertex");
> > g.add_edge("brother", "sister", "sibling");
> > if(g.find(make_pair("brother", "sister")))
> > related = true;
>
> Perhaps this is a good place to start. Could you
> explain each of the above lines of code. Then
> we can compare to an implementation in the current BGL
> and pinpoint problem areas.
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.
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.
Doug
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