Boost BGL捆绑属性添加“U edge”;“没有匹配功能”;
我创建了一个结构,并将其用作邻接列表的模板参数。但是,当我尝试添加_边(vertex1、vertex2、property、graph)时,编译器会抱怨“没有匹配的函数调用”。有人能看出我哪里出错了吗Boost BGL捆绑属性添加“U edge”;“没有匹配功能”;,boost,boost-graph,Boost,Boost Graph,我创建了一个结构,并将其用作邻接列表的模板参数。但是,当我尝试添加_边(vertex1、vertex2、property、graph)时,编译器会抱怨“没有匹配的函数调用”。有人能看出我哪里出错了吗 #include <iostream> #include <boost/graph/adjacency_list.hpp> // Create a struct to hold several properties struct MyProperty { int MyI
#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
{
int属性;
};
//定义图形的类型
typedef boost::邻接列表图;
int main(int,char*[])
{
//创建图形对象
图g(2);
//在节点0和节点1之间添加权重为1.2的边
myp;
p、 MyIntProperty=5;
std::cout在此代码中,MyProperty
被声明为顶点属性而不是边属性,因此使用该属性插入边没有意义。请尝试在邻接列表中的MyProperty
之前添加no_属性