简体   繁体   English

Boost图形库undirected_graph:如何指定顶点类型(例如int)?

[英]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 the AdjacencyMatrix , IncidenceGraph concept and the VertexIndexGraph concepts. 要求: Graph类型必须是AdjacencyMatrixIncidenceGraph概念和VertexIndexGraph概念的模型。 [¹ 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.]. [¹实现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.

相关问题 boost图形库:合并无向图 - boost graph library: Merging undirected graphs Boost Graph Library:如何保持对顶点的永久引用? (即不受顶点重新编号) - Boost Graph Library: How do I keep a permanant reference to a vertex? (i.e. not subject to vertex re-numbering) Boost Graph Library Undirected Graph没有并行边缘强制执行 - Boost Graph Library Undirected Graph No parallel edges enforcement 我如何从类外部(例如,通过另一个类)使用与boosed_graph有关的模板化typedef,即_in_一个类 - How can I use templated typedefs, that are _in_ a class, from outside the class (e.g. by another class), in relation to boost::graph Boost图形库的性能vertex_descriptor - Performance vertex_descriptor of the Boost Graph Library Boost Graph Library:顶点描述符一定是唯一的吗? - Boost Graph Library: Are Vertex Descriptors Necessarily Unique? 使用Boost Graph库查找连接的组件,其顶点和边类型为boost :: listS - Find connected components using Boost Graph library, with the vertex and edge type being boost::listS Boost图形库:顶点过滤图形上的BFS? - Boost Graph Library: BFS on a Vertex-filtered graph? Boost图形库-具有正好N个边/顶点的图形 - Boost Graph Library - Graph with exactly N Edges/Vertex 增强图形库:named_graph和remove_vertex - boost graph library: named_graph and remove_vertex
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM