题
我已经创建了一个结构,并将其用作模板参数to Adjacency_list。但是,当我尝试添加_edge(vertex1,vertex2,属性,图形)时,编译器抱怨“无匹配函数调用”。谁能看到我在这里出错的地方?
#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;
}
谢谢,
大卫
解决方案
在此代码中, MyProperty
被声明为顶点属性,而不是边缘属性,因此将边缘插入该属性是没有意义的。尝试添加 boost::no_property
前 MyProperty
在你的 adjacency_list
Typedef。
不隶属于 StackOverflow