Boost logo

Boost Users :

Subject: Re: [Boost-users] [graph] Bundled properties in subgraphs
From: Andrew Sutton (andrew.n.sutton_at_[hidden])
Date: 2009-01-10 09:58:05


>
> It seems that bundled properties still don't work with subgraphs. I found a
> mention of the problem dating back to 2005 [1], a closed ticket for the
> issue [2] and another post [3], this time from 2008, with an ex tempore fix
> (which doesn't work for me). Could someone possibly account for that?
>
> [1] http://lists.boost.org/boost-users/2005/03/10844.php
> [2] https://svn.boost.org/trac/boost/ticket/380
> [3]
> http://www.nabble.com/-graph--property_map-from-bundled-properties-in-a-subgraph,-how--td16541750.html
>
> TIA,
> Greg Slodkowicz
>

I applied the patch from Dmitry and added a new test file for subgraphs with
bundled properties and everything seems to work just fine in trunk. There
are some caveats, of course.

1. Subraphs require interior index properties for both vertices and edges,
and no adjacency list provides both of these by default. You get vertex
indices with VertexSet == vecS, but that's about it. You have to modify the
properties of the *underlying* adjacency list - not just the subgraph. For
example:

// Define the edge property
struct my_edge { ... };
typedef property<edge_index_t, size_t, my_edge> edge_prop;

// Define the underlying graph and the subgraph
typedef adjacency_list<vecS, vecS, undirectedS, my_vertex, edge_prop> Graph;
typedef subgraph<Graph> Subgraph;

2. This may not fully solve your problem since simply providing indices
doesn't mean that they're going to be used. You may need to explicitly set
the index of each vertex or edge during graph construction. If you remove
vertices or edges... well, that doesn't seem to be a well explored operation
with subgraphs.

3. Property maps are accessed from the subgraph:

Subgraph sg;
typedef property_map<Subgraph, int my_edge::*>::type WeightMap;
WeightMap weights = get(&my_edge::weight, sg);

Boost 1.38.0 release branch is closed, so this won't appear in the release
until 1.39.

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