我正在寻找一种通过使用键而不是顶点引用本身来访问顶点属性的方法。例如,如果我有
class Data
{
public:
std::string name;
unsigned int value;
};
typedef boost::adjacency_list< boost::vecS, boost::vecS, boost::directedS, Data > Graph;
typedef boost::graph_traits<Graph>::vertex_descriptor Vertex;
而不是使用
Vertex vertex1 = boost::add_vertex( g );
g[vertex1].name = "Alpha";
g[vertex1].value = 10;
我想拥有
g["Alpha"].name = "Alpha";
g["Alpha"].value = 10;
是否存在即用型机制?