Boost logo

Boost Users :

From: David E. Konerding DSD staff (dekonerding_at_[hidden])
Date: 2005-03-07 17:35:32


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<int*,
   boost::vertex_distance_t, boost::no_property>)'

Here's the actual code;l anybody have suggestions?

#include <boost/config.hpp>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <boost/property_map.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/adjacency_list_io.hpp>
#include <boost/graph/johnson_all_pairs_shortest.hpp>

int
main(int argc, char **argv)
{
  using namespace boost;
  typedef adjacency_list<vecS, vecS, directedS, no_property,
    property< edge_weight_t, int, property< edge_weight2_t, int > > > 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;
}


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net