Re: [Boost-users] Re: newbie: Graph library - bundled properties
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
Fixed compile error, but has run time error.
Modified graph_property.cpp:
int
main()
{
using namespace boost;
using std::string;
typedef adjacency_list
typedef adjacency_list
graph_t; Change this to:
typedef adjacency_list
property
> 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
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
, property > 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
no_property, edgeStruct, 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
===== TingChong Ma ______________________________________________________________________ Post your free ad now! http://personals.yahoo.ca
participants (1)
-
TC MA