Hi,
I want to represent a graph that consists of several layers. I have an
algorithm that is supposed to be run on each layer seperately. I thought
about having all layers in one graph, but each layer in a subgraph of this
graph. That way - I thought - I could leave the algorithm that works on one
layer unchanged.
First off: Is that a reasonable design? Is there a different way to achieve
what I want? Maybe there is another way to pass a subset of the graph to my
algorithm?
Now as for the actual problem with boost subgraphs:
My current code (for one layer only) looks similar to this:
----
struct my_vertex { int x; };
struct my_edge { int y; };
typedef boost::adjacency_list
NormalGraph;
NormalGraph ng;
NormalGraph::vertex_descriptor vd=add_vertex(ng);
ng[vd].x=5;
----
So as you can see I am using bundled properties.
Now I want to create the same thing with subgraphs. Just doing
----
typedef boost::subgraph > SubGraph;
----
Did not work and I suspected it was due to the problem mentioned in the
"Notes" section at the very bottom of [1] - which I dont quite understand to
be honest. I still tried to use the workaround that is mentioned there:
----
struct my_vertex { int x; };
struct my_edge { int y; };
typedef boost::property
vertex_prop;
typedef boost::property
edge_prop;
typedef boost::adjacency_list Graph;
typedef boost::subgraph<Graph> Subgraph;
Subgraph sg;
Subgraph::vertex_descriptor vd=add_vertex(sg);
sg[vd].x=5; // doesnt work - why?
auto pm=get(boost::vertex_bundle,sg);
my_vertex vert;
vert.x=7;
put(pm,vd,vert); // doesnt work - why?
----
Now I do not understand how to access my vertex and edge properties as you
can see... Neither using [] nor accessing via property maps appears to work.
What am I doing wrong here? I couldnt find any documentation or examples on
this :(
Thanks a lot
Frank
[1] http://www.boost.org/doc/libs/1_46_0/libs/graph/doc/subgraph.html