小编Aqu*_*pax的帖子

增强图中的彩色地图breadth_first_visit

我想使用boosts breadth_first_visit方法,我想为它提供我自己的"外部"颜色映射.我将图表定义如下

typedef boost::adjacency_list<boost::setS, boost::listS, boost::undirectedS, 
  boost::property<boost::vertex_index_t, int, 
  boost::property<boost::vertex_color_t, boost::default_color_type, 
  Node_t>>>  GraphType;
Run Code Online (Sandbox Code Playgroud)

where Node_t是结构,定义顶点的属性.但是,我无法找到如何为BFS提供我自己的颜色图.我想将顶点颜色存储在矢量中,所以我的定义看起来像

std::vector<boost::default_color_type> colors;
Run Code Online (Sandbox Code Playgroud)

但我无法弄清楚,如何将此用于bfs.

也不

boost::breadth_first_search(g, *boost::vertices(g).first, 
  boost::color_map(colors));
Run Code Online (Sandbox Code Playgroud)

也不

boost::breadth_first_search(g, *boost::vertices(g).first, 
  boost::color_map(&colors[0]));
Run Code Online (Sandbox Code Playgroud)

工作中.虽然第一个给了我一堆不同的编译器错误(例如不支持default-int,"boost :: color_traits"使用类类型需要类型参数列表)第二个编译只用C2664中止:'boost :: put'不能将参数2从'void*'转换为'ptrdiff_t'.

所以问题是:我如何使用自己的颜色映射结构.另一个问题是:我如何获得特定vertex_descriptor的颜色值?

c++ boost properties graph

5
推荐指数
1
解决办法
3116
查看次数

重载类函数运算符两次作为setter和getter

我有一个类,我想重载fuction-call操作符.但是由于C++标准禁止声明两个类似的方法只返回类型不同,我得到编译错误C2556.我想将这些函数用作getter和setter方法.我知道我可以通过创建一个get和一个set函数来实现这一点.所以问题是:有没有办法以某种方式实现这一目标?

class Foo
{
    private:
        std::vector<int> m_vec;

    public:
        Foo()
        {
            m_vec.push_back(1);
            m_vec.push_back(2);
            m_vec.push_back(3);
        }

        //Getter
        int operator()(int i)
        {
            return m_vec.at(i);
        }

        //Setter (C2556)
        int& operator()(int i)
        {
            return m_vec.at(i);
        }
};

int main()
{
    Foo foo;
    foo(1) = 10; //use the setter 
    int i = foo(1); //use the getter
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

c++ function operator-keyword

2
推荐指数
1
解决办法
2134
查看次数

Team Explorer 2012中的"团队成员"面板在哪里?

我安装了团队资源管理器2012和TFS Power Tools 2012,因为我需要工作区模板功能.但是在启动团队资源管理器并连接到我们的TFS 2012后,我找不到"团队成员"菜单,我可以在其中设置这些工作区模板.我错过了什么吗?这个菜单位于其他地方吗?

workspace tfs templates

1
推荐指数
1
解决办法
1853
查看次数