[BGL] Newbie problems with property_map interface
Hi, I'm just starting to learn how to use BGL, and have a few questions.
Help would be much appreciated.
I'm currently trying to understand the add_vertex function where
properties can be assigned to the vertices as the graph is constructed.
The only info I've managed to find on the website is this:
---------
vertex_descriptor
add_vertex(const VertexProperties& p,
adjacency_list& g)
Adds a vertex to the graph with the specified properties. Returns the
vertex descriptor for the new vertex.
---------
Does anybody have any examples on how to use this? More specifically,
consider the following. I want to construct a graph dynamically, i.e.
the graph will grow and shrink during runtime. Let's say I have a Node
class with one member (which I want to represent as an "internal
property") as follows:
class Node {
public:
std::string name;
};
And an Edge class, again with internal properties:
class Edge {
public:
int weight1;
double weight2;
};
Then my graph object would look something like this, right?
typedef adjacency_list
< vecS, vecS, directedS,
property < vertex_name_t, std::string >,
property
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
participants (2)
-
Erik Arner
-
Jeremy Siek