Boost logo

Boost Users :

From: Jeremy Siek (jsiek_at_[hidden])
Date: 2002-06-24 13:45:11


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 <edge_weight_t, int, property <edge_weight2_t, double> > >
yg-boo> Graph;
yg-boo>
yg-boo> Where do I go from here? That is, if I have a Node or Edge object in my
yg-boo> hand, with members as specified above, how do I add it to the structure
yg-boo> (provided that additional info is available regarding which Nodes to
yg-boo> connect with the Edge)?
yg-boo>
yg-boo> I would be very grateful for any help on this. Also, pointers to good
yg-boo> (online) tutorials and documented examples of using the BGL, aside from
yg-boo> the ones on boost.org, would be appreciated.
yg-boo>
yg-boo> Thanks,
yg-boo> Erik
yg-boo>
yg-boo>
yg-boo>
yg-boo>
yg-boo> Info: <http://www.boost.org>
yg-boo> Wiki: <http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl>
yg-boo> Unsubscribe: <mailto:boost-users-unsubscribe_at_[hidden]>
yg-boo>
yg-boo>
yg-boo> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
yg-boo>
yg-boo>

----------------------------------------------------------------------
 Jeremy Siek http://php.indiana.edu/~jsiek/
 Ph.D. Student, Indiana Univ. B'ton email: jsiek_at_[hidden]
 C++ Booster (http://www.boost.org) office phone: (812) 855-3608
----------------------------------------------------------------------


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