将参数传递给push_relabel_max_flow()是否有错误?

时间:2017-04-16 15:18:22

标签: c++ boost

所以这是我使用Boost C ++ lib中的push_relabel_max_flow函数通过网络获取最大流量的代码。

#include <string>
#include <boost/graph/adjacency_list.hpp>
#include <iostream>
#include <boost/graph/push_relabel_max_flow.hpp>
typedef boost::adjacency_list_traits<boost::vecS, boost::vecS, boost::directedS> Traits;

struct VertexProps {
    std::string name;
};

struct EdgeProps {
    long capacity;
    long residual_capacity;
    Traits::edge_descriptor reverse;
};

typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS, boost::no_property, EdgeProps > DirectedGraph;

int main() {
    DirectedGraph g;
    Traits::vertex_descriptor s, t;

    s = boost::add_vertex(g);
    t = boost::add_vertex(g);
    boost::add_vertex(g);

boost::add_edge(s, 2, { 33, 0 }, g);
boost::add_edge(2, t, { 33, 0 }, g);
auto capacity = boost::get(&EdgeProps::capacity, g);
    auto reverse = boost::get(&EdgeProps::reverse, g);
    auto residcap = boost::get(&EdgeProps::residual_capacity, g);
    auto indexmap = boost::get(boost::vertex_index, g);
    std::vector<DirectedGraph::vertex_descriptor> vertices;
int flow = boost::push_relabel_max_flow(g, s, t,capacity,residcap ,reverse,indexmap);
    std::cout << flow;
    return 0;
}

运行此代码后,它会显示错误

Exception thrown at 0x008D2551 in ConsoleApplication4.exe: 0xC0000005: Access violation reading location 0x00000004.

我有什么遗失的吗?这里有什么问题?

0 个答案:

没有答案