I'm using bundled properties and adjacency_list and would like to use the subgraph class.
struct Vertex
{
int index;
int seed;
};
struct Edge
{
bool visted;
double weight;
};
typedef adjacency_list<listS, listS, undirectedS, Vertex, property<edge_index_t,int,Edge> > Graph;
typedef subgraph<Graph> testSubgraph;
The property<edge_index_t,int,Edge>
part is needed, as subgraph needs edge_index_t
to compare two edges.
Now my question is how do I add an Edge using bundled properties in a Subgraph?
In the normal graph without property<edge_index_t,int,Edge>
I add an edge as following:
Edge e;
vertex_descriptor u,v;
// fill in u and v;
e.weight = 1.0;
e.visted=false;
add_edge(u,v,e,graph);
But this doesn't work for Subgraph.
Hope someone knows a solution for this.
Thanks
Ben
I just ran into the a similar issue when trying to add a vertex with the add_vertex()
function and found that there is a (very old) unresolved issue on the boost bugtracker:
Ticket #380: Support for bundled properties in graph adaptors:
The graph adaptors (such as subgraph) do not support bundled properties, but they should.
Further searching lead to the following 2 patches, which are not yet merged but appear to finally bring the support for bundled properties in subgraphs:
So I guess the answer is: For now, don't use bundled properties. But in the future, the issue should disappear.
An adjacency list do not have edge_index:es. You need to assign an index yourself, but that is as simple as adding a size_t index
to the Edge
, and assigning an index as you create the edges.
You probably do not need to create edges for the subgraph, since the boost subgraphs are induced subgraphs. Therefore, all edges in the graph of which both endpoints are in the subgraph will be included in your subgraphs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With