Hi folks,
I'm trying to convert the Boost Graph Library example from a graph
built in the code, to one that usses the adjacency_list_io supporto load
the graph from a file.
I was able to convert the dijkstra example this way, and had no problems.
I'm getting a weird error when I disable GRAPH_CODE (this example is
very close to the true example in the boost source distribution):
test.cpp: In function `int main(int, char**)':
test.cpp:44: no matching function for call to
`johnson_all_pairs_shortest_paths
(main(int, char**)::Graph&, int[V][V], boost::bgl_named_params)'
Here's the actual code;l anybody have suggestions?
#include
#include <fstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include
#include
#include
#include
int
main(int argc, char **argv)
{
using namespace boost;
typedef adjacency_list > > Graph;
typedef std::pair < int, int >Edge;
#if defined GRAPH_CODE
const int V = 5;
Edge edge_array[] =
{ Edge(0, 1), Edge(0, 4), Edge(0, 2), Edge(1, 3), Edge(1, 4),
Edge(2, 1), Edge(3, 2), Edge(3, 0), Edge(4, 3)
};
const std::size_t E = sizeof(edge_array) / sizeof(Edge);
Graph g(edge_array, edge_array + E, V);
property_map < Graph, edge_weight_t >::type w = get(edge_weight, g);
int weights[] = { 3, -4, 8, 1, 7, 4, -5, 2, 6 };
int *wp = weights;
graph_traits < Graph >::edge_iterator e, e_end;
for (boost::tie(e, e_end) = edges(g); e != e_end; ++e)
w[*e] = *wp++;
#else
std::ifstream graph_in(argv[1]);
Graph g;
graph_in >> read( g );
const int V = num_vertices(g);
#endif
std::vector < int >d(V, (std::numeric_limits < int >::max)());
int D[V][V];
johnson_all_pairs_shortest_paths(g, D, distance_map(&d[0]));
return 0;
}