Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2002-09-17 13:09:21


From: "Tim Culver" <tim.gmane_at_[hidden]>

> David Abrahams wrote:
> > From: "Tim Culver" <tim.gmane_at_[hidden]>
> >
> >>Also, I think the convention above might be a good alternative. I
> >>notice that the vertex descriptor does have a default constructor. My
> >>question is, does a default-constructed vertex descriptor act like a
> >>null value, in that it never corresponds to a valid vertex, and two
> >>nulls always compare equal?
> >
> >
> > Definitely not, and it shouldn't.
> > For many graph types, vertex_descriptor is an integer type which is a
> > zero-based index into the graph's vector of vertices. That's important
for
> > efficiency.
>
> Now I understand!

Apparently not. ;-/

> We want to be able to have descriptors without
> constructors.

Nooo, that would be almost useless. Descriptors are runtime entities. You
need to be able to make them.

> Still, this does not prevent writing a function that will generate a
> null-like value. I think this would be a good addition to the library
> for its graph datatypes.
>
> if (vdesc == graph_traits<My_graph>::null_vertex_descriptor()) {
> // vdesc is invalid
> }
>
> Also, the particular case of adjacency_list<listS,listS,...> appears to
> have actual default constructors that initialize something to zero. Can
> I use these as my null generators in this particular case?

No, that's my point. Zero is a valid descriptor value for many
adjacency_lists, which corresponds to the 0th vertex.

-----------------------------------------------------------
           David Abrahams * Boost Consulting
dave_at_[hidden] * http://www.boost-consulting.com


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk