Boost logo

Boost Users :

From: Erik Arner (yg-boost-users_at_[hidden])
Date: 2002-06-24 02:39:59


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 <edge_weight_t, int, property <edge_weight2_t, double> > >
Graph;

Where do I go from here? That is, if I have a Node or Edge object in my
hand, with members as specified above, how do I add it to the structure
(provided that additional info is available regarding which Nodes to
connect with the Edge)?

I would be very grateful for any help on this. Also, pointers to good
(online) tutorials and documented examples of using the BGL, aside from
the ones on boost.org, would be appreciated.

Thanks,
Erik


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