Boost logo

Boost Users :

Subject: Re: [Boost-users] [BGL] Trying to use subgraph
From: Andrew Sutton (andrew.n.sutton_at_[hidden])
Date: 2009-05-19 13:57:09


>
>
> However, I'm getting a static assertion error that edge_index is an unknown
> property. I had *thought* that an adjacency_list<vecS,vecS> would not have
> that issue, but apparently I was wrong. The page here:
> http://www.boost.org/doc/libs/1_39_0/libs/graph/doc/subgraph.html
> says "we add an edge index property to the adjacency list", but the code
> which follows demonstrates no such thing.

No it does not. As you've figured out, adjacency_list<vecS, vecS>
unfortunately, does not provide a builtin edge_index. As I think about it,
adjacency_list<OEL, VL, D, VP, EP, GP, vecS> /may/ have an edge_index (I'm
using Caps to denote un-fixed parameters). I'm not certain. If you want to
build an edge index into your adjlist, you can do it like this:

typedef property<edge_index_t, size_t> EdgeProp;
typedef adjacency_list<OEL, vecS, D, VP, EdgeProp> Graph;

The distinction between bundled properties and internal properties is still
> a bit mysterious to me. Can anyone shed some light on this?

A bundled property is basically just a stucture or class that you associate
with a vertex or edge. By supplying a class, you can "bundle" a number of
properties together. This is generally thought to be much easier than using
the internal properties (of which there is an example written above).

struct EdgeBundle {
  int distance;
  int resistance;
};

typedef adjacency_list<OEL, vecS, D, VP, EdgeBundle> Graph;

You can now create property maps over the bundles for use in different
generic graph algorithms. Or you can access the bundles as:

Graph g;
g[e].distance = 3; // e is edge descriptor.

Bundled properties are actually converted into interior properties through
metaprogramming. If you want to create a class with both interior and
bundled properties, you could write:

typedef property<edge_index_t, size_t, EdgeBundle> Prop;

At least, that should work.

Andrew Sutton
andrew.n.sutton_at_[hidden]



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