6

我正在使用捆绑属性和 adjacency_list 并想使用 subgraph 类。

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;

property<edge_index_t,int,Edge>部分是必需的,因为子图需要edge_index_t比较两条边。

现在我的问题是如何使用子图中的捆绑属性添加边缘?在没有property<edge_index_t,int,Edge>我添加边的普通图中,如下所示:

Edge e;
vertex_descriptor u,v; 
// fill in u and v;
e.weight = 1.0;
e.visted=false;
add_edge(u,v,e,graph);

但这不适用于 Subgraph。

希望有人知道这个问题的解决方案。

谢谢

4

2 回答 2

2

我在尝试使用该函数添加顶点时遇到了类似的问题add_vertex(),发现 boost bugtracker 上有一个(非常老的)未解决的问题:

票证 #380:支持图形适配器中的捆绑属性

图适配器(例如子图)不支持捆绑属性,但它们应该支持。


进一步搜索导致以下 2 个补丁,它们尚未合并,但似乎最终带来了对子图中捆绑属性的支持:

所以我想答案是:现在,不要使用捆绑属性。但在未来,这个问题应该会消失。

于 2015-11-03T14:30:17.250 回答
1

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.

于 2011-09-30T09:43:41.940 回答