Boost logo

Boost Users :

From: Douglas Gregor (doug.gregor_at_[hidden])
Date: 2005-03-09 18:06:18


On Mar 8, 2005, at 7:43 AM, Elvanör wrote:

> Hello everyone,
>
> this is my first post to the list so excuse me if I didn't get some
> concepts right.

Welcome!

> Now to my question: as I am a new user, when I read the documentation
> I decided to use the new bundled properties mechanism rather than the
> old properties map methods. It was recommended in the documentation (I
> would, btw, like to humbly point out that the documentation is not
> very clear on this. The bundled properties explanation page is not
> accessible from the content page and could confuse quite a lot of
> people), and anyway I found that a lot simpler.

Ok, we'll work on that.

> But now I am running into troubles. First, are bundled properties
> applicable to "external properties"?

Bundled properties only apply to internal properties.

> To be honest, I don't really get the difference between internal and
> external properties. Or do I have to use property maps (in the old
> way) for external properties?

Bundled properties don't change external properties at all.

> Second, with bundled properties I have troubles with constructors. I
> created a class myClass, that I will use as a struct for the bundled
> properties. This class contains reference members so it needs a
> constructor better than the default constructor without any arguments.
> Creating a graph with these bundled properties doesn't allow me to use
> another constructor than the default myClass() one, it seems. I think
> it would be very good if I could create an array of myClass and then
> point my Graph object to this array to use it as bundled properties.
> Then I could do all the initialization I want cleanly.

I think that when you add an edge or vertex, you can just pass a
myClass instance before the graph argument, e.g,,

   v = add_vertex(myClass(some_reference), g);

> My last problem is with the depth_first_search() algorithm... and of
> course bundled properties. This algorithm takes a const Graph &; but I
> want to be able to modify (while running the algorithm) the bundled
> properties!! That is the whole point of running this algorithm. I
> don't want to change the structure of the graph (the abstract graph -
> links from vertices to edges, etc), while running the algorithm, of
> course, but I do want to change when I want my bundled properties...
> that is not possible (at least, not without compiler warnings, which I
> don't like :-) due to the fact that depth_first_search expects a const
> graph.

Yeah, this is an annoying problem. We'd like to be able to take either
a const or a non-const graph, but doing so would require two overloads
of the algorithm, which we really can't do (too much code!). I suggest
that you put a non-const reference to the graph from within your
visitor and use that instead of the graph that is passed to the event
functions.

        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