Boost logo

Boost Users :

Subject: [Boost-users] Boost Graph: determining type of bundled property
From: Trevor Harmon (Trevor.W.Harmon_at_[hidden])
Date: 2010-04-07 18:37:55


Hi,

I wrote some Boost Graph code that uses a custom pointer type as the
vertex:

adjacency_list<vecS, vecS, directedS, Foo*, property<edge_index_t,
std::size_t> >

I now need to expand the graph so that the Foo pointer is just one of
several vertex properties. I assume bundled properties are the way to
go:

http://www.boost.org/doc/libs/1_42_0/libs/graph/doc/bundles.html

I also need my vertices to be of different types (but all as children
of a base type), such that my vertex bundles look something like this:

class BaseVertex { };
class EntryVertex : public BaseVertex { };
class ExitVertex : public BaseVertex { };
class FooVertex : public BaseVertex {
     Foo *foo;
     // ... other properties follow ...
};

My goal is to be able to iterate through the vertices and perform
different actions depending on the type of vertex. (e.g., if vertex
type is EntryVertex do this, if vertex type is ExitVertex do that,
etc.) However, I don't know how to determine a vertex's type. The
bundles document mentions something about
vertex_bundle_type<Graph>::type, but I have no idea how to use this. I
couldn't find any code in the Boost examples that use it, either. Any
tips to get me started?

Also, note that I've added an index property to my graph's edges,
declared explicitly in the adjacency_list instantiation (as seen
above). Would it make sense to convert this to a bundled property as
well, or should I leave it as-is? (I don't think I'll ever need any
edge properties other than the index.)

Thanks,

Trevor


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