Boost logo

Boost Users :

Subject: Re: [Boost-users] [graph] getting from vertex item to finding related elements
From: Jeremiah Willcock (jewillco_at_[hidden])
Date: 2010-08-13 14:56:32

On Thu, 12 Aug 2010, Noah Roberts wrote:

> I figure there HAS to be some way to do what I need but I can't think of
> it at the moment. Currently I have a couple of objects called
> "edge_description" and "vertex_description" that are the properties of
> the vertex and edges within a graph. What I want to be able to do is
> retrieve an edge_description from a vertex_description. Graph
> declaration looks like so:
> typedef boost::adjacency_list
> <
> boost::listS
> , boost::listS
> , boost::bidirectionalS
> , vertex_description
> , edge_description
> > system_graph_t;
> The only way I can think of to do this is to make the graph and the
> graph::vertex_descriptor reference members of the vertex_description
> object and manually keep those synchronized (serialization being the
> main issue). I'm disliking that plan.
> Is there a method of construction a graph that would get me what I want?
> So that when I have a pointer or reference to an element in the graph I
> can fetch connected elements?

Why not just work with the descriptors and get the properties from those?
That will make it easy to move around in the graph topological structure
and still access properties easily. If you want to work with properties
directly (the _description objects), you will need to maintain some kind
of mapping from those to BGL vertex and edge descriptors. You could also
create your own custom graph type that uses those description properties
as the vertex and edge descriptors, but that is much more complicated.

-- Jeremiah Willcock

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at