Boost logo

Boost Users :

From: Doug Gregor (dgregor_at_[hidden])
Date: 2004-11-23 17:27:53


On Nov 23, 2004, at 11:23 AM, TC MA wrote:
> struct graphStruct {
> string name;
> };

Unfortunately, bundled graph properties aren't supported (yet). You
can, however, add a graph name property using property<graph_name_t,
string> (see below).

> typedef adjacency_list<vecS, vecS,
> directedS,no_property, edgeStruct, graphStruct>
> graph_t;

Change this to:

typedef adjacency_list<vecS, vecS, directedS, no_property, edgeStruct,
                                           property<graph_name_t,
string> > graph_t;

> g[e].name = "graphname";
>
> std::cout << "name: " << g[e].name << std::endl;

These two won't compile because we can't get at the graph properties
that way. "e" is an edge descriptor, so "g[e]" is going to give you an
edgeStruct& back (that's how we were able to set the edge weight ). To
get to the graph_name property we just added above, use:

        get_property(g, graph_name);

If we can come up with a better syntax for the future, we'll definitely
do it. For now, we're stuck with that mess.

> typedef subgraph<graph_t> subgraph_t;

You're actually going to run into a minor problem here, because the
subgraph adaptor requires an edge_index property that we haven't
provided. The easiest way to introduce such a property is to actually
mix bundled and non-bundled parameters, like so:

typedef adjacency_list<vecS, vecS, directedS, no_property,
property<edge_index_t, int, edgeStruct>,
                                           property<graph_name_t,
string> > graph_t;

Notice how we put in the edge_index_t property, but ended with an
"edgeStruct"? That allows, e.g., g[e].weight to still work, but the
subgraph can use the edge index property map directly.

> subgraph_t sg;
> get_property(sg, graph_name) = "subgraph";
>
> std::cout << "name: " << get_property(sg,
> graph_name) << std::endl;
>
> return exit_success;
> }

All of this is fine; it's actually what we changed the above code to.

As you can probably tell, we're still working out some of the kinks in
the bundled properties setup. It's better than what we had before, but
we still have a bit of work to do to make it really slick.

        Doug


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