Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Boost Subgraph and Bundled properties

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

like image 200
Ben Avatar asked Sep 30 '11 08:09

Ben


2 Answers

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:

  • Ticket #10708: Property support in add_vertex() method for subgraph
  • Ticket #10709: Graph bundled property support in subgraph

So I guess the answer is: For now, don't use bundled properties. But in the future, the issue should disappear.

like image 126
Slizzered Avatar answered Sep 28 '22 10:09

Slizzered


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.

like image 20
carlpett Avatar answered Sep 28 '22 08:09

carlpett