I have a problem with the boost graph library.
At the initialization step, I want to store an image in this adjacency graph:
typedef boost::adjacency_list<boost::vecS,
boost::vecS,
boost::undirectedS,
boost::property<boost::vertex_bundle_t, unsigned int>,
boost::property<boost::edge_bundle_t, float>,
boost::no_property> GraphType
I did a first loop to create for each pixel of the image a vertex (use OTB library to handle the image, in_iter is just an iterator on the pixel of the image):
unsigned long int curr_id = 0;
for(in_iter.GoToBegin(); !in_iter.IsAtEnd(); ++in_iter)
{
boost::add_vertex(curr_id, *_graph);
curr_id++;
}
And now I want to create for a vertex its connections with its neighbors (4 connexity): I tried this but it doesn't work:
curr_id = 0;
long int neighbors[4];
auto iterBounds = boost::vertices(*_graph);
for(auto v_iter = iterBounds.first; v_iter != iterBounds.second; v_iter++)
{
FindNeighboring(curr_id, neighbors, rows, cols);
for(short j = 0; j<4; j++)
{
if(neighbors[j] > -1)
{
boost::add_vertex(*_graph->m_vertices[curr_id],
*_graph->m_vertices[neighbors[j]],
std::numeric_limits<float>::max();
*_graph);
}
}
}
I want to access to the vertex descriptor knowing its position. Is it possible to do that in BGL ?
Thank you for your help !