Reputation: 712
I tried to create a graph disallowing parallel edges using boost::setS, but it gives me an compilation error...
#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&)"
But if I switch the boost::setS to boost::vectorS, it works all right.
Please some expert point out where the program goes wrong... Thank you....
Upvotes: 0
Views: 100
Reputation: 712
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;
Upvotes: 1