Hi Erik,
Here are a couple examples files to look at:
example/edge_property.cpp
example/vertex-name-property.cpp
also, around page 50 of the BGL book discusses this.
There are basically two ways to initialize the internal property data. One
way is to create a property object (as shown in edge_property.cpp) and
pass that into add_edge or add_vertex. The other way is to just use the
normal add_edge/add_vertex and then use the operator[] or put() with the
correct property map to assign values.
Cheers,
Jeremy
On Mon, 24 Jun 2002, Erik Arner wrote:
yg-boo>
yg-boo> Hi, I'm just starting to learn how to use BGL, and have a few questions.
yg-boo> Help would be much appreciated.
yg-boo>
yg-boo> I'm currently trying to understand the add_vertex function where
yg-boo> properties can be assigned to the vertices as the graph is constructed.
yg-boo> The only info I've managed to find on the website is this:
yg-boo>
yg-boo> ---------
yg-boo> vertex_descriptor
yg-boo> add_vertex(const VertexProperties& p,
yg-boo> adjacency_list& g)
yg-boo>
yg-boo> Adds a vertex to the graph with the specified properties. Returns the
yg-boo> vertex descriptor for the new vertex.
yg-boo> ---------
yg-boo>
yg-boo> Does anybody have any examples on how to use this? More specifically,
yg-boo> consider the following. I want to construct a graph dynamically, i.e.
yg-boo> the graph will grow and shrink during runtime. Let's say I have a Node
yg-boo> class with one member (which I want to represent as an "internal
yg-boo> property") as follows:
yg-boo>
yg-boo> class Node {
yg-boo> public:
yg-boo> std::string name;
yg-boo> };
yg-boo>
yg-boo> And an Edge class, again with internal properties:
yg-boo>
yg-boo> class Edge {
yg-boo> public:
yg-boo> int weight1;
yg-boo> double weight2;
yg-boo> };
yg-boo>
yg-boo> Then my graph object would look something like this, right?
yg-boo>
yg-boo> typedef adjacency_list
yg-boo> < vecS, vecS, directedS,
yg-boo> property < vertex_name_t, std::string >,
yg-boo> property