定义boost压缩稀疏行图

时间:2012-03-18 22:27:44

标签: c++ boost generic-programming

我知道这可能是显而易见的,但请注意我的通用编程背景很弱。

这是我要编译的代码:

#define BOOST_GRAPH_USE_NEW_CSR_INTERFACE
#include <boost/graph/compressed_sparse_row_graph.hpp>
#include <vector>

typedef unsigned int uint32_t;
typedef unsigned long uint64_t;

using namespace boost;
using namespace std;

typedef compressed_sparse_row_graph<directedS,void,void,no_property,uint32_t,uint64_t> intl_graph;
typedef std::pair<uint32_t,uint32_t> E;

int main()
{
    intl_graph g;
    vector<E> the_edges;
    uint32_t nv = 3;
    uint64_t nedge;

    the_edges.push_back(E(0,1));
    the_edges.push_back(E(1,2));

    g = intl_graph(edges_are_unsorted_t,the_edges.begin(),the_edges.end(),nv); //line 24
}

会导致此错误:

boost_eg.cpp: In function âint main()â:
boost_eg.cpp:24: error: expected primary-expression before â(â token
boost_eg.cpp:24: error: expected primary-expression before â,â token

如果我将第24行更改为:

intl_graph g_(edges_are_unsorted_t,the_edges.begin(),the_edges.end(),nv);

错误是这样的:

boost_eg.cpp: In function âint main()â:
boost_eg.cpp:24: error: âthe_edgesâ is not a type
boost_eg.cpp:24: error: expected â,â or â...â before â.â token

有什么想法吗?

参考结束于此:

http://www.boost.org/doc/libs/1_49_0/libs/graph/doc/compressed_sparse_row.html

1 个答案:

答案 0 :(得分:2)

你必须替换

g = intl_graph(edges_are_unsorted_t,the_edges.begin(),the_edges.end(),nv); //line 24

通过

g = intl_graph(edges_are_unsorted,the_edges.begin(),the_edges.end(),nv); //line 24