BGL, Johnson all pair shortest path and C
Dear list,
I have to use johnson all pair shortest path[1] to have the all
pair distance matrix and pass it to a C function. Here is the
problem, the C function expect a row-order array, while the
Johnson expect a BasicMatrix[2] that understands the m[row][col]
syntax.
I solved it as shown in the bottom of the email, but it seems so
convoluted, is there a simpler way I missed?
Yours faithfully,
Paolo
[1] http://www.boost.org/doc/libs/release/libs/graph/doc/johnson_all_pairs_short...
[2] http://www.boost.org/doc/libs/release/libs/graph/doc/BasicMatrix.html
/* -------------- */
//p is the graph
//distance_matrix is a std vector
auto size = boost::num_vertices(p);
Matrix distance_matrix1(distance_matrix, size, size);
MatrixR distance_matrix_wrapper(distance_matrix1);
//pass distance_matrix_wrapper to johnson algorithm.
/* -------------- */
struct Matrix {
Matrix(std::vector
participants (1)
-
Paolo Bolzoni