|
Boost Users : |
Subject: Re: [Boost-users] Accessing the edge through edge descriptor
From: Christoph (c_p_at_[hidden])
Date: 2011-10-26 02:52:50
Why do you not correct me if i state stupid things?
On Tue, 2011-10-25 at 12:22 +0200, 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".
> 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.
>
> 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?
Because there are no other responses i would like to point out that the
pointer analogy was a bad thing because the descriptor ist not something
like a pointer. The iterator ist something like a pointer but not the
edge descriptor. With
typedef boost::adjacency_list <
boost::listS,boost::vecS,boost::undirectedS> Graph;
typedef boost::graph_traits<Graph> gt;
sizeof (gt::edge_descriptor) is 12 and the
sizeof (gt::edge_iterator) is 4 on my machine
So if you do
Graph g(5);
gt::edge_descriptor a,b,c;
a = b = c = add_edge (0,1,g);
then you actually have 4 distinct copies of edge_descriptors
a = (0,1)
b = (0,1)
c = (0,1)
and the edge added into the graph (0,1)
if you now change one edge_descriptor for instance b:
b.m_source = 2;
then
a = (0,1)
b = (2,1)
c = (0,1)
and the edge added into the graph (0,1)
only one copy (b) is changed. A
remove_edge (a, g);
just removes the edge from the graph. Then we still have
a = (0,1)
b = (2,1)
c = (0,1)
best regards
Christoph
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