yamiddu
yamiddu

Reputation: 43

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, e.g., 'int'?

The 'int' vertex type seems to be the default with the boost::adjacency_list, and the following code works:

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

but fails with an undirected_graph. What additional steps should I do to use the same syntax for adding vertices to an undirected_graph?

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

thanks

Upvotes: 0

Views: 199

Answers (1)

sehe
sehe

Reputation: 392929

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

The source tells me it accepts generic graphs (as BGL does):

The docs are hard to find (might be a bug in the quickbook definitions?), but here goes:

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.].

Head over to Concepts page in BGL documentation to see which graph types fit the bill.

I see that the likely "missing link" is the VertexIndexGraph concept. You can likely achieve this by adding a vertex_index_t Interior Property

Upvotes: 1

Related Questions