【问题标题】:BGL Bundled Properties add_edge "no matching function"BGL 捆绑属性 add_edge “无匹配功能”
【发布时间】:2011-01-26 21:27:22
【问题描述】:

我创建了一个结构,并将其用作 adjacency_list 的模板参数。但是,当我尝试 add_edge(vertex1, vertex2, property, graph) 时,编译器会抱怨“没有匹配的函数调用”。任何人都可以在这里看到我哪里出错了吗?

#include <iostream>
#include <boost/graph/adjacency_list.hpp>

// Create a struct to hold several properties
struct MyProperty
{
  int MyIntProperty;
};

// Define the type of the graph
typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS, MyProperty> Graph;

int main(int,char*[])
{
  // Create a graph object
  Graph g(2);

  // Add an edge between node 0 and node 1 with weight 1.2
  MyProperty p;
  p.MyIntProperty = 5;
  std::cout << p.MyIntProperty << std::endl;
  add_edge(0, 1, p, g);

  return 0;
}

谢谢,

大卫

【问题讨论】:

    标签: boost boost-graph


    【解决方案1】:

    在此代码中,MyProperty 被声明为顶点属性而不是边属性,因此插入具有该属性的边没有意义。尝试在 adjacency_list 类型定义中的 MyProperty 之前添加 boost::no_property

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-01-25
      • 2015-09-17
      • 1970-01-01
      • 1970-01-01
      • 2012-12-04
      • 2017-09-03
      • 1970-01-01
      相关资源
      最近更新 更多