【问题标题】:Boost Subgraph and Bundled propertiesBoost Subgraph 和 Bundled 属性
【发布时间】:2011-11-28 07:29:26
【问题描述】:

我正在使用捆绑属性和 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&lt;edge_index_t,int,Edge&gt; 部分,因为子图需要edge_index_t 来比较两条边。

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

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。

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

谢谢

【问题讨论】:

    标签: c++ boost boost-graph


    【解决方案1】:

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

    Ticket #380: Support for bundled properties in graph adaptors:

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


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

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

    【讨论】:

      【解决方案2】:

      邻接表没有 edge_index:es。您需要自己分配索引,但这就像将size_t index 添加到Edge 并在创建边时分配索引一样简单。

      您可能不需要为子图创建边,因为增强子图是诱导子图。因此,图中所有端点都在子图中的所有边都将包含在您的子图中。

      【讨论】:

      • 如果我只是将 size_t 索引添加到我的 Edge 结构中,它仍然找不到这个索引,因为它在 'property'中是需要的
      猜你喜欢
      • 1970-01-01
      • 2023-03-07
      • 1970-01-01
      • 2015-02-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-23
      • 2010-12-20
      相关资源
      最近更新 更多