|
Boost Users : |
Subject: Re: [Boost-users] Accessing the edge through edge descriptor with bundled properties
From: Jeremiah Willcock (jewillco_at_[hidden])
Date: 2011-10-26 15:58:29
On Tue, 25 Oct 2011, Christoph wrote:
> Hello,
>
> this is an interesting example for me as a beginner. As far as i
> understand the concept of a "descriptor" it does not matter if you use
> descriptors for some edges or copies of these descriptors in a container
> like "border_edge".
Yes -- copying a descriptor keeps the same value and is valid to refer to
the same vertex or edge.
> Am i right? That is why we call it descriptor. It describes the edge but
> it is not the edge, like a pointer points to an object but is not the
> object. So it doesn't matter if we use descriptor A, B or C if they all
> describe the same edge.
Yes, but there often isn't an object that you can say "is" the edge. An
edge might logically be two entries in different vectors, and the edge
descriptor is an index into those vectors; what is the edge in that case?
> Are there any situations in which i have to care about the copies? For
> instance what if I delete the edge of descriptor A (while B and C being
> descriptors of the same edge). Will the descriptors B and C become
> invalid in the way that they both will point to some kind of "Null"-edge
> or do I have to deal with some kind of undefined behaviour?
That depends on the graph type, but descriptors are typically not
reference counted, so if you delete an edge with descriptor e then any
copies of e will be invalid as well. In fact, descriptors for other edges
might also become invalid; there is a section in the adjacency_list
documentation about those rules. In that way, descriptors are somewhat
like pointers; there is a spectrum of descriptor types between values that
are the edge and don't point to anything else (such as grid_graph edge
descriptors) and edge descriptors that are index values or pointers (such
as adjacency_list or compressed_sparse_row_graph descriptors).
-- Jeremiah Willcock
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