Boost logo

Boost Users :

From: Doug Gregor (dgregor_at_[hidden])
Date: 2004-08-31 13:34:09


On Aug 31, 2004, at 1:13 PM, Jeffrey Holle wrote:
> // Graph Data accessor methods
> typedef boost::property_map<GraphT, vertex_Datum_t>::type VertexData;
> typedef boost::property_map<GraphT, edge_Datum_t>::type EdgeData;
> const VertexData& getVertexData(void) const {return vertexData_;}
> ...

FWIW, this type of thing will get easier in 1.32.0 because we'll
actually support dropping user-defined classes into adjacency_list,
adjacency_matrix, etc. for vertex and edge properties; but this is the
currently the best solution.

>
> I guess my biggest concern is initializing vertexData_ once, before
> the graph has any data, and keeping it around though the life of the
> graph.
> Is this safe?

It's safe.

> Also, I expect clients of this class to be able to use the operator[]
> method via getVertexData(). Will this work?

Yes, to an extent. The only issue is that const/non-const access to
properties won't be correct, because the types of property_map<GraphT,
foo>::type and property_map<const GraphT, foo>::type are different.

You really don't need to store VertexData in your graph; it should be
very efficient to construct.

        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