Performance 识别顶点的Boost图

Performance 识别顶点的Boost图,performance,boost,boost-graph,Performance,Boost,Boost Graph,我需要将Boost图中的顶点映射到无符号整数。我从这个网站(,)的相关帖子中了解到,正确的方法是创建一个自定义顶点类 struct Vertex { uint32_t index; }; typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS, Vertex> BoostGraphType; typedef BoostGraphType::vertex_descriptor v

我需要将Boost图中的顶点映射到无符号整数。我从这个网站(,)的相关帖子中了解到,正确的方法是创建一个自定义顶点类

struct Vertex { uint32_t index; };
typedef boost::adjacency_list<boost::vecS, boost::vecS,
    boost::directedS, Vertex> BoostGraphType;    

typedef BoostGraphType::vertex_descriptor vertex_desc;

// now i can use
BoostGraphType g; 

vertex_desc vd = boost::add_vertex(g);
g[vd].index = magic;
结构顶点{uint32_t index;};
typedef boost::邻接列表BoostGraphType;
typedef BoostGraphType::顶点描述符顶点描述;
//现在我可以使用
boostgraphtypeg;
顶点描述vd=boost::添加顶点(g);
g[vd].指数=magic;
但是,根据文档(),顶点描述符可能会变得无效,这意味着我不应该存储它们来映射顶点

因为我有自己的自定义顶点类+.索引,所以这应该不是问题

但是:以后如何检索特定索引的顶点描述符?没有线性搜索我怎么能做到


或者,对于每个顶点,有没有比这样一个自定义顶点类更好的方法来保持一个持久id?

当图形是
邻接列表时