簡體   English   中英

當我嘗試使用 setS 創建一個不允許平行邊的圖形時,boost 圖形庫給了我一個編譯 add_edge 錯誤

[英]boost graph library gives me a compilation add_edge error when I try to create a graph with setS disallowing parallel edges

我嘗試使用 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);
}
}

我收到以下錯誤:錯誤:沒有匹配的 function 調用“add_edge(int&, int&, MyGraphType&)”

但是如果我將 boost::setS 切換為 boost::vectorS,它就可以正常工作。

請高手指出程序出錯的地方...謝謝...

對不起,我弄亂了圖形定義的順序,應該是:

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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM