Boost logo

Boost Users :

Subject: Re: [Boost-users] BGL -- adjacency_matrix, graph concepts
From: Raymond Wan (r.wan_at_[hidden])
Date: 2009-10-07 08:12:57


Hi Andrew,

Andrew Sutton wrote:
>> sample.cpp: In function âint main()â:
>>
>> sample.cpp:34: error: no matching function for call to
>> âboost::adjacency_matrix<boost::undirectedS, boost::no_property,
>> boost::property<boost::edge_weight_t, int, boost::no_property>,
>> boost::no_property, std::allocator<bool> >::adjacency_matrix(main()::E
>> [7], main()::E*, int [7], const int&)â
>>
>
> Hmmm... I wonder if the compiler is having trouble telling the difference
> between edges and edges + num_edges. You might try passing edges as
> &edges[0] to force the compiler to treat it as a pointer. Maybe?

Unfortunately, no luck... And I didn't have this problem with
adjacency_list (sorry for not saying this explicitly before!) and the
same compiler (g++ v4.3.2). I guess that made me wonder if maybe this
constructor does not exist? Or maybe I need to #include something more
besides just "adjacency_matrix.hpp"?

Hmmmm, I hope this is not too much to ask, but can you or someone else
check if the sample code I posted before compiles (with the offending
line uncommented)? I should compile as-is... Just to check if I'm
going nuts... :-) Here it is again below [with the line commented out,
so this should compile].

Thank you!

Ray

-----
#include <boost/config.hpp>
#include <boost/graph/adjacency_matrix.hpp>
#include <boost/graph/graph_utility.hpp>
#include <iostream>

int main () {
   using namespace boost;
   typedef adjacency_matrix < undirectedS, no_property, property <
edge_weight_t, int > > Graph;
   typedef graph_traits < Graph >::edge_descriptor Edge;
   typedef graph_traits < Graph >::vertex_descriptor Vertex;
   typedef std::pair<int, int> E;

   const int num_nodes = 5;
   E edges[] = { E(0, 2), E(1, 3), E(1, 4), E(2, 1), E(2, 3),
     E(3, 4), E(4, 0)
   };
   int weights[] = { 1, 1, 2, 7, 3, 1, 1 };
   std::size_t num_edges = sizeof(edges) / sizeof(E);

   Graph g1 (num_nodes);
   for (unsigned int i = 0; i < num_edges; i++) {
     add_edge (edges[i].first, edges[i].second, g1);
   }
   print_graph (g1);

   Graph g2 (num_nodes);
// Graph g2 (&edges[0], edges + num_nodes, weights, num_nodes);
   print_graph (g2);

   return EXIT_SUCCESS;
}


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