首页 > 解决方案 > Boost C++ 库中的深度优先搜索未显示错误

问题描述

class MyVisitor : public boost::default_dfs_visitor {
public:
    MyVisitor() : vv(new std::vector<DotVertex>()) {}

    void discover_vertex(DotVertex v, const graph_t& g) { //note the lack of const
        //if (boost::in_degree(v, g) != 0) { //only print the vertices in the connected component (I already did MCC and removed edges so all the extra vertices are isolated)
            std::cerr << v.label << std::endl;
            vv->push_back(v);
        //}
        return;
    }
    std::vector<DotVertex>& GetVector() const { return *vv; }
private:
    boost::shared_ptr< std::vector<DotVertex> > vv;
};

我在 boost 中为 DFS 编写了上述访问者。我收到以下错误:

错误 C2664: 'void MyVisitor::discover_vertex(DotVertex,const graph_t &)': 无法将参数 1 从 'unsigned int' 转换为 'DotVertex'

我怎么解决这个问题?

标签: c++boostdepth-first-search

解决方案


推荐阅读