[英]Boost Graph Library undirected_graph: how to specify the vertex type (e.g. as int)?
is it possible to fix the type of the vertices in a boost::undirected_graph
such to be, eg, 'int'? 是否可以将
boost::undirected_graph
中的顶点类型固定为例如'int'?
The 'int' vertex type seems to be the default with the boost::adjacency_list
, and the following code works: boost::adjacency_list
似乎是默认的'int'顶点类型,以下代码有效:
boost::adjacency_list< boost::vecS, boost::vecS, boost::undirectedS> g; boost::add_edge(0 , 1 , g);
but fails with an undirected_graph. 但失败并显示undirected_graph。 What additional steps should I do to use the same syntax for adding vertices to an undirected_graph?
我应该执行哪些其他步骤才能使用相同的语法将顶点添加到undirected_graph?
I need to use a bron_kerbosch_all_cliques
algorithm which only accepts undirected_graph as input. 我需要使用仅接受undirected_graph作为输入的
bron_kerbosch_all_cliques
算法。
thanks 谢谢
I need to use a bron_kerbosch_all_cliques algorithm which only accepts undirected_graph as input.
我需要使用仅接受undirected_graph作为输入的bron_kerbosch_all_cliques算法。
The source tells me it accepts generic graphs (as BGL does): 消息人士告诉我,它接受通用图(就像BGL一样):
The docs are hard to find (might be a bug in the quickbook definitions?), but here goes: 很难找到文档(可能是Quickbook定义中的错误吗?),但是这里有:
Requirements: The
Graph
type must be a model of theAdjacencyMatrix
,IncidenceGraph
concept and theVertexIndexGraph
concepts.要求:
Graph
类型必须是AdjacencyMatrix
,IncidenceGraph
概念和VertexIndexGraph
概念的模型。 [¹ AnyGraph
type that implements theedge()
function will satisfy the expression requirements for theAdjacencyMatrix
, but may incur additional overhead due non-constant time complexity.].[¹实现
edge()
函数的任何Graph
类型都将满足AdjacencyMatrix
的表达式要求,但由于非恒定时间复杂性,可能会产生额外的开销。
Head over to Concepts page in BGL documentation to see which graph types fit the bill. 转到BGL文档中的“ 概念”页面,以查看适合该图的图形类型。
I see that the likely "missing link" is the VertexIndexGraph concept. 我看到了可能的“缺失链接”是VertexIndexGraph概念。 You can likely achieve this by adding a
vertex_index_t
Interior Property 您可以通过添加一个
vertex_index_t
Interior属性来实现此目的
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.