Boost Graph Library undirected_graph:如何指定顶点类型(例如 int)?

Boost Graph Library undirected_graph: how to specify the vertex type (e.g. as int)?

是否可以将 boost::undirected_graph 中的顶点类型固定为 'int'?

'int' 顶点类型似乎是 boost::adjacency_list 的默认值,下面的代码有效:

boost::adjacency_list< boost::vecS, boost::vecS, boost::undirectedS> g; boost::add_edge(0 , 1 , g);

但失败并显示 undirected_graph。我应该执行哪些额外步骤才能使用相同的语法将顶点添加到 undirected_graph?

我需要使用只接受 undirected_graph 作为输入的 bron_kerbosch_all_cliques 算法。

谢谢

I need to use a bron_kerbosch_all_cliques algorithm which only accepts undirected_graph as input.

消息来源告诉我它接受通用图形(就像 BGL 那样):

文档很难找到(可能是 quickbook 定义中的错误?),但这里是:

Requirements: The Graph type must be a model of the AdjacencyMatrix, IncidenceGraph concept and the VertexIndexGraph concepts. [¹ Any Graph type that implements the edge() function will satisfy the expression requirements for the AdjacencyMatrix, but may incur additional overhead due non-constant time complexity.].

前往 BGL 文档中的 概念 页面,查看符合要求的图表类型。

我看到可能 "missing link" 是 VertexIndexGraph 概念。您可以通过添加 vertex_index_t Interior Property

来实现此目的