[英]boost graph library gives me a compilation add_edge error when I try to create a graph with setS disallowing parallel edges
I tried to create a graph disallowing parallel edges using boost::setS, but it gives me an compilation error...我尝试使用 boost::setS 创建一个不允许平行边的图形,但它给了我一个编译错误......
#include <iostream>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/graphviz.hpp>
#include <boost/graph/properties.hpp>
#include <boost/property_map/property_map.hpp>
#include <boost/graph/named_function_params.hpp>
#include <boost/graph/iteration_macros.hpp>
#include <random>
struct VertexData
{
long account_id;
};
struct EdgeData
{
// std::list<long> transaction_ids;
long edge_id;
};
typedef boost::adjacency_list<boost::vecS, boost::setS,
boost::directedS,
VertexData,
boost::property<boost::edge_weight_t, double, EdgeData>
> MyGraphType;
void test_insert_data(size_t vertex_size, size_t edge_size)
{
std::random_device rd; // Only used once to initialise (seed) engine
std::mt19937 rng(rd()); // Random-number engine used (Mersenne-Twister in this case)
std::uniform_int_distribution<int> uni(0, vertex_size - 1); // Guaranteed unbiased
auto random_integer = uni(rng);
MyGraphType g;
for (size_t i = 0; i < vertex_size; i++)
add_vertex(g);
for (size_t j = 0; j < edge_size; j++)
{
auto from = uni(rng);
auto to = uni(rng);
add_edge(from, to, g);
}
}
I got an error below: error: no matching function for call to "add_edge(int&, int&, MyGraphType&)"我收到以下错误:错误:没有匹配的 function 调用“add_edge(int&, int&, MyGraphType&)”
But if I switch the boost::setS to boost::vectorS, it works all right.但是如果我将 boost::setS 切换为 boost::vectorS,它就可以正常工作。
Please some expert point out where the program goes wrong... Thank you....请高手指出程序出错的地方...谢谢...
sorry I messed up the order of the definition of graph, it should be:对不起,我弄乱了图形定义的顺序,应该是:
typedef boost::adjacency_list<boost::setS, boost::vecS,
boost::directedS,
VertexData,
boost::property<boost::edge_weight_t, double, EdgeData>
> MyGraphType;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.