Boost logo

Boost :

From: Douglas Gregor (doug.gregor_at_[hidden])
Date: 2007-07-26 20:26:31

On Jul 26, 2007, at 1:34 PM, Huseyin Akcan wrote:
> I guess my main question is does using descriptors have advantages
> over iterators in the design or the runtime of the graph library?
> Also are there other specific reasons to use descriptors that you
> experienced?
> Any insight on this issue would be appreciated.

The reason we need descriptors in the Graph library is that there are
many different ways to iterate over a particular data structure, all
with different iterator types, but we need a common type to talk
about what those iterators refer to... that's why all of the
iterators into a graph (say, into the adjacency_list) point to vertex
or edge descriptors. That extra level of indirection allows us to
talk about vertices or edges in the abstract sense, regardless of the
way that we found those vertices or edges (enumerating out-edges, in-
edges, neighbors, etc.)

Now, we have run into similar problems with descriptors not always
being the best answer for inserting or removing values from
containers. To get around this, there are a few extra overloads for
routines such as remove_out_edge (in the adjacency_list) that accept
out_edge_iterators rather than edge descriptors. The iterator-based
versions are more efficient, but the descriptor-based versions are
more flexible (since they can take the descriptors returned from
other kinds of iterators).

        - Doug

Boost list run by bdawes at, gregod at, cpdaniel at, john at