I'm using this typedef
for my BGL graph type, Graph
, using struct VertexProperty
as a bundled vertex property:
struct VertexProperty {
BeamType beam;
size_t index;
};
typedef typename boost::adjacency_list<
boost::listS,
boost::listS,
boost::bidirectionalS,
VertexProperty
> Graph;
Before a recent change in my project, I'd been using the VertexProperty::index
to construct a two_bit_color_map
for use with depth_first_search
:
auto colorMap = boost::make_two_bit_color_map(
boost::num_vertices(graph_),
get(&VertexProperty::index, graph_));
(the graph_
argument is a member variable of type Graph
from above). My recent change re-purposed VertexProperty::index
to store a vertex index number read in from a file, rather than automatically generated by my code. My code had previously been creating these indices as 0-based consecutive indices, incremented for each new vertex added to graph_
. With the change, I wish to no longer assume the indices are consecutive or that they will remain smaller than graph_.size() - 1
; I just don't want to put that constraint on users. However, I continued to use Vertex::index
as the property for the two_bit_color_map
, and this led to a run-time assertion failure with the message:
Assertion failed!
Program: D:\school\thesis\code\build\test\bin\testChain.exe
File: D:\programming\lib\boost\boost_1_54_0/boost/graph/two_bit_color_map.hpp, Line 72
Expression: (std::size_t)i < pm.n
I know I have VertexProperty::index
values that go higher than or equal to graph_.size()
; is my conclusion correct that this is what is causing the assertion failure? I can't find in the BGL docs if there is any such constraint on the index property used with make_two_bit_color_map
.
So, my main quesion is: Is it possible to use both interior properties, specifically property<vertex_index_t, int>
and bundled vertex properties with a BGL graph, or am I stuck with one or the other? (I'd like to avoid implementing the consecutive indices again with a new member in VertexProperty
). I imagine this might look something like this, though probably with other exact syntax:
typedef typename boost::adjacency_list<
boost::listS,
boost::listS,
boost::bidirectionalS,
property<vertex_index_t, int, property<VertexProperty>>
> Graph;